Browse Source

Merge pull request #691 from starwarswii/patch-1

updated lark.lark with two small fixes
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.10.0
Erez Shinan 4 years ago
committed by GitHub
parent
commit
84b195d5f0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions
  1. +7
    -7
      examples/lark.lark
  2. +2
    -0
      examples/lark_grammar.py
  3. +2
    -0
      examples/tests/negative_priority.lark
  4. +1
    -0
      examples/tests/no_newline_at_end.lark

+ 7
- 7
examples/lark.lark View File

@@ -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]/*


+ 2
- 0
examples/lark_grammar.py View File

@@ -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',
]



+ 2
- 0
examples/tests/negative_priority.lark View File

@@ -0,0 +1,2 @@
start: r
r.-1: "a"

+ 1
- 0
examples/tests/no_newline_at_end.lark View File

@@ -0,0 +1 @@
start: "a"

Loading…
Cancel
Save