-
-
Notifications
You must be signed in to change notification settings - Fork 163
Tips on Using pgen2
andychu edited this page Aug 30, 2019
·
1 revision
Back: Implementing the Oil Expression Language
pgen2 is the LL parser generator borrowed from Python, used for recognizing the Oil expression language (which is based on Python). Caveat: it's a bit hard to use!!!
Tips:
- Print out the parse tree with
print_parse_tree
infrontend/parse_lib.py
. The structured of the parse tree depends on the exact structure of the grammar's rules. - In
oil_lang/expr_to_ast.py
, make sure you copy the relevant productions into comments. That will make it easier to write the "transformer". - See
opy/compiler2/transformer.py
for "tips" on transforming rules to AST nodes. However, note that we have the "singleton-collapse" rule which OPy doesn't have. Ping me for details if you don't understand this.