|
|
@@ -3,6 +3,8 @@ |
|
|
|
# |
|
|
|
# Lark Stand-alone Generator Tool |
|
|
|
# ---------------------------------- |
|
|
|
# Generates a stand-alone LALR(1) parser with a standard lexer |
|
|
|
# |
|
|
|
# Git: https://github.com/erezsh/lark |
|
|
|
# Author: Erez Shinan (erezshin@gmail.com) |
|
|
|
# |
|
|
@@ -158,8 +160,7 @@ def main(fn): |
|
|
|
parser_atoms = ParserAtoms(lark_inst.parser.parser) |
|
|
|
tree_builder_atoms = TreeBuilderAtoms(lark_inst) |
|
|
|
|
|
|
|
print('# Generated by Lark v%s' % lark.__version__) |
|
|
|
|
|
|
|
print('# The file was automatically generated by Lark v%s' % lark.__version__) |
|
|
|
|
|
|
|
for pyfile in EXTRACT_STANDALONE_FILES: |
|
|
|
print (extract_sections(open(os.path.join(__larkdir__, pyfile)))['standalone']) |
|
|
@@ -171,12 +172,10 @@ def main(fn): |
|
|
|
tree_builder_atoms.print_python() |
|
|
|
parser_atoms.print_python() |
|
|
|
|
|
|
|
# print('print(parser.parse(lex("1+2")).pretty())') |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if len(sys.argv) < 2: |
|
|
|
print("Generates a stand-alone lalr parser") |
|
|
|
print("Usage: %s <grammar_path>" % sys.argv[0]) |
|
|
|
print("Lark Stand-alone Generator Tool") |
|
|
|
print("Usage: python -m lark.tools.standalone <grammar-file>") |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
fn ,= sys.argv[1:] |
|
|
|