Instantly share code, notes, and snippets.

Embed
What would you like to do?
DFA for parsing McBopomofo data.txt (Graphviz)
# Parser DFA for McBopomofo's data.txt
#
# Regular expression equivalent:
#
# (\n*\w\w*\s\w\w*\s\w\w*)*$
#
digraph finite_state_machine {
rankdir = LR;
size = "10";
node [shape = doublecircle]; End;
node [shape = circle];
Start -> End [ label = "EOF"];
Start -> Error [ label = "\\s" ];
Start -> Start [ label = "\\n" ];
Start -> 1 [ label = "\\w" ];
1 -> Error [ label = "\\n, EOF" ];
1 -> 2 [ label = "\\s" ];
1 -> 1 [ label = "\\w" ];
2 -> Error [ label = "\\n, \\s, EOF" ];
2 -> 3 [ label = "\\w" ];
3 -> Error [ label = "\\n, EOF "];
3 -> 4 [ label = "\\s" ];
3 -> 3 [ label = "\\w" ];
4 -> Error [ label = "\\n, \\s, EOF" ];
4 -> 5 [ label = "\\w" ];
5 -> Error [ label = "\\s, EOF" ];
5 -> Start [ label = "\\n" ];
5 -> 5 [ label = "\\w" ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment