Skip to content

Commit ab9bd58

Browse files
committed
Remove VariantLists
1 parent 502a392 commit ab9bd58

17 files changed

+276
-654
lines changed

spec/CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 0.9.0 (Unreleased)
4+
5+
- Remove `VariantLists`. (#204)
6+
7+
The `VariantLists` and the `VariantExpression` syntax and AST nodes were
8+
deprecated in Syntax 0.9 and have now been removed.
9+
310
## 0.8.0 (December 13, 2018)
411

512
- Preserve content-indent in multiline `Patterns`. (#162)
@@ -73,7 +80,7 @@
7380
`VariantLists`:
7481

7582
```properties
76-
# A Term with a VariantList as a value.
83+
# BEFORE A Term with a VariantList as a value.
7784
-thing = {
7885
*[definite] the thing
7986
[indefinite] a thing
@@ -83,7 +90,7 @@
8390
```
8491

8592
```properties
86-
# A parametrized Term with a Pattern as a value.
93+
# AFTER A parameterized Term with a Pattern as a value.
8794
-thing = { $article ->
8895
*[definite] the thing
8996
[indefinite] a thing
@@ -96,7 +103,7 @@
96103
hierarchies of term values:
97104

98105
```properties
99-
# A parametrized Term with nested Patterns.
106+
# AFTER A parameterized Term with nested Patterns.
100107
-thing = { $article ->
101108
*[definite] { $first-letter ->
102109
*[lower] the thing

spec/fluent.ebnf

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Entry ::= (Message line_end)
1212
| (Term line_end)
1313
| CommentLine
1414
Message ::= Identifier blank_inline? "=" blank_inline? ((Pattern Attribute*) | (Attribute+))
15-
Term ::= "-" Identifier blank_inline? "=" blank_inline? Value Attribute*
15+
Term ::= "-" Identifier blank_inline? "=" blank_inline? Pattern Attribute*
1616

1717
/* Adjacent comment lines of the same comment type are joined together during
1818
* the AST construction. */
@@ -31,12 +31,8 @@ junk_line ::= /[^\n]*/ ("\u000A" | EOF)
3131
/* Attributes of Messages and Terms. */
3232
Attribute ::= line_end blank? "." Identifier blank_inline? "=" blank_inline? Pattern
3333

34-
/* Value types: Pattern and VariantList (deprecated). */
35-
Value ::= Pattern
36-
| VariantList
34+
/* Patterns are values of Messages, Terms, Attributes and Variants. */
3735
Pattern ::= PatternElement+
38-
/* DEPRECATION NOTICE VariantLists have been deprecated in Syntax 0.8. */
39-
VariantList ::= blank? "{" variant_list blank? "}"
4036

4137
/* TextElement and Placeable can occur inline or as block.
4238
* Text needs to be indented and start with a non-special character.
@@ -58,7 +54,6 @@ InlineExpression ::= StringLiteral
5854
| NumberLiteral
5955
| CallExpression
6056
| AttributeExpression
61-
| VariantExpression
6257
| MessageReference
6358
| TermReference
6459
| VariableReference
@@ -82,8 +77,6 @@ Argument ::= NamedArgument
8277
| InlineExpression
8378
NamedArgument ::= Identifier blank? ":" blank? (StringLiteral | NumberLiteral)
8479
AttributeExpression ::= (MessageReference | TermReference) "." Identifier
85-
/* DEPRECATION NOTICE VariantExpressions have been deprecated in Syntax 0.8. */
86-
VariantExpression ::= TermReference VariantKey
8780

8881
/* Block Expressions */
8982
SelectExpression ::= InlineExpression blank? "->" blank_inline? variant_list

syntax/abstract.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ export function list_into(Type) {
9898

9999
return always(new Type(selector, variants));
100100
};
101-
case FTL.VariantList:
102-
return ([variants]) =>
103-
always(new Type(variants));
104101
default:
105102
return elements =>
106103
always(new Type(...elements));

syntax/ast.mjs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ export class Term extends Entry {
4343
}
4444
}
4545

46-
export class VariantList extends SyntaxNode {
47-
constructor(variants) {
48-
super();
49-
this.type = "VariantList";
50-
this.variants = variants;
51-
}
52-
}
53-
5446
export class Pattern extends SyntaxNode {
5547
constructor(elements) {
5648
super();
@@ -154,15 +146,6 @@ export class AttributeExpression extends Expression {
154146
}
155147
}
156148

157-
export class VariantExpression extends Expression {
158-
constructor(ref, key) {
159-
super();
160-
this.type = "VariantExpression";
161-
this.ref = ref;
162-
this.key = key;
163-
}
164-
}
165-
166149
export class CallExpression extends Expression {
167150
constructor(callee, positional = [], named = []) {
168151
super();

syntax/grammar.mjs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let Term = defer(() =>
6161
maybe(blank_inline),
6262
string("="),
6363
maybe(blank_inline),
64-
Value.abstract,
64+
Pattern.abstract,
6565
repeat(Attribute).abstract)
6666
.map(keep_abstract)
6767
.chain(list_into(FTL.Term)));
@@ -133,31 +133,15 @@ let Attribute = defer(() =>
133133
.map(keep_abstract)
134134
.chain(list_into(FTL.Attribute)));
135135

136-
/* -------------------------------------------------- */
137-
/* Value types: Pattern and VariantList (deprecated). */
138-
let Value = defer(() =>
139-
either(
140-
Pattern,
141-
VariantList));
142-
136+
/* ---------------------------------------------------------------- */
137+
/* Patterns are values of Messages, Terms, Attributes and Variants. */
143138
let Pattern = defer(() =>
144139
repeat1(
145140
PatternElement)
146141
// Flatten block_text and block_placeable which return lists.
147142
.map(flatten(1))
148143
.chain(list_into(FTL.Pattern)));
149144

150-
/* DEPRECATION NOTICE VariantLists have been deprecated in Syntax 0.8. */
151-
let VariantList = defer(() =>
152-
sequence(
153-
maybe(blank),
154-
string("{"),
155-
variant_list.abstract,
156-
maybe(blank),
157-
string("}"))
158-
.map(keep_abstract)
159-
.chain(list_into(FTL.VariantList)));
160-
161145
/* ----------------------------------------------------------------- */
162146
/* TextElement and Placeable can occur inline or as block.
163147
* Text needs to be indented and start with a non-special character.
@@ -214,7 +198,6 @@ let InlineExpression = defer(() =>
214198
NumberLiteral,
215199
CallExpression,
216200
AttributeExpression,
217-
VariantExpression,
218201
MessageReference,
219202
TermReference,
220203
VariableReference,
@@ -322,14 +305,6 @@ let AttributeExpression = defer(() =>
322305
.map(keep_abstract)
323306
.chain(list_into(FTL.AttributeExpression)));
324307

325-
/* DEPRECATION NOTICE VariantExpressions have been deprecated in Syntax 0.8. */
326-
let VariantExpression = defer(() =>
327-
sequence(
328-
TermReference.abstract,
329-
VariantKey.abstract)
330-
.map(keep_abstract)
331-
.chain(list_into(FTL.VariantExpression)));
332-
333308
/* ----------------- */
334309
/* Block Expressions */
335310
let SelectExpression = defer(() =>

test/fixtures/member_expressions.ftl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
## Member expressions in placeables.
22

3+
# OK Message attributes may be interpolated in values.
34
message-attribute-expression-placeable = {msg.attr}
4-
term-variant-expression-placeable = {-term[case]}
55
6-
# ERROR Message values cannot be VariantLists
7-
message-variant-expression-placeable = {msg[case]}
86
# ERROR Term attributes may not be used for interpolation.
97
term-attribute-expression-placeable = {-term.attr}
108
9+
1110
## Member expressions in selectors.
1211

12+
# OK Term attributes may be used as selectors.
1313
term-attribute-expression-selector = {-term.attr ->
1414
*[key] Value
1515
}
16-
17-
# ERROR Message attributes may not be used as selector.
16+
# ERROR Message attributes may not be used as selectors.
1817
message-attribute-expression-selector = {msg.attr ->
1918
*[key] Value
2019
}
21-
# ERROR Term values may not be used as selector.
22-
term-variant-expression-selector = {-term[case] ->
23-
*[key] Value
24-
}
25-
# ERROR Message values cannot be VariantLists
26-
message-variant-expression-selector = {msg[case] ->
27-
*[key] Value
28-
}

test/fixtures/member_expressions.json

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,10 @@
3434
]
3535
},
3636
"attributes": [],
37-
"comment": null
38-
},
39-
{
40-
"type": "Message",
41-
"id": {
42-
"type": "Identifier",
43-
"name": "term-variant-expression-placeable"
44-
},
45-
"value": {
46-
"type": "Pattern",
47-
"elements": [
48-
{
49-
"type": "Placeable",
50-
"expression": {
51-
"type": "VariantExpression",
52-
"ref": {
53-
"type": "TermReference",
54-
"id": {
55-
"type": "Identifier",
56-
"name": "term"
57-
}
58-
},
59-
"key": {
60-
"type": "Identifier",
61-
"name": "case"
62-
}
63-
}
64-
}
65-
]
66-
},
67-
"attributes": [],
68-
"comment": null
69-
},
70-
{
71-
"type": "Comment",
72-
"content": "ERROR Message values cannot be VariantLists"
73-
},
74-
{
75-
"type": "Junk",
76-
"annotations": [],
77-
"content": "message-variant-expression-placeable = {msg[case]}\n"
37+
"comment": {
38+
"type": "Comment",
39+
"content": "OK Message attributes may be interpolated in values."
40+
}
7841
},
7942
{
8043
"type": "Comment",
@@ -83,7 +46,7 @@
8346
{
8447
"type": "Junk",
8548
"annotations": [],
86-
"content": "term-attribute-expression-placeable = {-term.attr}\n\n"
49+
"content": "term-attribute-expression-placeable = {-term.attr}\n\n\n"
8750
},
8851
{
8952
"type": "GroupComment",
@@ -140,34 +103,19 @@
140103
]
141104
},
142105
"attributes": [],
143-
"comment": null
106+
"comment": {
107+
"type": "Comment",
108+
"content": "OK Term attributes may be used as selectors."
109+
}
144110
},
145111
{
146112
"type": "Comment",
147-
"content": "ERROR Message attributes may not be used as selector."
113+
"content": "ERROR Message attributes may not be used as selectors."
148114
},
149115
{
150116
"type": "Junk",
151117
"annotations": [],
152118
"content": "message-attribute-expression-selector = {msg.attr ->\n *[key] Value\n}\n"
153-
},
154-
{
155-
"type": "Comment",
156-
"content": "ERROR Term values may not be used as selector."
157-
},
158-
{
159-
"type": "Junk",
160-
"annotations": [],
161-
"content": "term-variant-expression-selector = {-term[case] ->\n *[key] Value\n}\n"
162-
},
163-
{
164-
"type": "Comment",
165-
"content": "ERROR Message values cannot be VariantLists"
166-
},
167-
{
168-
"type": "Junk",
169-
"annotations": [],
170-
"content": "message-variant-expression-selector = {msg[case] ->\n *[key] Value\n}\n"
171119
}
172120
]
173121
}

