From 9a7fdd29c263a1fa7778c7ec1cbc812397d88571 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 29 Jul 2020 09:53:07 -0700 Subject: [PATCH] Add test for non-terminal extras that share non-extra rules --- .../corpus.txt | 23 +++++++ .../grammar.json | 68 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 test/fixtures/test_grammars/extra_non_terminals_with_shared_rules/corpus.txt create mode 100644 test/fixtures/test_grammars/extra_non_terminals_with_shared_rules/grammar.json diff --git a/test/fixtures/test_grammars/extra_non_terminals_with_shared_rules/corpus.txt b/test/fixtures/test_grammars/extra_non_terminals_with_shared_rules/corpus.txt new file mode 100644 index 00000000..a22d8b8d --- /dev/null +++ b/test/fixtures/test_grammars/extra_non_terminals_with_shared_rules/corpus.txt @@ -0,0 +1,23 @@ +===== +Extras +===== + +; +%; +%foo:; +; +bar: baz:; +; + +--- + +(program + (statement) + (macro_statement (statement)) + (macro_statement (statement + (label_declaration (identifier)))) + (statement) + (statement + (label_declaration (identifier)) + (label_declaration (identifier))) + (statement)) diff --git a/test/fixtures/test_grammars/extra_non_terminals_with_shared_rules/grammar.json b/test/fixtures/test_grammars/extra_non_terminals_with_shared_rules/grammar.json new file mode 100644 index 00000000..a7f51b8e --- /dev/null +++ b/test/fixtures/test_grammars/extra_non_terminals_with_shared_rules/grammar.json @@ -0,0 +1,68 @@ +{ + "name": "extra_non_terminals_with_shared_rules", + + "extras": [ + { "type": "PATTERN", "value": "\\s+" }, + { "type": "SYMBOL", "name": "macro_statement" } + ], + + "rules": { + "program": { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "statement" + } + }, + "statement": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "label_declaration" + } + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "macro_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "%" + }, + { + "type": "SYMBOL", + "name": "statement" + } + ] + }, + "label_declaration": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "identifier" + }, + { + "type": "STRING", + "value": ":" + } + ] + }, + "identifier": { + "type": "PATTERN", + "value": "[a-zA-Z]+" + } + }, + "conflicts": [], + "externals": [], + "inline": [], + "supertypes": [] +}