From 22ce7f3b549b08211474c9cdce84e527a36c5f65 Mon Sep 17 00:00:00 2001 From: Eryk Miszczuk Date: Mon, 2 Dec 2019 22:46:36 +0100 Subject: [PATCH] Currently program cannot step into epsilon states some more tests is needed why it cannot step into them --- TaskB02/run.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/TaskB02/run.py b/TaskB02/run.py index 1072c90..5e73b5b 100644 --- a/TaskB02/run.py +++ b/TaskB02/run.py @@ -20,17 +20,22 @@ for line in sys.stdin: state_move[(int(move.group(1)), move.group(3))] = (int(move.group(2)), 0) if succes: 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: + # starting with from 0 node because that is atandt standard current_state = 0 word = word.replace('\n', '') 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): current_state = state_move[(current_state, word[character_number])][1] character_number += 1 - elif (current_state, '') in state_move): + # if there is epsilon program move to pointed node but didnt count epsilon as character + elif ((current_state, '') in state_move): current_state = state_move[(current_state, '')][0] else: current_state = -1 @@ -42,4 +47,4 @@ with open(sys.argv[1], 'r', encoding='utf-8') as f: if (current_state in accept_states): print("YES " + word) else: - print("NO" + word) + print("NO " + word)