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

fja_checker fix (task type recognition)

parent 0e509fd4
Loading
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -2,22 +2,30 @@ from parser import Parser
from reg_automata import DFA
from antlr4 import RecognitionException # type: ignore
import sys
import signal


def transformation(solution: str, solution_type: str) -> DFA:
    if solution_type == "DFA":

    if solution_type in {"DFA", "TOT"}:
        parser = Parser()
        return parser.str_to_dfa(solution)

    elif solution_type == "NFA":
        parser = Parser()
        nfa = parser.str_to_nfa(solution)
        return nfa.determinize()

    #elif solution_type == "EFA":
    #    parser = Parser()
    #    efa = parser.str_to_efa(solution)
    #    return efa.eliminate_epsilon.determinize()
    else:
        print(solution_type, "type of formalism is not recognized by fja_checker")

def main():
    signal.alarm(60)

    with open(sys.argv[1]) as student_file:
        student_solution = student_file.read()

@@ -33,6 +41,7 @@ def main():
    try:
        parser = Parser()
        result = student_dfa.is_equivalent(teacher_dfa)
        print(parser.dfa_to_str(teacher_dfa))
        if result:
            exit(0)
        else:
+0 −1
Original line number Diff line number Diff line
@@ -101,7 +101,6 @@ class Parser:
        else:
            return init + " " + transition + " " + final


    def str_to_dfa(self, string: str) -> DFA:
        chars = antlr4.InputStream(string)
        lexer = DFA_grammarLexer(chars)