This commit is contained in:
Eryk Miszczuk 2019-12-03 09:01:32 +01:00
parent 22ce7f3b54
commit 40d837f7bc

View File

@ -29,10 +29,10 @@ with open(sys.argv[1], 'r') as f:
word = word.replace('\n', '')
character_number = 0
# checking what is next state based on current character from word
while character_number <= len(word):
print('State: {current_state} and character: {char} on index {character_number}'.format(current_state = current_state, char = word[character_number], character_number = character_number))
while character_number < len(word):
#print('State: {current_state} and character: {char} on index {character_number}'.format(current_state = current_state, char = word[character_number], character_number = character_number))
if ((current_state, word[character_number]) in state_move):
current_state = state_move[(current_state, word[character_number])][1]
current_state = state_move[(current_state, word[character_number])][0]
character_number += 1
# if there is epsilon program move to pointed node but didnt count epsilon as character
elif ((current_state, '<eps>') in state_move):
@ -40,7 +40,9 @@ with open(sys.argv[1], 'r') as f:
else:
current_state = -1
character_number += 1
#print('State after {char} letter: {current_state} and index {character_number}'.format(current_state = current_state, char = word[character_number - 1], character_number = character_number))
#print('State after consuming whole word: {current_state}'.format(current_state = current_state))
while ((current_state, '<eps>') in state_move):
current_state = state_move[(current_state, '<eps>')][0]