Browse Source

Corrections to the standalone tool

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.2
Erez Shinan 6 years ago
parent
commit
a409f2835c
1 changed files with 5 additions and 6 deletions
  1. +5
    -6
      lark/tools/standalone.py

+ 5
- 6
lark/tools/standalone.py View File

@@ -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:]


Loading…
Cancel
Save