diff --git a/src/bnf.backup.json b/src/bnf.backup.json deleted file mode 100644 index e14a033..0000000 --- a/src/bnf.backup.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "literals": [ - { "name": "identifier", "pattern": "[a-zA-Z_]\\w*" }, - { "name": "string", "pattern": "\"(?:\\\\.|[^\"\\\\])*\"|'(?:\\\\.|[^'\\\\])*'" }, - { "name": "equal", "pattern": "=" }, - { "name": "pipe", "pattern": "\\|" }, - { "name": "comma", "pattern": "," }, - { "name": "semicolon", "pattern": ";" }, - { "name": "left_paren", "pattern": "\\(" }, - { "name": "right_paren", "pattern": "\\)" }, - { "name": "left_brace", "pattern": "\\{" }, - { "name": "right_brace", "pattern": "\\}" }, - { "name": "left_bracket", "pattern": "\\[" }, - { "name": "right_bracket", "pattern": "\\]" }, - { "name": "whitespace", "pattern": "[ \\t]+" }, - { "name": "line_terminator", "pattern": "[\\n;]+" }, - { "name": "directive", "pattern": "##\\w+ [^\\n]*" }, - { "name": "comment", "pattern": "#[^\\n]*" } - ], - "ignoreLiterals": ["whitespace", "comment"], - "definitions": [ - { "name": "rule", "type": "sequence", "pattern": ["identifier", "equal", "expression", "semicolon"] }, - { "name": "expression_continue", "type": "sequence", "pattern": ["pipe", "term"] }, - { "name": "expression", "type": "sequence", "pattern": ["term", { "kind": "expression_continue", "type": "repeated" }] }, - { "name": "term_continue", "type": "sequence", "pattern": ["comma", "factor"] }, - { "name": "term", "type": "sequence", "pattern": ["factor", { "kind": "term_continue", "type": "repeated" }] }, - { "name": "factor", "type": "oneof", "pattern": ["string", "identifier", "group"] }, - { "name": "group", "type": "oneof", "pattern": ["repetition", "optional", "parenthesized"] }, - { "name": "parenthesized", "type": "sequence", "pattern": ["left_paren", "expression", "right_paren"] }, - { "name": "repetition", "type": "sequence", "pattern": ["left_brace", "expression", "right_brace"] }, - { "name": "optional", "type": "sequence", "pattern": ["left_bracket", "expression", "right_bracket"] }, - { "name": "rule_list_continue", "type": "sequence", "pattern": [{ "kind": "rule", "type": "optional" }, { "kind": "directive", "type": "optional" }, "line_terminator"] }, - { - "name": "rule_list", - "type": "sequence", - "pattern": [ - { "kind": "rule", "type": "optional" }, - { "kind": "directive", "type": "optional" }, - { "kind": "rule_list_continue", "type": "repeated" } - ] - } - ], - "rootNode": "rule_list" -} diff --git a/src/bnf.json b/src/bnf.json new file mode 100644 index 0000000..5c284e2 --- /dev/null +++ b/src/bnf.json @@ -0,0 +1,138 @@ +{ + "definitions": [ + { + "name": "parenthesized", + "type": "sequence", + "pattern": [ + { "kind": "left_param", "type": "required" }, + { "kind": "expression", "type": "required" }, + { "kind": "right_param", "type": "required" } + ] + }, + { + "name": "optional", + "type": "sequence", + "pattern": [ + { "kind": "left_bracket", "type": "required" }, + { "kind": "expression", "type": "required" }, + { "kind": "right_bracket", "type": "required" } + ] + }, + { + "name": "repetition", + "type": "sequence", + "pattern": [ + { "kind": "left_brace", "type": "required" }, + { "kind": "expression", "type": "required" }, + { "kind": "right_brace", "type": "required" } + ] + }, + { + "name": "group", + "type": "oneof", + "pattern": [ + { "kind": "parenthesized", "type": "required" }, + { "kind": "optional", "type": "required" }, + { "kind": "repetition", "type": "required" } + ] + }, + { + "name": "factor", + "type": "oneof", + "pattern": [ + { "kind": "string", "type": "required" }, + { "kind": "identifier", "type": "required" }, + { "kind": "group", "type": "required" } + ] + }, + { + "name": "term#0", + "type": "sequence", + "pattern": [ + { "kind": "pipe", "type": "required" }, + { "kind": "factor", "type": "required" } + ] + }, + { + "name": "term", + "type": "sequence", + "pattern": [ + { "kind": "factor", "type": "required" }, + { "kind": "term#0", "type": "repeated" } + ] + }, + { + "name": "expression#0", + "type": "sequence", + "pattern": [ + { "kind": ",", "type": "required" }, + { "kind": "term", "type": "required" } + ] + }, + { + "name": "expression", + "type": "sequence", + "pattern": [ + { "kind": "term", "type": "required" }, + { "kind": "expression#0", "type": "repeated" } + ] + }, + { + "name": "rule", + "type": "sequence", + "pattern": [ + { "kind": "identifier", "type": "required" }, + { "kind": "=", "type": "required" }, + { "kind": "expression", "type": "required" }, + { "kind": ";", "type": "required" } + ] + }, + { + "name": "rule_list#0", + "type": "oneof", + "pattern": [ + { "kind": "rule", "type": "required" }, + { "kind": "comment", "type": "required" }, + { "kind": "directive", "type": "required" } + ] + }, + { + "name": "rule_list#1", + "type": "oneof", + "pattern": [ + { "kind": "line_terminator", "type": "required" }, + { "kind": "rule", "type": "required" }, + { "kind": "comment", "type": "required" }, + { "kind": "directive", "type": "required" } + ] + }, + { + "name": "rule_list", + "type": "oneof", + "pattern": [ + { "kind": "rule_list#0", "type": "required" }, + { "kind": "rule_list#1", "type": "repeated" } + ] + } + ], + "literals": [ + { "name": "string", "pattern": "\"(?:\\\\.|[^\"\\\\])*\"|'(?:\\\\.|[^'\\\\])*'" }, + { "name": "identifier", "pattern": "[a-zA-Z_]\\w*" }, + { "name": "whitespace", "pattern": "[ \\t]+" }, + { "name": "line_terminator", "pattern": "[\\n;]+" }, + { "name": "comment", "pattern": "#[^\\n]*" }, + { "name": "directive", "pattern": "##\\w+ [^\\n]*" }, + { "name": "pipe", "pattern": "\\|" }, + { "name": "left_param", "pattern": "\\(" }, + { "name": "right_param", "pattern": "\\)" }, + { "name": "left_bracket", "pattern": "\\[" }, + { "name": "right_bracket", "pattern": "\\]" }, + { "name": "left_brace", "pattern": "\\{" }, + { "name": "right_brace", "pattern": "\\}" }, + { "name": ",", "pattern": "," }, + { "name": "=", "pattern": "=" }, + { "name": ";", "pattern": ";" } + ], + "rootNode": "rule_list", + "ignoreLiterals": ["whitespace", "comment"] +}