forked from IF-LK-2020/py-automaten
dea
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
venv
|
||||
.idea
|
||||
@@ -1,13 +1,25 @@
|
||||
# Übergangsfunktion
|
||||
# Zustand, Buchstabe => Neuer Zustand
|
||||
def transition( state, char ):
|
||||
def transition(state, char):
|
||||
new_state = -1
|
||||
|
||||
# Übergänge
|
||||
# siehe dea_abaca.py für ein Beispiel
|
||||
if state == 0:
|
||||
if char in '123456789':
|
||||
new_state = 1
|
||||
elif char == '0':
|
||||
new_state = 2
|
||||
elif state == 1:
|
||||
if char == '+':
|
||||
new_state = 0
|
||||
if char in '0123456789':
|
||||
new_state = 1
|
||||
elif state == 2:
|
||||
if char == '+':
|
||||
new_state = 0
|
||||
|
||||
return new_state
|
||||
|
||||
|
||||
# Scanner-Funktion für ein Wort
|
||||
# True, wenn das Wort in der Sprache liegt
|
||||
def scan_word(word):
|
||||
@@ -20,7 +32,6 @@ def scan_word(word):
|
||||
# Word wird akzeptiert, wenn einer der Endzustände erreicht wurde
|
||||
return state == 1 # or state == 2
|
||||
|
||||
|
||||
# Programmstart
|
||||
if __name__ == "__main__":
|
||||
word = input("Bitte ein Wort eingeben: ")
|
||||
|
||||
Reference in New Issue
Block a user