Skip to content

Fix #3. Use { and } for explicit grouping #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions fluent.asdl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ module Fluent

pat = Pattern(expr* elements, bool quoted)

expr = MessageReference(iden id)
| ExternalArgument(iden id)
| CallExpression(iden callee, expr* args)
| SelectExpression(expr exp, mem* vars)
| MemberExpression(expr obj, memkey key)
| KeyValueArgument(iden name, argval val)
| Number(string value)
| String(string value)
expr = Selector(sel)
| SelectExpression(sel sel, mem* vars)

sel = MessageReference(iden id)
| ExternalArgument(iden id)
| CallExpression(iden callee, expr* args)
| MemberExpression(expr obj, memkey key)
| KeyValueArgument(iden name, argval val)
| Number(string value)
| String(string value)

mem = Member(memkey key, pat value, bool default)
memkey = Number(string value)
Expand Down
8 changes: 5 additions & 3 deletions fluent.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ quoted-text ::= ([^{"] | '\{' | '\"')+
block-text ::= NL __ '|' unquoted-pattern

placeable ::= '{' __ expression __ '}'
expression ::= quoted-pattern
expression ::= selector-expression | select-expression

selector-expression ::= quoted-pattern
| number
| identifier
| variable
| select-expression
| member-expression
| call-expression
| placeable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why placeable?

key = { { $foo } ->
  [one] Value
}

is that intended to work?

Copy link
Contributor Author

@stasm stasm Jan 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's not what the serializer would normally serialize to, but I don't think we need to artificially limit the syntax here. It doesn't change the meaning compared to just using $foo, just like (1) === 1 in JavaScript.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what's the use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use case is tightly related to #4. In particular, we need a way to remove the ambiguity from call-expressions with multiple arguments, some of them being select-expressions:

key = { LIST(foo, { bar, baz -> 
        [bar, baz] Bar and Baz
    }) }


select-expression ::= expression __ ' ->' __ variants-list
select-expression ::= selector-expression __ ' ->' __ variants-list
member-expression ::= identifier '[' keyword ']'
call-expression ::= builtin '(' __ arglist? __ ')'
arglist ::= argument (__ ',' __ arglist)?
Expand Down