Currently program cannot step into epsilon states

some more tests is needed why it cannot step into them
This commit is contained in:
Eryk Miszczuk 2019-12-02 22:46:36 +01:00
parent 216b5843f1
commit 22ce7f3b54

View File

@ -20,17 +20,22 @@ for line in sys.stdin:
state_move[(int(move.group(1)), move.group(3))] = (int(move.group(2)), 0) state_move[(int(move.group(1)), move.group(3))] = (int(move.group(2)), 0)
if succes: if succes:
accept_states.append(int(line)) accept_states.append(int(line))
print(state_move)
with open(sys.argv[1], 'r', encoding='utf-8') as f: with open(sys.argv[1], 'r') as f:
for word in f: for word in f:
# starting with from 0 node because that is atandt standard
current_state = 0 current_state = 0
word = word.replace('\n', '') word = word.replace('\n', '')
character_number = 0 character_number = 0
while character_number < len(word): # 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))
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])][1]
character_number += 1 character_number += 1
elif (current_state, '<eps>') in state_move): # if there is epsilon program move to pointed node but didnt count epsilon as character
elif ((current_state, '<eps>') in state_move):
current_state = state_move[(current_state, '<eps>')][0] current_state = state_move[(current_state, '<eps>')][0]
else: else:
current_state = -1 current_state = -1
@ -42,4 +47,4 @@ with open(sys.argv[1], 'r', encoding='utf-8') as f:
if (current_state in accept_states): if (current_state in accept_states):
print("YES " + word) print("YES " + word)
else: else:
print("NO" + word) print("NO " + word)