Commit 6fcd8620 authored by Vladimír Štill's avatar Vladimír Štill
Browse files

lib: Add missing CAN to checker

parent c9e341bc
......@@ -16,16 +16,12 @@ def get_task(string: str) -> Tuple[str, str]: # from IS task prefix
def dfa_transform(string: str, automaton_type: str) -> reg.DFA:
if automaton_type in {"DFA", "TOT", "MIN", "TOC", "MIC"}:
if automaton_type in {"DFA", "TOT", "MIN", "TOC", "CAN", "MIC"}:
parser = Parser()
return parser.str_to_dfa(string)
return nfa_transform(string, automaton_type).determinize()
except ParsingError as ex:
raise ParsingError(ex.args)
def nfa_transform(string: str, automaton_type: str) -> reg.NFA:
......@@ -37,7 +33,7 @@ def nfa_transform(string: str, automaton_type: str) -> reg.NFA:
automaton = parser.str_to_reggrammar(string).eliminate_useless().reggrammar_to_nfa()
elif automaton_type == "REG":
automaton = parser.str_to_regex(string).regex_to_efa().eliminate_epsilon()
elif automaton_type in {"DFA", "TOT", "MIN", "TOC", "MIC"}:
elif automaton_type in {"DFA", "TOT", "MIN", "TOC", "CAN", "MIC"}:
automaton = parser.str_to_dfa(string).dfa_to_nfa()
return reg.NFA(automaton.states, automaton.characters, automaton.transition, automaton.init,
......@@ -50,7 +46,7 @@ def transform(string: str, automaton_type: str) -> Union[reg.DFA, reg.NFA, reg.R
parser = Parser()
if automaton_type in {"DFA", "TOT", "MIN", "TOC", "MIC"}:
if automaton_type in {"DFA", "TOT", "MIN", "TOC", "CAN", "MIC"}:
formalism = parser.str_to_dfa(string)
elif automaton_type in {"EFA", "NFA"}:
formalism = parser.str_to_nfa(string)
......@@ -74,7 +70,7 @@ def check_task(automaton: Union[reg.DFA, reg.NFA], task: str) -> str:
output = "NFA obsahuje ε-kroky."
return output
if task not in {"TOT", "MIN", "TOC", "MIC"}:
if task not in {"TOT", "MIN", "TOC", "CAN", "MIC"}:
return output
if task == "TOT" and not automaton.is_total():
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