Loading fja_checker.py +10 −1 Original line number Original line Diff line number Diff line Loading @@ -2,22 +2,30 @@ from parser import Parser from reg_automata import DFA from reg_automata import DFA from antlr4 import RecognitionException # type: ignore from antlr4 import RecognitionException # type: ignore import sys import sys import signal def transformation(solution: str, solution_type: str) -> DFA: def transformation(solution: str, solution_type: str) -> DFA: if solution_type == "DFA": if solution_type in {"DFA", "TOT"}: parser = Parser() parser = Parser() return parser.str_to_dfa(solution) return parser.str_to_dfa(solution) elif solution_type == "NFA": elif solution_type == "NFA": parser = Parser() parser = Parser() nfa = parser.str_to_nfa(solution) nfa = parser.str_to_nfa(solution) return nfa.determinize() return nfa.determinize() #elif solution_type == "EFA": #elif solution_type == "EFA": # parser = Parser() # parser = Parser() # efa = parser.str_to_efa(solution) # efa = parser.str_to_efa(solution) # return efa.eliminate_epsilon.determinize() # return efa.eliminate_epsilon.determinize() else: print(solution_type, "type of formalism is not recognized by fja_checker") def main(): def main(): signal.alarm(60) with open(sys.argv[1]) as student_file: with open(sys.argv[1]) as student_file: student_solution = student_file.read() student_solution = student_file.read() Loading @@ -33,6 +41,7 @@ def main(): try: try: parser = Parser() parser = Parser() result = student_dfa.is_equivalent(teacher_dfa) result = student_dfa.is_equivalent(teacher_dfa) print(parser.dfa_to_str(teacher_dfa)) if result: if result: exit(0) exit(0) else: else: Loading parser.py +0 −1 Original line number Original line Diff line number Diff line Loading @@ -101,7 +101,6 @@ class Parser: else: else: return init + " " + transition + " " + final return init + " " + transition + " " + final def str_to_dfa(self, string: str) -> DFA: def str_to_dfa(self, string: str) -> DFA: chars = antlr4.InputStream(string) chars = antlr4.InputStream(string) lexer = DFA_grammarLexer(chars) lexer = DFA_grammarLexer(chars) Loading Loading
fja_checker.py +10 −1 Original line number Original line Diff line number Diff line Loading @@ -2,22 +2,30 @@ from parser import Parser from reg_automata import DFA from reg_automata import DFA from antlr4 import RecognitionException # type: ignore from antlr4 import RecognitionException # type: ignore import sys import sys import signal def transformation(solution: str, solution_type: str) -> DFA: def transformation(solution: str, solution_type: str) -> DFA: if solution_type == "DFA": if solution_type in {"DFA", "TOT"}: parser = Parser() parser = Parser() return parser.str_to_dfa(solution) return parser.str_to_dfa(solution) elif solution_type == "NFA": elif solution_type == "NFA": parser = Parser() parser = Parser() nfa = parser.str_to_nfa(solution) nfa = parser.str_to_nfa(solution) return nfa.determinize() return nfa.determinize() #elif solution_type == "EFA": #elif solution_type == "EFA": # parser = Parser() # parser = Parser() # efa = parser.str_to_efa(solution) # efa = parser.str_to_efa(solution) # return efa.eliminate_epsilon.determinize() # return efa.eliminate_epsilon.determinize() else: print(solution_type, "type of formalism is not recognized by fja_checker") def main(): def main(): signal.alarm(60) with open(sys.argv[1]) as student_file: with open(sys.argv[1]) as student_file: student_solution = student_file.read() student_solution = student_file.read() Loading @@ -33,6 +41,7 @@ def main(): try: try: parser = Parser() parser = Parser() result = student_dfa.is_equivalent(teacher_dfa) result = student_dfa.is_equivalent(teacher_dfa) print(parser.dfa_to_str(teacher_dfa)) if result: if result: exit(0) exit(0) else: else: Loading
parser.py +0 −1 Original line number Original line Diff line number Diff line Loading @@ -101,7 +101,6 @@ class Parser: else: else: return init + " " + transition + " " + final return init + " " + transition + " " + final def str_to_dfa(self, string: str) -> DFA: def str_to_dfa(self, string: str) -> DFA: chars = antlr4.InputStream(string) chars = antlr4.InputStream(string) lexer = DFA_grammarLexer(chars) lexer = DFA_grammarLexer(chars) Loading