%run Regexp-2-NFA.ipynb
%run RegExp-Parser.ipynb

"""
Explanation: This notebook contains a test for the function toNFA.
End of explanation
"""


r = parse('(ab + ba)*')
r

converter = RegExp2NFA({'a', 'b'})

"""
Explanation: If the regular expression r that is defined below is written in the style of the lecture notes, it reads:
$$(\texttt{a}\cdot\texttt{b} + \texttt{b}\cdot\texttt{a})^*$$
End of explanation
"""


nfa = converter.toNFA(r)
nfa

%run FSM-2-Dot.ipynb

"""
Explanation: We use converter to create a non-deterministic <span style="font-variant:small-caps;">Fsm</span> nfa that accepts the language 
described by the regular expression r.
End of explanation
"""


d = nfa2dot(nfa)
d.render(view=True)

"""
Explanation: I have to use the method render below, because somehow the method displayis buggy and
cuts of parts of the graph.
End of explanation
"""


%run NFA-2-DFA.ipynb

dfa = nfa2dfa(nfa)
dfa

d, S = dfa2dot(dfa)
S

d

"""
Explanation: After having constructed a non-deterministic <span style="font-variant:small-caps;">Fsm</span> for the regular expression,
we convert it into a deterministic <span style="font-variant:small-caps;">Fsm</span>.
End of explanation
"""


