diff options
Diffstat (limited to 'examples/make_diagram.py')
-rw-r--r-- | examples/make_diagram.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/make_diagram.py b/examples/make_diagram.py new file mode 100644 index 0000000..f1de4bf --- /dev/null +++ b/examples/make_diagram.py @@ -0,0 +1,34 @@ +# +# make_diagram.py +# +# Sample railroad diagrams of selected pyparsing examples. +# +# Copyright 2020, Paul McGuire + +from pyparsing.diagram import to_railroad, railroad_to_html + + +def make_diagram(expr): + 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) |