test/fixtures/obsolete.ftl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### The syntax in this file has been discontinued. It is no longer part of the
2+
### Fluent specification and should not be implemented nor used. We're keeping
3+
### these fixtures around to protect against accidental syntax reuse.
4+
5+
6+
## Variant lists.
7+
8+
message-variant-list =
9+
{
10+
*[key] Value
11+
}
12+
13+
-term-variant-list =
14+
{
15+
*[key] Value
16+
}
17+
18+
19+
## Variant expressions.
20+
21+
message-variant-expression-placeable = {msg[case]}
22+
message-variant-expression-selector = {msg[case] ->
23+
*[key] Value
24+
}
25+
26+
term-variant-expression-placeable = {-term[case]}
27+
term-variant-expression-selector = {-term[case] ->
28+
*[key] Value
29+
}

test/fixtures/obsolete.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"type": "Resource",
3+
"body": [
4+
{
5+
"type": "ResourceComment",
6+
"content": "The syntax in this file has been discontinued. It is no longer part of the\nFluent specification and should not be implemented nor used. We're keeping\nthese fixtures around to protect against accidental syntax reuse."
7+
},
8+
{
9+
"type": "GroupComment",
10+
"content": "Variant lists."
11+
},
12+
{
13+
"type": "Junk",
14+
"annotations": [],
15+
"content": "message-variant-list =\n {\n *[key] Value\n }\n\n"
16+
},
17+
{
18+
"type": "Junk",
19+
"annotations": [],
20+
"content": "-term-variant-list =\n {\n *[key] Value\n }\n\n\n"
21+
},
22+
{
23+
"type": "GroupComment",
24+
"content": "Variant expressions."
25+
},
26+
{
27+
"type": "Junk",
28+
"annotations": [],
29+
"content": "message-variant-expression-placeable = {msg[case]}\n"
30+
},
31+
{
32+
"type": "Junk",
33+
"annotations": [],
34+
"content": "message-variant-expression-selector = {msg[case] ->\n *[key] Value\n}\n\n"
35+
},
36+
{
37+
"type": "Junk",
38+
"annotations": [],
39+
"content": "term-variant-expression-placeable = {-term[case]}\n"
40+
},
41+
{
42+
"type": "Junk",
43+
"annotations": [],
44+
"content": "term-variant-expression-selector = {-term[case] ->\n *[key] Value\n}\n"
45+
}
46+
]
47+
}

0 commit comments

Comments
 (0)