From 082e0f3de763bd3883e556390813a89fd139c44e Mon Sep 17 00:00:00 2001 From: starwarswii Date: Thu, 17 Sep 2020 22:35:16 -0400 Subject: [PATCH] fixed lark.lark requiring newline at the end of grammars lark.lark didn't parse grammars that didn't have a trailing newline in the file, but lark itself has no problem parsing those grammars this change makes lark.lark more accurate in reflecting what grammars are parsed by lark. --- examples/lark.lark | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/lark.lark b/examples/lark.lark index 8c4fa75..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)*