Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 748 Bytes

File metadata and controls

25 lines (19 loc) · 748 Bytes

LR(0) DFA Generator/Renderer

Rendering the DFA requires the Graphviz library: https://pypi.python.org/pypi/graphviz

Users may pass an input grammar as a string with the following format:

N -> prod1 | prod2 | ... Where N is a nonterminal and prod is a production of N.
Unique symbols must be separated by whitespace. Aa != A a
Nullable productions may be represented with λ or the keyword LAMBDA.

E.g.
grammar=\
"""
S -> A | B
A -> a b c
B -> identifier
"""

Output:
alt text

Pass the grammar to an instance of DFA and the automaton will be constructed!
Calling DFA.render() produces a GV file and a file of whichever format the user passes (defaults to SVG).