forked from IF-LK-2020/py-automaten
Implemented the method transition
This commit is contained in:
parent
3a25f020e7
commit
21d6809f78
|
@ -3,6 +3,25 @@
|
|||
def transition( state, char ):
|
||||
new_state = -1
|
||||
|
||||
if state == 0:
|
||||
if char in "123456789":
|
||||
new_state = 1
|
||||
elif char == "0":
|
||||
new_state = 2
|
||||
if state == 1:
|
||||
if char == "+":
|
||||
new_state = 0
|
||||
elif char in "123456789":
|
||||
new_state = 1
|
||||
if state == 2:
|
||||
if char == "+":
|
||||
new_state = 0
|
||||
|
||||
return new_state
|
||||
|
||||
|
||||
|
||||
|
||||
# Übergänge
|
||||
# siehe dea_abaca.py für ein Beispiel
|
||||
|
||||
|
@ -18,7 +37,7 @@ def scan_word(word):
|
|||
state = transition(state, char) # Übergangsfunktion ausführen
|
||||
|
||||
# Word wird akzeptiert, wenn einer der Endzustände erreicht wurde
|
||||
return state == 1 # or state == 2
|
||||
return state == 1 or state == 2
|
||||
|
||||
|
||||
# Programmstart
|
||||
|
|
Loading…
Reference in New Issue