This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB

  1. """
  2. Lark Grammar
  3. ============
  4. A reference implementation of the Lark grammar (using LALR(1))
  5. """
  6. import lark
  7. from pathlib import Path
  8. examples_path = Path(__file__).parent
  9. lark_path = Path(lark.__file__).parent
  10. parser = lark.Lark.open(lark_path / 'grammars/lark.lark', rel_to=__file__, parser="lalr")
  11. grammar_files = [
  12. examples_path / 'advanced/python2.lark',
  13. examples_path / 'relative-imports/multiples.lark',
  14. examples_path / 'relative-imports/multiple2.lark',
  15. examples_path / 'relative-imports/multiple3.lark',
  16. examples_path / 'tests/no_newline_at_end.lark',
  17. examples_path / 'tests/negative_priority.lark',
  18. examples_path / 'standalone/json.lark',
  19. lark_path / 'grammars/common.lark',
  20. lark_path / 'grammars/lark.lark',
  21. lark_path / 'grammars/unicode.lark',
  22. lark_path / 'grammars/python.lark',
  23. ]
  24. def test():
  25. for grammar_file in grammar_files:
  26. tree = parser.parse(open(grammar_file).read())
  27. print("All grammars parsed successfully")
  28. if __name__ == '__main__':
  29. test()