diff --git a/examples/lark.lark b/examples/lark.lark index fef6b07..474b819 100644 --- a/examples/lark.lark +++ b/examples/lark.lark @@ -1,20 +1,20 @@ -start: (_item | _NL)* +start: (_item? _NL)* _item? _item: rule | token | statement -rule: RULE rule_params priority? ":" expansions _NL -token: TOKEN token_params priority? ":" expansions _NL +rule: RULE rule_params priority? ":" expansions +token: TOKEN token_params priority? ":" expansions rule_params: ["{" RULE ("," RULE)* "}"] token_params: ["{" TOKEN ("," TOKEN)* "}"] priority: "." NUMBER -statement: "%ignore" expansions _NL -> ignore - | "%import" import_path ["->" name] _NL -> import - | "%import" import_path name_list _NL -> multi_import +statement: "%ignore" expansions -> ignore + | "%import" import_path ["->" name] -> import + | "%import" import_path name_list -> multi_import | "%declare" name+ -> declare !import_path: "."? name ("." name)* @@ -49,7 +49,7 @@ REGEXP: /\/(?!\/)(\\\/|\\\\|[^\/\n])*?\/[imslux]*/ _NL: /(\r?\n)+\s*/ %import common.ESCAPED_STRING -> _STRING -%import common.INT -> NUMBER +%import common.SIGNED_INT -> NUMBER %import common.WS_INLINE COMMENT: /\s*/ "//" /[^\n]/* diff --git a/examples/lark_grammar.py b/examples/lark_grammar.py index b424e87..f2185ee 100644 --- a/examples/lark_grammar.py +++ b/examples/lark_grammar.py @@ -19,6 +19,8 @@ grammar_files = [ examples_path / 'relative-imports/multiples.lark', examples_path / 'relative-imports/multiple2.lark', examples_path / 'relative-imports/multiple3.lark', + examples_path / 'tests/no_newline_at_end.lark', + examples_path / 'tests/negative_priority.lark', lark_path / 'grammars/common.lark', ] diff --git a/examples/tests/negative_priority.lark b/examples/tests/negative_priority.lark new file mode 100644 index 0000000..e71f5e3 --- /dev/null +++ b/examples/tests/negative_priority.lark @@ -0,0 +1,2 @@ +start: r +r.-1: "a" diff --git a/examples/tests/no_newline_at_end.lark b/examples/tests/no_newline_at_end.lark new file mode 100644 index 0000000..8ab64d7 --- /dev/null +++ b/examples/tests/no_newline_at_end.lark @@ -0,0 +1 @@ +start: "a" \ No newline at end of file