This commit is contained in:
deadsmond 2019-11-25 21:05:54 +01:00
parent 17da17130e
commit a43a406bf3

View File

@ -12,6 +12,8 @@ class automata:
self.accepting_states = []
# list of current states
self.state = ['0']
# word variable
self.word = ''
# print for debug purposes
def __repr__(self):
@ -32,11 +34,11 @@ class automata:
self.accepting_states.append(node[0])
# check if string is accepted by automate
def test_string(self, text):
def test_string(self, word):
self.state = ['0']
text = text.replace('\n', '')
# for all values in text
for i in text:
self.word = word.replace('\n', '')
# for all values in word
for i in self.word:
# for all actual states
result = []
for q in self.state:
@ -79,6 +81,6 @@ f = open(sys.argv[1], 'r')
for line in f:
if auto.test_string(line):
print("TRUE %s" % line)
print("TRUE %s" % auto.word)
else:
print("FALSE %s" % line)
print("FALSE %s" % auto.word)