diff options
-rw-r--r-- | examples/make_diagram.py | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/examples/make_diagram.py b/examples/make_diagram.py index f1de4bf..5508f4e 100644 --- a/examples/make_diagram.py +++ b/examples/make_diagram.py @@ -8,27 +8,28 @@ from pyparsing.diagram import to_railroad, railroad_to_html -def make_diagram(expr): - with open("output.html", "w", encoding="utf-8") as fp: +def make_diagram(expr, output_html="output.html"): + with open(output_html, "w", encoding="utf-8") as fp: railroad = to_railroad(expr) fp.write(railroad_to_html(railroad)) -# Uncomment the related import statement, and pass the imported parser to make_diagram - -# from examples.delta_time import time_expression -# from examples.sexpParser import sexp -# from examples.ebnftest import ebnf_parser -# from examples.jsonParser import jsonObject -# from examples.lucene_grammar import expression -# from examples.invRegex import parser -# from examples.oc import program -# from examples.mozillaCalendarParser import calendars -# from examples.pgn import pgnGrammar -# from examples.idlParse import CORBA_IDL_BNF -# from examples.chemicalFormulas import formula -# from examples.romanNumerals import romanNumeral -# from examples.protobuf_parser import parser -from examples.parsePythonValue import listItem - -make_diagram(listItem) +# Uncomment the related import statement and rerun to construct railroad diagram + +from examples.delta_time import time_expression as imported_expr + +# from examples.sexpParser import sexp as imported_expr +# from examples.ebnftest import ebnf_parser as imported_expr +# from examples.jsonParser import jsonObject as imported_expr +# from examples.lucene_grammar import expression as imported_expr +# from examples.invRegex import parser as imported_expr +# from examples.oc import program as imported_expr +# from examples.mozillaCalendarParser import calendars as imported_expr +# from examples.pgn import pgnGrammar as imported_expr +# from examples.idlParse import CORBA_IDL_BNF as imported_expr +# from examples.chemicalFormulas import formula as imported_expr +# from examples.romanNumerals import romanNumeral as imported_expr +# from examples.protobuf_parser import parser as imported_expr +# from examples.parsePythonValue import listItem as imported_expr + +make_diagram(imported_expr) |