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
2a742b78
Commit
2a742b78
authored
Jul 03, 2020
by
Kateřina Sloupová
Browse files
grammar and regex conversion fix
parent
fd809f8e
Pipeline
#62459
passed with stage
in 1 minute and 3 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
evalweb/web_checker.py
View file @
2a742b78
...
...
@@ -73,8 +73,9 @@ class WebChecker():
if
self
.
task
==
"GRA"
:
return
parser
.
reggrammar_to_str
(
automaton
.
nfa_to_reggrammar
().
eliminate_useless
())
if
self
.
task
==
"REG"
and
student_type
!=
"REG"
:
return
"Tohle není pěkný typ převodu. Nechcete si místo regulárního výrazu vybrat něco jiného?"
if
self
.
task
==
"REG"
:
return
self
.
student_string
if
student_type
==
"REG"
else
\
"Tohle není pěkný typ převodu. Nechcete si místo regulárního výrazu vybrat něco jiného?"
#return parser.regex_to_str(automaton.nfa_to_regex())
except
ParsingError
as
ex
:
...
...
lib/checker.py
View file @
2a742b78
...
...
@@ -33,13 +33,13 @@ def nfa_transform(string: str, automaton_type: str) -> reg.NFA:
if
automaton_type
in
{
"EFA"
,
"NFA"
}:
automaton
=
parser
.
str_to_nfa
(
string
)
elif
automaton_type
==
"GRA"
:
automaton
=
parser
.
str_to_reggrammar
(
string
).
reggrammar_to_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"
}:
automaton
=
parser
.
str_to_dfa
(
string
).
dfa_to_nfa
()
return
automaton
return
reg
.
NFA
(
automaton
.
states
,
automaton
.
characters
,
automaton
.
transition
,
automaton
.
init
,
automaton
.
final
)
except
ParsingError
as
ex
:
raise
ParsingError
(
ex
.
args
)
...
...
lib/reg.py
View file @
2a742b78
...
...
@@ -65,4 +65,6 @@ class NFA(NFA):
pass
class
RegEx
(
RegEx
):
pass
def
regex_to_efa
(
self
)
->
NFA
:
nfa
=
super
().
regex_to_efa
()
# TODO ask how to do this more efficiently
return
NFA
(
nfa
.
states
,
nfa
.
characters
,
nfa
.
transition
,
nfa
.
init
,
nfa
.
final
)
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