-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
36 lines (31 loc) · 1016 Bytes
/
utils.py
File metadata and controls
36 lines (31 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from .fsa import FSA, Transition
def make_fsa(states, alphabet, transitions, initial, accept):
return FSA(
states=states,
alphabet=alphabet,
transitions=[
Transition(**t) for t in transitions
],
initial_state=initial,
accept_states=accept,
)
# if __name__ == "__main__":
# fsa = make_fsa(
# states=["q0", "q1"],
# alphabet=["a"],
# transitions=[
# {"from_state": "q0", "to_state": "q0", "symbol": "a"},
# {"from_state": "q0", "to_state": "q1", "symbol": "a"}, # Non-deterministic
# ],
# initial="q0",
# accept=["q1"],
# )
# draw_fsa(fsa, False, True, "./valid.png")
# fsa = make_fsa(
# states=["q0"],
# alphabet=["a"],
# transitions=[],
# initial="q0",
# accept=["q1"], # q1 is not in states
# )
# draw_fsa(fsa, False, True, "./invalid.png")