TaskB02
This commit is contained in:
parent
22ce7f3b54
commit
40d837f7bc
@ -29,10 +29,10 @@ with open(sys.argv[1], 'r') as f:
|
|||||||
word = word.replace('\n', '')
|
word = word.replace('\n', '')
|
||||||
character_number = 0
|
character_number = 0
|
||||||
# checking what is next state based on current character from word
|
# checking what is next state based on current character from word
|
||||||
while character_number <= len(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))
|
#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):
|
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
|
character_number += 1
|
||||||
# if there is epsilon program move to pointed node but didnt count epsilon as character
|
# if there is epsilon program move to pointed node but didnt count epsilon as character
|
||||||
elif ((current_state, '<eps>') in state_move):
|
elif ((current_state, '<eps>') in state_move):
|
||||||
@ -40,7 +40,9 @@ with open(sys.argv[1], 'r') as f:
|
|||||||
else:
|
else:
|
||||||
current_state = -1
|
current_state = -1
|
||||||
character_number += 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):
|
while ((current_state, '<eps>') in state_move):
|
||||||
current_state = state_move[(current_state, '<eps>')][0]
|
current_state = state_move[(current_state, '<eps>')][0]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user