From 964d0a43b5c19bd441f72e0425c6dde4753e785b Mon Sep 17 00:00:00 2001 From: Niles Rogoff Date: Wed, 22 Mar 2017 09:49:56 -0400 Subject: [PATCH] add graphs --- (1+0)*1.svg | 147 +++++++++++++++++++ ab(c1+2d(e*f)d)*e.svg | 330 ++++++++++++++++++++++++++++++++++++++++++ nfa.py | 4 +- 3 files changed, 479 insertions(+), 2 deletions(-) create mode 100644 (1+0)*1.svg create mode 100644 ab(c1+2d(e*f)d)*e.svg diff --git a/(1+0)*1.svg b/(1+0)*1.svg new file mode 100644 index 0000000..8a6541d --- /dev/null +++ b/(1+0)*1.svg @@ -0,0 +1,147 @@ + + + + + + +test + + +652 + +652 + + +652->652 + + +start + + +901 + +901 + + +652->901 + + +epsilon + + +352 + +352 + + +652->352 + + +epsilon + + +232 + +232 + + +901->232 + + +epsilon + + +562 + +562 + + +352->562 + + +epsilon + + +311 + +311 + + +352->311 + + +epsilon + + +41 + +41 + + +562->41 + + +1 + + +827 + +827 + + +41->827 + + +epsilon + + +745 + +745 + + +745->745 + + +terminal + + +827->652 + + +epsilon + + +827->901 + + +epsilon + + +232->745 + + +1 + + +502 + +502 + + +311->502 + + +0 + + +502->827 + + +epsilon + + + diff --git a/ab(c1+2d(e*f)d)*e.svg b/ab(c1+2d(e*f)d)*e.svg new file mode 100644 index 0000000..26d86aa --- /dev/null +++ b/ab(c1+2d(e*f)d)*e.svg @@ -0,0 +1,330 @@ + + + + + + +test + + +842 + +842 + + +842->842 + + +terminal + + +820 + +820 + + +842->820 + + +epsilon + + +353 + +353 + + +842->353 + + +epsilon + + +565 + +565 + + +686 + +686 + + +565->686 + + +b + + +521 + +521 + + +686->521 + + +epsilon + + +521->842 + + +epsilon + + +412 + +412 + + +521->412 + + +epsilon + + +119 + +119 + + +820->119 + + +c + + +194 + +194 + + +119->194 + + +epsilon + + +261 + +261 + + +412->261 + + +epsilon + + +876 + +876 + + +353->876 + + +2 + + +993 + +993 + + +876->993 + + +epsilon + + +777 + +777 + + +194->777 + + +1 + + +804 + +804 + + +993->804 + + +d + + +208 + +208 + + +804->208 + + +epsilon + + +512 + +512 + + +208->512 + + +epsilon + + +320 + +320 + + +208->320 + + +epsilon + + +547 + +547 + + +547->521 + + +epsilon + + +547->412 + + +epsilon + + +777->547 + + +epsilon + + +462 + +462 + + +512->462 + + +e + + +462->208 + + +epsilon + + +462->320 + + +epsilon + + +261->842 + + +e + + +581 + +581 + + +320->581 + + +epsilon + + +532 + +532 + + +581->532 + + +f + + +165 + +165 + + +532->165 + + +epsilon + + +645 + +645 + + +165->645 + + +d + + +645->547 + + +epsilon + + +848 + +848 + + +848->848 + + +start + + +232 + +232 + + +848->232 + + +a + + +232->565 + + +epsilon + + + diff --git a/nfa.py b/nfa.py index d477303..2720b1d 100644 --- a/nfa.py +++ b/nfa.py @@ -67,7 +67,7 @@ def either(a, b): new_start.moves['ε'].add(b.start) new_end = nfa() new_end.terminal = True - for node in union(a.nodes, b.nodes): + for node in (a.nodes | b.nodes): if node.terminal: node.terminal = False node.moves['ε'].add(new_end) @@ -210,7 +210,7 @@ def pmap(f): # prints out the passed field in a way that dot can compile to an s #pmap(compile("ab(c1+2d(e*f)d)*e")) #pmap(either(build_from_char('a'), build_from_char('b'))) # x = compile("(1+0)*1") -# #pmap(x) +# pmap(x) # for s in ["101", "111110", "11001", "1", "0"]: # print(match(x, s)) # x = compile("a+b+c")