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

more fixes in DFA minimization and emptiness check

parent 3710e7f4
Loading
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
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)



+6 −2
Original line number Diff line number Diff line
@@ -409,9 +409,13 @@ class DFA:

        if len(reachable.intersection(self.final)) == 0:
            return IsEmptyResult()
        else:

        word = []
        state = reachable.intersection(self.final).pop()
        if state == self.init:
            return IsEmptyResult('ε') # TODO some Eps -> str

        else:
            while state is not self.init:
                word.append(predecessor[state][1].name)
                state = predecessor[state][0]