|
@@ -167,9 +167,8 @@ class TreeBuilderAtoms: |
|
|
print('}') |
|
|
print('}') |
|
|
print('parse_tree_builder = ParseTreeBuilder(RULES.values(), Tree)') |
|
|
print('parse_tree_builder = ParseTreeBuilder(RULES.values(), Tree)') |
|
|
|
|
|
|
|
|
def main(fn, start): |
|
|
|
|
|
with codecs.open(fn, encoding='utf8') as f: |
|
|
|
|
|
lark_inst = Lark(f, parser="lalr", start=start) |
|
|
|
|
|
|
|
|
def main(fobj, start): |
|
|
|
|
|
lark_inst = Lark(fobj, parser="lalr", start=start) |
|
|
|
|
|
|
|
|
lexer_atoms = LexerAtoms(lark_inst.parser.lexer) |
|
|
lexer_atoms = LexerAtoms(lark_inst.parser.lexer) |
|
|
parser_atoms = ParserAtoms(lark_inst.parser.parser) |
|
|
parser_atoms = ParserAtoms(lark_inst.parser.parser) |
|
@@ -178,9 +177,12 @@ def main(fn, start): |
|
|
print('# The file was automatically 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: |
|
|
for pyfile in EXTRACT_STANDALONE_FILES: |
|
|
print (extract_sections(open(os.path.join(__larkdir__, pyfile)))['standalone']) |
|
|
|
|
|
|
|
|
with open(os.path.join(__larkdir__, pyfile)) as f: |
|
|
|
|
|
print (extract_sections(f)['standalone']) |
|
|
|
|
|
|
|
|
|
|
|
with open(os.path.join(__larkdir__, 'grammar.py')) as grammar_py: |
|
|
|
|
|
print(grammar_py.read()) |
|
|
|
|
|
|
|
|
print(open(os.path.join(__larkdir__, 'grammar.py')).read()) |
|
|
|
|
|
print('Shift = 0') |
|
|
print('Shift = 0') |
|
|
print('Reduce = 1') |
|
|
print('Reduce = 1') |
|
|
lexer_atoms.print_python() |
|
|
lexer_atoms.print_python() |
|
@@ -200,4 +202,5 @@ if __name__ == '__main__': |
|
|
else: |
|
|
else: |
|
|
assert False, sys.argv |
|
|
assert False, sys.argv |
|
|
|
|
|
|
|
|
main(fn, start) |
|
|
|
|
|
|
|
|
with codecs.open(fn, encoding='utf8') as f: |
|
|
|
|
|
main(f, start) |