Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
fja
eval
Commits
6fcd8620
Commit
6fcd8620
authored
Feb 15, 2021
by
Vladimír Štill
Browse files
lib: Add missing CAN to checker
parent
c9e341bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/checker.py
View file @
6fcd8620
...
@@ -16,15 +16,11 @@ def get_task(string: str) -> Tuple[str, str]: # from IS task prefix
...
@@ -16,15 +16,11 @@ def get_task(string: str) -> Tuple[str, str]: # from IS task prefix
def
dfa_transform
(
string
:
str
,
automaton_type
:
str
)
->
reg
.
DFA
:
def
dfa_transform
(
string
:
str
,
automaton_type
:
str
)
->
reg
.
DFA
:
try
:
if
automaton_type
in
{
"DFA"
,
"TOT"
,
"MIN"
,
"TOC"
,
"CAN"
,
"MIC"
}:
if
automaton_type
in
{
"DFA"
,
"TOT"
,
"MIN"
,
"TOC"
,
"MIC"
}:
parser
=
Parser
()
parser
=
Parser
()
return
parser
.
str_to_dfa
(
string
)
return
parser
.
str_to_dfa
(
string
)
else
:
else
:
return
nfa_transform
(
string
,
automaton_type
).
determinize
()
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
:
def
nfa_transform
(
string
:
str
,
automaton_type
:
str
)
->
reg
.
NFA
:
...
@@ -37,7 +33,7 @@ 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
()
automaton
=
parser
.
str_to_reggrammar
(
string
).
eliminate_useless
().
reggrammar_to_nfa
()
elif
automaton_type
==
"REG"
:
elif
automaton_type
==
"REG"
:
automaton
=
parser
.
str_to_regex
(
string
).
regex_to_efa
().
eliminate_epsilon
()
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
()
automaton
=
parser
.
str_to_dfa
(
string
).
dfa_to_nfa
()
return
reg
.
NFA
(
automaton
.
states
,
automaton
.
characters
,
automaton
.
transition
,
automaton
.
init
,
automaton
.
final
)
return
reg
.
NFA
(
automaton
.
states
,
automaton
.
characters
,
automaton
.
transition
,
automaton
.
init
,
automaton
.
final
)
...
@@ -50,7 +46,7 @@ def transform(string: str, automaton_type: str) -> Union[reg.DFA, reg.NFA, reg.R
...
@@ -50,7 +46,7 @@ def transform(string: str, automaton_type: str) -> Union[reg.DFA, reg.NFA, reg.R
try
:
try
:
parser
=
Parser
()
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
)
formalism
=
parser
.
str_to_dfa
(
string
)
elif
automaton_type
in
{
"EFA"
,
"NFA"
}:
elif
automaton_type
in
{
"EFA"
,
"NFA"
}:
formalism
=
parser
.
str_to_nfa
(
string
)
formalism
=
parser
.
str_to_nfa
(
string
)
...
@@ -74,7 +70,7 @@ def check_task(automaton: Union[reg.DFA, reg.NFA], task: str) -> str:
...
@@ -74,7 +70,7 @@ def check_task(automaton: Union[reg.DFA, reg.NFA], task: str) -> str:
output
=
"NFA obsahuje ε-kroky."
output
=
"NFA obsahuje ε-kroky."
return
output
return
output
if
task
not
in
{
"TOT"
,
"MIN"
,
"TOC"
,
"MIC"
}:
if
task
not
in
{
"TOT"
,
"MIN"
,
"TOC"
,
"CAN"
,
"MIC"
}:
return
output
return
output
if
task
==
"TOT"
and
not
automaton
.
is_total
():
if
task
==
"TOT"
and
not
automaton
.
is_total
():
...
@@ -133,4 +129,4 @@ def exit_correct():
...
@@ -133,4 +129,4 @@ def exit_correct():
def
exit_incorrect
():
def
exit_incorrect
():
print
(
"Nesprávné řešení."
)
print
(
"Nesprávné řešení."
)
exit
(
1
)
exit
(
1
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment