From ab9bd58bcb6c7d47726e07324acecb0605f84691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sta=C5=9B=20Ma=C5=82olepszy?= Date: Tue, 6 Nov 2018 11:57:20 +0100 Subject: [PATCH] Remove VariantLists --- spec/CHANGELOG.md | 13 +- spec/fluent.ebnf | 11 +- syntax/abstract.mjs | 3 - syntax/ast.mjs | 17 --- syntax/grammar.mjs | 31 +---- test/fixtures/member_expressions.ftl | 17 +-- test/fixtures/member_expressions.json | 72 ++-------- test/fixtures/obsolete.ftl | 29 ++++ test/fixtures/obsolete.json | 47 +++++++ test/fixtures/select_expressions.ftl | 32 ++--- test/fixtures/select_expressions.json | 44 +++--- test/fixtures/variant_keys.ftl | 28 ++-- test/fixtures/variant_keys.json | 186 +++++++++++++++++--------- test/fixtures/variant_lists.ftl | 55 -------- test/fixtures/variant_lists.json | 180 ------------------------- test/fixtures/variants_indent.ftl | 19 --- test/fixtures/variants_indent.json | 146 -------------------- 17 files changed, 276 insertions(+), 654 deletions(-) create mode 100644 test/fixtures/obsolete.ftl create mode 100644 test/fixtures/obsolete.json delete mode 100644 test/fixtures/variant_lists.ftl delete mode 100644 test/fixtures/variant_lists.json delete mode 100644 test/fixtures/variants_indent.ftl delete mode 100644 test/fixtures/variants_indent.json diff --git a/spec/CHANGELOG.md b/spec/CHANGELOG.md index 85e0e3d..e5c6632 100644 --- a/spec/CHANGELOG.md +++ b/spec/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 0.9.0 (Unreleased) + + - Remove `VariantLists`. (#204) + + The `VariantLists` and the `VariantExpression` syntax and AST nodes were + deprecated in Syntax 0.9 and have now been removed. + ## 0.8.0 (December 13, 2018) - Preserve content-indent in multiline `Patterns`. (#162) @@ -73,7 +80,7 @@ `VariantLists`: ```properties - # A Term with a VariantList as a value. + # BEFORE A Term with a VariantList as a value. -thing = { *[definite] the thing [indefinite] a thing @@ -83,7 +90,7 @@ ``` ```properties - # A parametrized Term with a Pattern as a value. + # AFTER A parameterized Term with a Pattern as a value. -thing = { $article -> *[definite] the thing [indefinite] a thing @@ -96,7 +103,7 @@ hierarchies of term values: ```properties - # A parametrized Term with nested Patterns. + # AFTER A parameterized Term with nested Patterns. -thing = { $article -> *[definite] { $first-letter -> *[lower] the thing diff --git a/spec/fluent.ebnf b/spec/fluent.ebnf index 498c57a..0aab043 100644 --- a/spec/fluent.ebnf +++ b/spec/fluent.ebnf @@ -12,7 +12,7 @@ Entry ::= (Message line_end) | (Term line_end) | CommentLine Message ::= Identifier blank_inline? "=" blank_inline? ((Pattern Attribute*) | (Attribute+)) -Term ::= "-" Identifier blank_inline? "=" blank_inline? Value Attribute* +Term ::= "-" Identifier blank_inline? "=" blank_inline? Pattern Attribute* /* Adjacent comment lines of the same comment type are joined together during * the AST construction. */ @@ -31,12 +31,8 @@ junk_line ::= /[^\n]*/ ("\u000A" | EOF) /* Attributes of Messages and Terms. */ Attribute ::= line_end blank? "." Identifier blank_inline? "=" blank_inline? Pattern -/* Value types: Pattern and VariantList (deprecated). */ -Value ::= Pattern - | VariantList +/* Patterns are values of Messages, Terms, Attributes and Variants. */ Pattern ::= PatternElement+ -/* DEPRECATION NOTICE VariantLists have been deprecated in Syntax 0.8. */ -VariantList ::= blank? "{" variant_list blank? "}" /* TextElement and Placeable can occur inline or as block. * Text needs to be indented and start with a non-special character. @@ -58,7 +54,6 @@ InlineExpression ::= StringLiteral | NumberLiteral | CallExpression | AttributeExpression - | VariantExpression | MessageReference | TermReference | VariableReference @@ -82,8 +77,6 @@ Argument ::= NamedArgument | InlineExpression NamedArgument ::= Identifier blank? ":" blank? (StringLiteral | NumberLiteral) AttributeExpression ::= (MessageReference | TermReference) "." Identifier -/* DEPRECATION NOTICE VariantExpressions have been deprecated in Syntax 0.8. */ -VariantExpression ::= TermReference VariantKey /* Block Expressions */ SelectExpression ::= InlineExpression blank? "->" blank_inline? variant_list diff --git a/syntax/abstract.mjs b/syntax/abstract.mjs index 5ea2d7b..895da4e 100644 --- a/syntax/abstract.mjs +++ b/syntax/abstract.mjs @@ -98,9 +98,6 @@ export function list_into(Type) { return always(new Type(selector, variants)); }; - case FTL.VariantList: - return ([variants]) => - always(new Type(variants)); default: return elements => always(new Type(...elements)); diff --git a/syntax/ast.mjs b/syntax/ast.mjs index bf5ceba..97b7789 100644 --- a/syntax/ast.mjs +++ b/syntax/ast.mjs @@ -43,14 +43,6 @@ export class Term extends Entry { } } -export class VariantList extends SyntaxNode { - constructor(variants) { - super(); - this.type = "VariantList"; - this.variants = variants; - } -} - export class Pattern extends SyntaxNode { constructor(elements) { super(); @@ -154,15 +146,6 @@ export class AttributeExpression extends Expression { } } -export class VariantExpression extends Expression { - constructor(ref, key) { - super(); - this.type = "VariantExpression"; - this.ref = ref; - this.key = key; - } -} - export class CallExpression extends Expression { constructor(callee, positional = [], named = []) { super(); diff --git a/syntax/grammar.mjs b/syntax/grammar.mjs index 1db48d5..83164b4 100644 --- a/syntax/grammar.mjs +++ b/syntax/grammar.mjs @@ -61,7 +61,7 @@ let Term = defer(() => maybe(blank_inline), string("="), maybe(blank_inline), - Value.abstract, + Pattern.abstract, repeat(Attribute).abstract) .map(keep_abstract) .chain(list_into(FTL.Term))); @@ -133,13 +133,8 @@ let Attribute = defer(() => .map(keep_abstract) .chain(list_into(FTL.Attribute))); -/* -------------------------------------------------- */ -/* Value types: Pattern and VariantList (deprecated). */ -let Value = defer(() => - either( - Pattern, - VariantList)); - +/* ---------------------------------------------------------------- */ +/* Patterns are values of Messages, Terms, Attributes and Variants. */ let Pattern = defer(() => repeat1( PatternElement) @@ -147,17 +142,6 @@ let Pattern = defer(() => .map(flatten(1)) .chain(list_into(FTL.Pattern))); -/* DEPRECATION NOTICE VariantLists have been deprecated in Syntax 0.8. */ -let VariantList = defer(() => - sequence( - maybe(blank), - string("{"), - variant_list.abstract, - maybe(blank), - string("}")) - .map(keep_abstract) - .chain(list_into(FTL.VariantList))); - /* ----------------------------------------------------------------- */ /* TextElement and Placeable can occur inline or as block. * Text needs to be indented and start with a non-special character. @@ -214,7 +198,6 @@ let InlineExpression = defer(() => NumberLiteral, CallExpression, AttributeExpression, - VariantExpression, MessageReference, TermReference, VariableReference, @@ -322,14 +305,6 @@ let AttributeExpression = defer(() => .map(keep_abstract) .chain(list_into(FTL.AttributeExpression))); -/* DEPRECATION NOTICE VariantExpressions have been deprecated in Syntax 0.8. */ -let VariantExpression = defer(() => - sequence( - TermReference.abstract, - VariantKey.abstract) - .map(keep_abstract) - .chain(list_into(FTL.VariantExpression))); - /* ----------------- */ /* Block Expressions */ let SelectExpression = defer(() => diff --git a/test/fixtures/member_expressions.ftl b/test/fixtures/member_expressions.ftl index b4a9392..db4c8f4 100644 --- a/test/fixtures/member_expressions.ftl +++ b/test/fixtures/member_expressions.ftl @@ -1,28 +1,19 @@ ## Member expressions in placeables. +# OK Message attributes may be interpolated in values. message-attribute-expression-placeable = {msg.attr} -term-variant-expression-placeable = {-term[case]} -# ERROR Message values cannot be VariantLists -message-variant-expression-placeable = {msg[case]} # ERROR Term attributes may not be used for interpolation. term-attribute-expression-placeable = {-term.attr} + ## Member expressions in selectors. +# OK Term attributes may be used as selectors. term-attribute-expression-selector = {-term.attr -> *[key] Value } - -# ERROR Message attributes may not be used as selector. +# ERROR Message attributes may not be used as selectors. message-attribute-expression-selector = {msg.attr -> *[key] Value } -# ERROR Term values may not be used as selector. -term-variant-expression-selector = {-term[case] -> - *[key] Value -} -# ERROR Message values cannot be VariantLists -message-variant-expression-selector = {msg[case] -> - *[key] Value -} diff --git a/test/fixtures/member_expressions.json b/test/fixtures/member_expressions.json index f6890e5..3f9b7a0 100644 --- a/test/fixtures/member_expressions.json +++ b/test/fixtures/member_expressions.json @@ -34,47 +34,10 @@ ] }, "attributes": [], - "comment": null - }, - { - "type": "Message", - "id": { - "type": "Identifier", - "name": "term-variant-expression-placeable" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "Placeable", - "expression": { - "type": "VariantExpression", - "ref": { - "type": "TermReference", - "id": { - "type": "Identifier", - "name": "term" - } - }, - "key": { - "type": "Identifier", - "name": "case" - } - } - } - ] - }, - "attributes": [], - "comment": null - }, - { - "type": "Comment", - "content": "ERROR Message values cannot be VariantLists" - }, - { - "type": "Junk", - "annotations": [], - "content": "message-variant-expression-placeable = {msg[case]}\n" + "comment": { + "type": "Comment", + "content": "OK Message attributes may be interpolated in values." + } }, { "type": "Comment", @@ -83,7 +46,7 @@ { "type": "Junk", "annotations": [], - "content": "term-attribute-expression-placeable = {-term.attr}\n\n" + "content": "term-attribute-expression-placeable = {-term.attr}\n\n\n" }, { "type": "GroupComment", @@ -140,34 +103,19 @@ ] }, "attributes": [], - "comment": null + "comment": { + "type": "Comment", + "content": "OK Term attributes may be used as selectors." + } }, { "type": "Comment", - "content": "ERROR Message attributes may not be used as selector." + "content": "ERROR Message attributes may not be used as selectors." }, { "type": "Junk", "annotations": [], "content": "message-attribute-expression-selector = {msg.attr ->\n *[key] Value\n}\n" - }, - { - "type": "Comment", - "content": "ERROR Term values may not be used as selector." - }, - { - "type": "Junk", - "annotations": [], - "content": "term-variant-expression-selector = {-term[case] ->\n *[key] Value\n}\n" - }, - { - "type": "Comment", - "content": "ERROR Message values cannot be VariantLists" - }, - { - "type": "Junk", - "annotations": [], - "content": "message-variant-expression-selector = {msg[case] ->\n *[key] Value\n}\n" } ] } diff --git a/test/fixtures/obsolete.ftl b/test/fixtures/obsolete.ftl new file mode 100644 index 0000000..e0869e3 --- /dev/null +++ b/test/fixtures/obsolete.ftl @@ -0,0 +1,29 @@ +### The syntax in this file has been discontinued. It is no longer part of the +### Fluent specification and should not be implemented nor used. We're keeping +### these fixtures around to protect against accidental syntax reuse. + + +## Variant lists. + +message-variant-list = + { + *[key] Value + } + +-term-variant-list = + { + *[key] Value + } + + +## Variant expressions. + +message-variant-expression-placeable = {msg[case]} +message-variant-expression-selector = {msg[case] -> + *[key] Value +} + +term-variant-expression-placeable = {-term[case]} +term-variant-expression-selector = {-term[case] -> + *[key] Value +} diff --git a/test/fixtures/obsolete.json b/test/fixtures/obsolete.json new file mode 100644 index 0000000..8dacf90 --- /dev/null +++ b/test/fixtures/obsolete.json @@ -0,0 +1,47 @@ +{ + "type": "Resource", + "body": [ + { + "type": "ResourceComment", + "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." + }, + { + "type": "GroupComment", + "content": "Variant lists." + }, + { + "type": "Junk", + "annotations": [], + "content": "message-variant-list =\n {\n *[key] Value\n }\n\n" + }, + { + "type": "Junk", + "annotations": [], + "content": "-term-variant-list =\n {\n *[key] Value\n }\n\n\n" + }, + { + "type": "GroupComment", + "content": "Variant expressions." + }, + { + "type": "Junk", + "annotations": [], + "content": "message-variant-expression-placeable = {msg[case]}\n" + }, + { + "type": "Junk", + "annotations": [], + "content": "message-variant-expression-selector = {msg[case] ->\n *[key] Value\n}\n\n" + }, + { + "type": "Junk", + "annotations": [], + "content": "term-variant-expression-placeable = {-term[case]}\n" + }, + { + "type": "Junk", + "annotations": [], + "content": "term-variant-expression-selector = {-term[case] ->\n *[key] Value\n}\n" + } + ] +} diff --git a/test/fixtures/select_expressions.ftl b/test/fixtures/select_expressions.ftl index 7a1fb82..87debb1 100644 --- a/test/fixtures/select_expressions.ftl +++ b/test/fixtures/select_expressions.ftl @@ -9,45 +9,37 @@ valid-selector-term-attribute = *[key] value } -# ERROR +# ERROR Term values are not valid selectors invalid-selector-term-value = { -term -> *[key] value } -# ERROR +# ERROR CallExpressions on Terms are similar to TermReferences invalid-selector-term-variant = - { -term[case] -> - *[key] value - } - -# ERROR -invalid-selector-term-call = { -term(case: "nominative") -> *[key] value } empty-variant = - { 1 -> - *[one] {""} + { $sel -> + *[key] {""} } nested-select = - { 1 -> - *[one] { 2 -> + { $sel -> + *[one] { $sel -> *[two] Value } } -# ERROR VariantLists cannot be Variant values. -nested-variant-list = - { 1 -> - *[one] { - *[two] Value - } +# ERROR Missing selector +missing-selector = + { + *[key] Value } # ERROR Missing line end after variant list missing-line-end = - { 1 -> - *[one] One} + { $sel -> + *[key] Value} diff --git a/test/fixtures/select_expressions.json b/test/fixtures/select_expressions.json index a3dc573..0a6fe95 100644 --- a/test/fixtures/select_expressions.json +++ b/test/fixtures/select_expressions.json @@ -132,7 +132,7 @@ }, { "type": "Comment", - "content": "ERROR" + "content": "ERROR Term values are not valid selectors" }, { "type": "Junk", @@ -141,21 +141,12 @@ }, { "type": "Comment", - "content": "ERROR" + "content": "ERROR CallExpressions on Terms are similar to TermReferences" }, { "type": "Junk", "annotations": [], - "content": "invalid-selector-term-variant =\n { -term[case] ->\n *[key] value\n }\n\n" - }, - { - "type": "Comment", - "content": "ERROR" - }, - { - "type": "Junk", - "annotations": [], - "content": "invalid-selector-term-call =\n { -term(case: \"nominative\") ->\n *[key] value\n }\n\n" + "content": "invalid-selector-term-variant =\n { -term(case: \"nominative\") ->\n *[key] value\n }\n\n" }, { "type": "Message", @@ -171,15 +162,18 @@ "expression": { "type": "SelectExpression", "selector": { - "type": "NumberLiteral", - "value": "1" + "type": "VariableReference", + "id": { + "type": "Identifier", + "name": "sel" + } }, "variants": [ { "type": "Variant", "key": { "type": "Identifier", - "name": "one" + "name": "key" }, "value": { "type": "Pattern", @@ -218,8 +212,11 @@ "expression": { "type": "SelectExpression", "selector": { - "type": "NumberLiteral", - "value": "1" + "type": "VariableReference", + "id": { + "type": "Identifier", + "name": "sel" + } }, "variants": [ { @@ -236,8 +233,11 @@ "expression": { "type": "SelectExpression", "selector": { - "type": "NumberLiteral", - "value": "2" + "type": "VariableReference", + "id": { + "type": "Identifier", + "name": "sel" + } }, "variants": [ { @@ -274,12 +274,12 @@ }, { "type": "Comment", - "content": "ERROR VariantLists cannot be Variant values." + "content": "ERROR Missing selector" }, { "type": "Junk", "annotations": [], - "content": "nested-variant-list =\n { 1 ->\n *[one] {\n *[two] Value\n }\n }\n\n" + "content": "missing-selector =\n {\n *[key] Value\n }\n\n" }, { "type": "Comment", @@ -288,7 +288,7 @@ { "type": "Junk", "annotations": [], - "content": "missing-line-end =\n { 1 ->\n *[one] One}\n" + "content": "missing-line-end =\n { $sel ->\n *[key] Value}\n" } ] } diff --git a/test/fixtures/variant_keys.ftl b/test/fixtures/variant_keys.ftl index 7586d52..52f8ca6 100644 --- a/test/fixtures/variant_keys.ftl +++ b/test/fixtures/variant_keys.ftl @@ -1,37 +1,37 @@ --simple-identifier = - { +simple-identifier = + { $sel -> *[key] value } --identifier-surrounded-by-whitespace = - { +identifier-surrounded-by-whitespace = + { $sel -> *[ key ] value } --int-number = - { +int-number = + { $sel -> *[1] value } --float-number = - { +float-number = + { $sel -> *[3.14] value } # ERROR --invalid-identifier = - { +invalid-identifier = + { $sel -> *[two words] value } # ERROR --invalid-int = - { +invalid-int = + { $sel -> *[1 apple] value } # ERROR --invalid-int = - { +invalid-int = + { $sel -> *[3.14 apples] value } diff --git a/test/fixtures/variant_keys.json b/test/fixtures/variant_keys.json index cf752e4..63b33a4 100644 --- a/test/fixtures/variant_keys.json +++ b/test/fixtures/variant_keys.json @@ -2,30 +2,45 @@ "type": "Resource", "body": [ { - "type": "Term", + "type": "Message", "id": { "type": "Identifier", "name": "simple-identifier" }, "value": { - "type": "VariantList", - "variants": [ + "type": "Pattern", + "elements": [ { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "key" - }, - "value": { - "type": "Pattern", - "elements": [ + "type": "Placeable", + "expression": { + "type": "SelectExpression", + "selector": { + "type": "VariableReference", + "id": { + "type": "Identifier", + "name": "sel" + } + }, + "variants": [ { - "type": "TextElement", - "value": "value" + "type": "Variant", + "key": { + "type": "Identifier", + "name": "key" + }, + "value": { + "type": "Pattern", + "elements": [ + { + "type": "TextElement", + "value": "value" + } + ] + }, + "default": true } ] - }, - "default": true + } } ] }, @@ -33,30 +48,45 @@ "comment": null }, { - "type": "Term", + "type": "Message", "id": { "type": "Identifier", "name": "identifier-surrounded-by-whitespace" }, "value": { - "type": "VariantList", - "variants": [ + "type": "Pattern", + "elements": [ { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "key" - }, - "value": { - "type": "Pattern", - "elements": [ + "type": "Placeable", + "expression": { + "type": "SelectExpression", + "selector": { + "type": "VariableReference", + "id": { + "type": "Identifier", + "name": "sel" + } + }, + "variants": [ { - "type": "TextElement", - "value": "value" + "type": "Variant", + "key": { + "type": "Identifier", + "name": "key" + }, + "value": { + "type": "Pattern", + "elements": [ + { + "type": "TextElement", + "value": "value" + } + ] + }, + "default": true } ] - }, - "default": true + } } ] }, @@ -64,30 +94,45 @@ "comment": null }, { - "type": "Term", + "type": "Message", "id": { "type": "Identifier", "name": "int-number" }, "value": { - "type": "VariantList", - "variants": [ + "type": "Pattern", + "elements": [ { - "type": "Variant", - "key": { - "type": "NumberLiteral", - "value": "1" - }, - "value": { - "type": "Pattern", - "elements": [ + "type": "Placeable", + "expression": { + "type": "SelectExpression", + "selector": { + "type": "VariableReference", + "id": { + "type": "Identifier", + "name": "sel" + } + }, + "variants": [ { - "type": "TextElement", - "value": "value" + "type": "Variant", + "key": { + "type": "NumberLiteral", + "value": "1" + }, + "value": { + "type": "Pattern", + "elements": [ + { + "type": "TextElement", + "value": "value" + } + ] + }, + "default": true } ] - }, - "default": true + } } ] }, @@ -95,30 +140,45 @@ "comment": null }, { - "type": "Term", + "type": "Message", "id": { "type": "Identifier", "name": "float-number" }, "value": { - "type": "VariantList", - "variants": [ + "type": "Pattern", + "elements": [ { - "type": "Variant", - "key": { - "type": "NumberLiteral", - "value": "3.14" - }, - "value": { - "type": "Pattern", - "elements": [ + "type": "Placeable", + "expression": { + "type": "SelectExpression", + "selector": { + "type": "VariableReference", + "id": { + "type": "Identifier", + "name": "sel" + } + }, + "variants": [ { - "type": "TextElement", - "value": "value" + "type": "Variant", + "key": { + "type": "NumberLiteral", + "value": "3.14" + }, + "value": { + "type": "Pattern", + "elements": [ + { + "type": "TextElement", + "value": "value" + } + ] + }, + "default": true } ] - }, - "default": true + } } ] }, @@ -132,7 +192,7 @@ { "type": "Junk", "annotations": [], - "content": "-invalid-identifier =\n {\n *[two words] value\n }\n\n" + "content": "invalid-identifier =\n { $sel ->\n *[two words] value\n }\n\n" }, { "type": "Comment", @@ -141,7 +201,7 @@ { "type": "Junk", "annotations": [], - "content": "-invalid-int =\n {\n *[1 apple] value\n }\n\n" + "content": "invalid-int =\n { $sel ->\n *[1 apple] value\n }\n\n" }, { "type": "Comment", @@ -150,7 +210,7 @@ { "type": "Junk", "annotations": [], - "content": "-invalid-int =\n {\n *[3.14 apples] value\n }\n" + "content": "invalid-int =\n { $sel ->\n *[3.14 apples] value\n }\n" } ] } diff --git a/test/fixtures/variant_lists.ftl b/test/fixtures/variant_lists.ftl deleted file mode 100644 index e5c61dd..0000000 --- a/test/fixtures/variant_lists.ftl +++ /dev/null @@ -1,55 +0,0 @@ --variant-list-in-term = - { - *[key] Value - } - -# ERROR Attributes of Terms must be Patterns. --variant-list-in-term-attr = Value - .attr = - { - *[key] Value - } - -# ERROR Message values must be Patterns. -variant-list-in-message = - { - *[key] Value - } - -# ERROR Attributes of Messages must be Patterns. -variant-list-in-message-attr = Value - .attr = - { - *[key] Value - } - -# ERROR VariantLists cannot be Variant values. --nested-variant-list-in-term = - { - *[one] { - *[two] Value - } - } - --nested-select = - { - *[one] { 2 -> - *[two] Value - } - } - -# ERROR VariantLists cannot be Variant values. -nested-select-then-variant-list = - { - *[one] { 2 -> - *[two] { - *[three] Value - } - } - } - -# ERROR VariantLists are value types and may not appear in Placeables -variant-list-in-placeable = - A prefix here { - *[key] Value - } and a postfix here make this a Pattern. diff --git a/test/fixtures/variant_lists.json b/test/fixtures/variant_lists.json deleted file mode 100644 index 83f1666..0000000 --- a/test/fixtures/variant_lists.json +++ /dev/null @@ -1,180 +0,0 @@ -{ - "type": "Resource", - "body": [ - { - "type": "Term", - "id": { - "type": "Identifier", - "name": "variant-list-in-term" - }, - "value": { - "type": "VariantList", - "variants": [ - { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "key" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "TextElement", - "value": "Value" - } - ] - }, - "default": true - } - ] - }, - "attributes": [], - "comment": null - }, - { - "type": "Term", - "id": { - "type": "Identifier", - "name": "variant-list-in-term-attr" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "TextElement", - "value": "Value" - } - ] - }, - "attributes": [], - "comment": { - "type": "Comment", - "content": "ERROR Attributes of Terms must be Patterns." - } - }, - { - "type": "Junk", - "annotations": [], - "content": " .attr =\n {\n *[key] Value\n }\n\n" - }, - { - "type": "Comment", - "content": "ERROR Message values must be Patterns." - }, - { - "type": "Junk", - "annotations": [], - "content": "variant-list-in-message =\n {\n *[key] Value\n }\n\n" - }, - { - "type": "Message", - "id": { - "type": "Identifier", - "name": "variant-list-in-message-attr" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "TextElement", - "value": "Value" - } - ] - }, - "attributes": [], - "comment": { - "type": "Comment", - "content": "ERROR Attributes of Messages must be Patterns." - } - }, - { - "type": "Junk", - "annotations": [], - "content": " .attr =\n {\n *[key] Value\n }\n\n" - }, - { - "type": "Comment", - "content": "ERROR VariantLists cannot be Variant values." - }, - { - "type": "Junk", - "annotations": [], - "content": "-nested-variant-list-in-term =\n {\n *[one] {\n *[two] Value\n }\n }\n\n" - }, - { - "type": "Term", - "id": { - "type": "Identifier", - "name": "nested-select" - }, - "value": { - "type": "VariantList", - "variants": [ - { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "one" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "Placeable", - "expression": { - "type": "SelectExpression", - "selector": { - "type": "NumberLiteral", - "value": "2" - }, - "variants": [ - { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "two" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "TextElement", - "value": "Value" - } - ] - }, - "default": true - } - ] - } - } - ] - }, - "default": true - } - ] - }, - "attributes": [], - "comment": null - }, - { - "type": "Comment", - "content": "ERROR VariantLists cannot be Variant values." - }, - { - "type": "Junk", - "annotations": [], - "content": "nested-select-then-variant-list =\n {\n *[one] { 2 ->\n *[two] {\n *[three] Value\n }\n }\n }\n\n" - }, - { - "type": "Comment", - "content": "ERROR VariantLists are value types and may not appear in Placeables" - }, - { - "type": "Junk", - "annotations": [], - "content": "variant-list-in-placeable =\n A prefix here {\n *[key] Value\n } and a postfix here make this a Pattern.\n" - } - ] -} diff --git a/test/fixtures/variants_indent.ftl b/test/fixtures/variants_indent.ftl deleted file mode 100644 index 38f5a62..0000000 --- a/test/fixtures/variants_indent.ftl +++ /dev/null @@ -1,19 +0,0 @@ --variants-1tbs = { - *[key] Value -} - --variants-allman = -{ - *[key] Value -} - --variants-gnu = - { - *[key] Value - } - --variants-no-indent = -{ -*[key] Value -[other] Other -} diff --git a/test/fixtures/variants_indent.json b/test/fixtures/variants_indent.json deleted file mode 100644 index 7b987d4..0000000 --- a/test/fixtures/variants_indent.json +++ /dev/null @@ -1,146 +0,0 @@ -{ - "type": "Resource", - "body": [ - { - "type": "Term", - "id": { - "type": "Identifier", - "name": "variants-1tbs" - }, - "value": { - "type": "VariantList", - "variants": [ - { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "key" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "TextElement", - "value": "Value" - } - ] - }, - "default": true - } - ] - }, - "attributes": [], - "comment": null - }, - { - "type": "Term", - "id": { - "type": "Identifier", - "name": "variants-allman" - }, - "value": { - "type": "VariantList", - "variants": [ - { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "key" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "TextElement", - "value": "Value" - } - ] - }, - "default": true - } - ] - }, - "attributes": [], - "comment": null - }, - { - "type": "Term", - "id": { - "type": "Identifier", - "name": "variants-gnu" - }, - "value": { - "type": "VariantList", - "variants": [ - { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "key" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "TextElement", - "value": "Value" - } - ] - }, - "default": true - } - ] - }, - "attributes": [], - "comment": null - }, - { - "type": "Term", - "id": { - "type": "Identifier", - "name": "variants-no-indent" - }, - "value": { - "type": "VariantList", - "variants": [ - { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "key" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "TextElement", - "value": "Value" - } - ] - }, - "default": true - }, - { - "type": "Variant", - "key": { - "type": "Identifier", - "name": "other" - }, - "value": { - "type": "Pattern", - "elements": [ - { - "type": "TextElement", - "value": "Other" - } - ] - }, - "default": false - } - ] - }, - "attributes": [], - "comment": null - } - ] -}