Skip to content

Add an intermediate Placeable production for Expressions within Patterns #52

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
Aug 9, 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
11 changes: 10 additions & 1 deletion spec/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

## Unreleased

- …
- Added the `Placeable` production as a wrapper for expressions in patterns.

This allows storing more precise information about the whitespace around
the placeable's braces.

- Separated the `expr` type into `inline_expr` and `block_expr`.

This mirrors the EBNF, where a select expression cannot by an argument to
a call expression nor selector of another select expression without being
wrapped in braces.

## 0.3.0

Expand Down
27 changes: 15 additions & 12 deletions spec/fluent.asdl
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,22 @@ module Fluent
-- Pattern values
pat = Pattern(elem* elements, span? span)
elem = TextElement(string value, span? span)
| Expression(expr)
| Placeable(expr expression, span? span)

-- Expressions
expr = StringExpression(string)
| NumberExpression(number)
| MessageReference(iden id)
| ExternalArgument(iden id)
| SelectExpression(expr? expression, var* variants)
| AttributeExpression(iden id, iden name)
| VariantExpression(iden id, varkey key)
| CallExpression(fun callee, arg* arguments)
| Expression(expr)
attributes (span? span)
expr = InlineExpression(inline_expr)
| BlockExpression(block_expr)
inline_expr = StringExpression(string)
| NumberExpression(number)
| MessageReference(iden id)
| ExternalArgument(iden id)
| AttributeExpression(iden id, iden name)
| VariantExpression(iden id, varkey key)
| CallExpression(fun callee, arg* arguments)
| Placeable(expr expression)
attributes (span? span)
block_expr = SelectExpression(inline_expr? expression, var* variants)
attributes (span? span)

-- Attributes of Message
attr = Attribute(iden id, pat value, span? span)
Expand All @@ -63,7 +66,7 @@ module Fluent
| Symbol(symb)

-- Arguments to CallExpression
arg = Expression(expr)
arg = Expression(inline_expr)
| NamedArgument(iden name, argval value, span? span)
argval = NumberExpression(number)
| StringExpression(string)
Expand Down
11 changes: 7 additions & 4 deletions spec/fluent.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,23 @@ text ::= text-char+
quoted-text ::= '"' (text-char - '"' | '\"')+ '"'


placeable ::= '{' __? (expression | select-expression | variant-list) __? '}'
expression ::= quoted-text
placeable ::= '{' __? (inline-expression | block-expression) __? '}'

inline-expression ::= quoted-text
| number
| identifier
| external
| attribute-expression
| variant-expression
| call-expression
| placeable
block-expression ::= select-expression
| variant-list

select-expression ::= expression __ '->' __ variant-list
select-expression ::= inline-expression __ '->' __ variant-list
attribute-expression ::= identifier '.' identifier
variant-expression ::= identifier '[' _? variant-key _? ']'
call-expression ::= builtin '(' __? (argument ( __? ',' __? argument)*)? __? ')'
argument ::= expression
argument ::= inline-expression
| named-argument
named-argument ::= identifier __? ':' __? (quoted-text | number)