diff --git a/fluent.asdl b/fluent.asdl index 9c05d67..49655a3 100644 --- a/fluent.asdl +++ b/fluent.asdl @@ -2,35 +2,49 @@ module Fluent { res = Resource(entry* body, comment? comment) - entry = Message(iden id, pat? value, attr* attrs, comment? comment) + entry = Message(iden id, pat? value, attr* attributes, comment? comment) | Section(key key, comment? comment) | Comment(comment) | Junk(string body) - pat = Pattern(expr* elements, bool quoted) + -- Pattern values + pat = Pattern(elem* elements, bool quoted) + elem = String(string) + | Placeable(plcbl) - expr = Selector(sel) - | SelectExpression(sel? sel, var* vars) + -- Expressions allowed inside of braced Placeables + plcbl = Expression(expr) + | SelectExpression(expr? expr, var* vars) - sel = MessageReference(iden id) - | ExternalArgument(iden id) - | CallExpression(iden callee, expr* args) - | VariantExpression(iden msg, varkey key) - | AttributeExpression(iden msg, iden id) - | KeyValueArgument(iden name, argval val) - | Number(string value) - | String(string value) + -- Expressions allowed as selectors of SelectExpression and + -- arguments to CallExpression + expr = Pattern(pat) + | Number(number) + | MessageReference(iden id) + | ExternalArgument(iden id) + | AttributeExpression(iden id, iden name) + | VariantExpression(iden id, varkey key) + | CallExpression(fun callee, arg* args) + . | Placeable(plcbl) + -- Attributes of Message attr = Attribute(iden id, pat value) + + -- Variants of SelectExpression var = Variant(varkey key, pat value, bool default) - varkey = Number(string value) - | Keyword(key name) + varkey = Number(number) + | Keyword(key) - argval = Number(string value) - | String(string value) + -- Arguments to CallExpression + arg = Expression(expr) + | NamedArgument(iden name, argval val) + argval = Number(number) + | String(string) iden = (string name) key = (string name) + fun = (string name) + number = (string value) comment = (string body) } diff --git a/fluent.ebnf b/fluent.ebnf index e75ca58..05073e6 100644 --- a/fluent.ebnf +++ b/fluent.ebnf @@ -11,7 +11,7 @@ __ ::= [#x20#x9]* /* space, tab */ NL ::= [#xA#xD]+ /* line feed, carriage return */ identifier ::= [a-zA-Z_?-] ([a-zA-Z0-9_?-])* -variable ::= '$' identifier +external ::= '$' identifier keyword ::= [a-zA-Z_.?-] ([a-zA-Z0-9_.?- ]* [a-zA-Z0-9_.?-])? builtin ::= [A-Z_?-]+ number ::= [0-9]+ ('.' [0-9]+)? @@ -33,19 +33,17 @@ unquoted-text ::= ([^{] | '\{')+ quoted-text ::= ([^{"] | '\{' | '\"')+ block-text ::= NL __ '|' unquoted-pattern -placeable ::= '{' __ expression __ '}' -expression ::= selector-expression | select-expression | variant-list - -selector-expression ::= quoted-pattern +placeable ::= '{' __ (expression | select-expression | variant-list) __ '}' +expression ::= quoted-pattern | number | identifier - | variable + | external | attribute-expression | variant-expression | call-expression | placeable -select-expression ::= selector-expression __ ' ->' __ variant-list +select-expression ::= expression __ ' ->' __ variant-list attribute-expression ::= identifier '.' identifier variant-expression ::= identifier '[' keyword ']' call-expression ::= builtin '(' __ arglist? __ ')'