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.

32 lines
824 B

  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. parser = lark.Lark.open('lark.lark', rel_to=__file__, parser="lalr")
  9. examples_path = Path(__file__).parent
  10. lark_path = Path(lark.__file__).parent
  11. grammar_files = [
  12. examples_path / 'lark.lark',
  13. examples_path / 'advanced/python2.lark',
  14. examples_path / 'advanced/python3.lark',
  15. examples_path / 'relative-imports/multiples.lark',
  16. examples_path / 'relative-imports/multiple2.lark',
  17. examples_path / 'relative-imports/multiple3.lark',
  18. lark_path / 'grammars/common.lark',
  19. ]
  20. def test():
  21. for grammar_file in grammar_files:
  22. tree = parser.parse(open(grammar_file).read())
  23. print("All grammars parsed successfully")
  24. if __name__ == '__main__':
  25. test()