Parcourir la source

Moved `lark.lark` into the standard library.

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.2
MegaIng1 il y a 3 ans
Parent
révision
dd3cf90b2d
2 fichiers modifiés avec 8 ajouts et 4 suppressions
  1. +7
    -3
      examples/lark_grammar.py
  2. +1
    -1
      lark/grammars/lark.lark

+ 7
- 3
examples/lark_grammar.py Voir le fichier

@@ -7,13 +7,13 @@ A reference implementation of the Lark grammar (using LALR(1))
import lark
from pathlib import Path

parser = lark.Lark.open('lark.lark', rel_to=__file__, parser="lalr")

examples_path = Path(__file__).parent
lark_path = Path(lark.__file__).parent

parser = lark.Lark.open(lark_path / 'grammars/lark.lark', rel_to=__file__, parser="lalr")


grammar_files = [
examples_path / 'lark.lark',
examples_path / 'advanced/python2.lark',
examples_path / 'advanced/python3.lark',
examples_path / 'relative-imports/multiples.lark',
@@ -21,7 +21,11 @@ grammar_files = [
examples_path / 'relative-imports/multiple3.lark',
examples_path / 'tests/no_newline_at_end.lark',
examples_path / 'tests/negative_priority.lark',
examples_path / 'standalone/json.lark',
lark_path / 'grammars/common.lark',
lark_path / 'grammars/lark.lark',
lark_path / 'grammars/unicode.lark',
lark_path / 'grammars/python.lark',
]

def test():


examples/lark.lark → lark/grammars/lark.lark Voir le fichier

@@ -45,7 +45,7 @@ OP: /[+*]|[?](?![a-z])/
RULE: /!?[_?]?[a-z][_a-z0-9]*/
TOKEN: /_?[A-Z][_A-Z0-9]*/
STRING: _STRING "i"?
REGEXP: /\/(?!\/)(\\\/|\\\\|[^\/\n])*?\/[imslux]*/
REGEXP: /\/(?!\/)(\\\/|\\\\|[^\/])*?\/[imslux]*/
_NL: /(\r?\n)+\s*/

%import common.ESCAPED_STRING -> _STRING

Chargement…
Annuler
Enregistrer