This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

38 linhas
1.1 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 / 'advanced/python3.lark',
  14. examples_path / 'relative-imports/multiples.lark',
  15. examples_path / 'relative-imports/multiple2.lark',
  16. examples_path / 'relative-imports/multiple3.lark',
  17. examples_path / 'tests/no_newline_at_end.lark',
  18. examples_path / 'tests/negative_priority.lark',
  19. examples_path / 'standalone/json.lark',
  20. lark_path / 'grammars/common.lark',
  21. lark_path / 'grammars/lark.lark',
  22. lark_path / 'grammars/unicode.lark',
  23. lark_path / 'grammars/python.lark',
  24. ]
  25. def test():
  26. for grammar_file in grammar_files:
  27. tree = parser.parse(open(grammar_file).read())
  28. print("All grammars parsed successfully")
  29. if __name__ == '__main__':
  30. test()