Commit cdcda863 authored by Kateřina Sloupová's avatar Kateřina Sloupová
Browse files

more fixes in DFA minimization and emptiness check

parent 3710e7f4
Pipeline #55279 failed with stage
in 20 seconds
from parser import Parser, ParsingError
from reg_automata import DFA
from reg_automata import DFA, State
from antlr4 import RecognitionException # type: ignore
import sys
import signal
......@@ -17,7 +17,9 @@ def parse(string: str, automaton_type: str) -> DFA:
return automaton
except ParsingError as message:
print(message)
print("Parsing error:", message)
except AttributeError as message:
print("Parsing error:", message)
......
......@@ -409,9 +409,13 @@ class DFA:
if len(reachable.intersection(self.final)) == 0:
return IsEmptyResult()
word = []
state = reachable.intersection(self.final).pop()
if state == self.init:
return IsEmptyResult('ε') # TODO some Eps -> str
else:
word = []
state = reachable.intersection(self.final).pop()
while state is not self.init:
word.append(predecessor[state][1].name)
state = predecessor[state][0]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment