Skip to content

Commit

Permalink
updated parse_instr in docutis
Browse files Browse the repository at this point in the history
  • Loading branch information
schorrm committed Jun 23, 2020
1 parent edde637 commit 48db755
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions docs/utils/parse_instr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

from lark import Lark
import sys
from pprint import pprint
sys.path.append('../../')

from convert_parse_tree import TreeToDict


if __name__ == "__main__":
with open('grammar/grammar_arm.lark') as f:
with open('../../grammar/grammar_arm.lark') as f:
grammar = f.read()

l = Lark(grammar, parser='earley')
transformer = TreeToDict()

fn = 'stm_ex.arm'
if len(sys.argv) > 1:
Expand All @@ -18,8 +24,9 @@
for line in lines:
print()
print(line.rstrip())
x = l.parse(line)
print(x.pretty())
tree = l.parse(line)
d = transformer.transform(tree)
print(tree.pretty())
print()
print(type(x))
pprint(d)

0 comments on commit 48db755

Please sign in to comment.