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
c802d0ab
Commit
c802d0ab
authored
Mar 11, 2020
by
Kateřina Sloupová
Browse files
init could be empty plus first exception messages in fja_checker
parent
eebcc1bc
Pipeline
#55167
failed with stage
in 20 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
DFA_grammar.g4
View file @
c802d0ab
...
...
@@ -4,7 +4,7 @@ grammar DFA_grammar;
start: init production* final;
init: INIT EQUALS statename;
init:
(
INIT EQUALS statename
| )
;
production: LEFT_PARENTHESIS statename COMMA statename RIGHT_PARENTHESIS EQUALS statename;
...
...
DFA_grammar.interp
View file @
c802d0ab
...
...
@@ -33,4 +33,4 @@ statename
atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 12, 52, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 3, 2, 7, 2, 15, 10, 2, 12, 2, 14, 2, 18, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 7, 5, 40, 10, 5, 12, 5, 14, 5, 43, 11, 5, 3, 5, 5, 5, 46, 10, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 2, 2, 7, 2, 4, 6, 8, 10, 2, 2, 2, 49, 2, 12, 3, 2, 2, 2, 4, 21, 3, 2, 2, 2, 6, 25, 3, 2, 2, 2, 8, 33, 3, 2, 2, 2, 10, 49, 3, 2, 2, 2, 12, 16, 5, 4, 3, 2, 13, 15, 5, 6, 4, 2, 14, 13, 3, 2, 2, 2, 15, 18, 3, 2, 2, 2, 16, 14, 3, 2, 2, 2, 16, 17, 3, 2, 2, 2, 17, 19, 3, 2, 2, 2, 18, 16, 3, 2, 2, 2, 19, 20, 5, 8, 5, 2, 20, 3, 3, 2, 2, 2, 21, 22, 7, 3, 2, 2, 22, 23, 7, 4, 2, 2, 23, 24, 5, 10, 6, 2, 24, 5, 3, 2, 2, 2, 25, 26, 7, 5, 2, 2, 26, 27, 5, 10, 6, 2, 27, 28, 7, 9, 2, 2, 28, 29, 5, 10, 6, 2, 29, 30, 7, 6, 2, 2, 30, 31, 7, 4, 2, 2, 31, 32, 5, 10, 6, 2, 32, 7, 3, 2, 2, 2, 33, 34, 7, 10, 2, 2, 34, 35, 7, 4, 2, 2, 35, 45, 7, 7, 2, 2, 36, 41, 5, 10, 6, 2, 37, 38, 7, 9, 2, 2, 38, 40, 5, 10, 6, 2, 39, 37, 3, 2, 2, 2, 40, 43, 3, 2, 2, 2, 41, 39, 3, 2, 2, 2, 41, 42, 3, 2, 2, 2, 42, 46, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 44, 46, 3, 2, 2, 2, 45, 36, 3, 2, 2, 2, 45, 44, 3, 2, 2, 2, 46, 47, 3, 2, 2, 2, 47, 48, 7, 8, 2, 2, 48, 9, 3, 2, 2, 2, 49, 50, 7, 11, 2, 2, 50, 11, 3, 2, 2, 2, 5, 16, 41, 45]
\ No newline at end of file
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 12, 54, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 3, 2, 7, 2, 15, 10, 2, 12, 2, 14, 2, 18, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 26, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 7, 5, 42, 10, 5, 12, 5, 14, 5, 45, 11, 5, 3, 5, 5, 5, 48, 10, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 2, 2, 7, 2, 4, 6, 8, 10, 2, 2, 2, 52, 2, 12, 3, 2, 2, 2, 4, 25, 3, 2, 2, 2, 6, 27, 3, 2, 2, 2, 8, 35, 3, 2, 2, 2, 10, 51, 3, 2, 2, 2, 12, 16, 5, 4, 3, 2, 13, 15, 5, 6, 4, 2, 14, 13, 3, 2, 2, 2, 15, 18, 3, 2, 2, 2, 16, 14, 3, 2, 2, 2, 16, 17, 3, 2, 2, 2, 17, 19, 3, 2, 2, 2, 18, 16, 3, 2, 2, 2, 19, 20, 5, 8, 5, 2, 20, 3, 3, 2, 2, 2, 21, 22, 7, 3, 2, 2, 22, 23, 7, 4, 2, 2, 23, 26, 5, 10, 6, 2, 24, 26, 3, 2, 2, 2, 25, 21, 3, 2, 2, 2, 25, 24, 3, 2, 2, 2, 26, 5, 3, 2, 2, 2, 27, 28, 7, 5, 2, 2, 28, 29, 5, 10, 6, 2, 29, 30, 7, 9, 2, 2, 30, 31, 5, 10, 6, 2, 31, 32, 7, 6, 2, 2, 32, 33, 7, 4, 2, 2, 33, 34, 5, 10, 6, 2, 34, 7, 3, 2, 2, 2, 35, 36, 7, 10, 2, 2, 36, 37, 7, 4, 2, 2, 37, 47, 7, 7, 2, 2, 38, 43, 5, 10, 6, 2, 39, 40, 7, 9, 2, 2, 40, 42, 5, 10, 6, 2, 41, 39, 3, 2, 2, 2, 42, 45, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 48, 3, 2, 2, 2, 45, 43, 3, 2, 2, 2, 46, 48, 3, 2, 2, 2, 47, 38, 3, 2, 2, 2, 47, 46, 3, 2, 2, 2, 48, 49, 3, 2, 2, 2, 49, 50, 7, 8, 2, 2, 50, 9, 3, 2, 2, 2, 51, 52, 7, 11, 2, 2, 52, 11, 3, 2, 2, 2, 6, 16, 25, 43, 47]
\ No newline at end of file
DFA_grammarParser.py
View file @
c802d0ab
...
...
@@ -12,22 +12,23 @@ else:
def
serializedATN
():
with
StringIO
()
as
buf
:
buf
.
write
(
"
\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\f
"
)
buf
.
write
(
"
\64\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\3\2\3\2\7
"
)
buf
.
write
(
"
\2\17\n\2\f\2\16\2\22\13\2\3\2\3\2\3\3\3\3\3\3\3\3\3\4
"
)
buf
.
write
(
"
\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\7
"
)
buf
.
write
(
"
\5
(
\n\5\f\5\16\5
+
\13\5\3\5\5\5
.
\n\5\3\5\3\5\3\6\3\6\3
"
)
buf
.
write
(
"
\6\2\2\7\2\4\6\b\n\2\2\2\61\2\f\3\2\2\2\4\25\3\2\2\2\6
"
)
buf
.
write
(
"
\31\3\2\2\2\b
!
\3\2\2\2\n\61\3\2\2\2\f\20\5\4\3\2\r\17
"
)
buf
.
write
(
"
\5\6\4\2\16\r\3\2\2\2\17\22\3\2\2\2\20\16\3\2\2\2\20\21
"
)
buf
.
write
(
"
\3\2\2\2\21\23\3\2\2\2\22\20\3\2\2\2\23\24\5\b\5\2\24
"
)
buf
.
write
(
"
\3\3\2\2\2\25\26\7\3\2\2\26\27\7\4\2\2\27\30\5\n\6\2\30
"
)
buf
.
write
(
"
\5\3\2\2\2\31\32\7\5\2\2\32\33\5\n\6\2\33\34\7\t\2\2\34
"
)
buf
.
write
(
"
\35\5\n\6\2\35\36\7\6\2\2\36\37\7\4\2\2\37
\5\n\6\2
\7
"
)
buf
.
write
(
"
\3\2\2\2
!
\"\7\n\2\2\"
#
\7\4\2\2
#-
\7\7\2\2
$)
\5\n\6\2
%&
\7
"
)
buf
.
write
(
"
\t\2\2
&(
\5\n\6\2\'
%
\3\2\2\2
(+
\3\2\2\2
)
\'\3\2\2\2
)*
\3\2
"
)
buf
.
write
(
"
\2\2
*.
\3\2\2\2
+)
\3\2\2\2
,.
\3\2\2\2
-$
\3\2\2\2
-,
\3\2\2\2
"
)
buf
.
write
(
"./
\3\2\2\2
/
\60\7\b\2\2\60\t\3\2\2\2\61\62\7\13\2\2\62
"
)
buf
.
write
(
"
\13\3\2\2\2\5\20
)-"
)
buf
.
write
(
"
\66\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\3\2\3\2\7
"
)
buf
.
write
(
"
\2\17\n\2\f\2\16\2\22\13\2\3\2\3\2\3\3\3\3\3\3\3\3\5\3
"
)
buf
.
write
(
"
\32\n\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3\5\3
"
)
buf
.
write
(
"
\5\3\5\3\5\7\5
*
\n\5\f\5\16\5
-
\13\5\3\5\5\5\60\n\5\3\5
"
)
buf
.
write
(
"
\3\5\3\6\3\6\3\6\2\2\7\2\4\6\b\n\2\2\2\64\2\f\3\2\2\2
"
)
buf
.
write
(
"
\4\31\3\2\2\2\6\33\3\2\2\2\b
#
\3\2\2\2\n\63\3\2\2\2\f\20
"
)
buf
.
write
(
"
\5\4\3\2\r\17\5\6\4\2\16\r\3\2\2\2\17\22\3\2\2\2\20\16
"
)
buf
.
write
(
"
\3\2\2\2\20\21\3\2\2\2\21\23\3\2\2\2\22\20\3\2\2\2\23
"
)
buf
.
write
(
"
\24\5\b\5\2\24\3\3\2\2\2\25\26\7\3\2\2\26\27\7\4\2\2\27
"
)
buf
.
write
(
"
\32\5\n\6\2\30\32\3\2\2\2\31\25\3\2\2\2\31\30\3\2\2\2
"
)
buf
.
write
(
"
\32\5\3\2\2\2\33\34\7\5\2\2\34\35\5\n\6\2\35\36\7\t\2
"
)
buf
.
write
(
"
\2\36\37\5\n\6\2\37
\7\6\2\2
!
\7\4\2\2
!
\"\5\n\6\2\"\7
"
)
buf
.
write
(
"
\3\2\2\2
#$
\7\n\2\2
$%
\7\4\2\2
%/
\7\7\2\2
&+
\5\n\6\2\'
(
\7
"
)
buf
.
write
(
"
\t\2\2
(*
\5\n\6\2
)
\'\3\2\2\2
*-
\3\2\2\2
+)
\3\2\2\2
+,
\3\2
"
)
buf
.
write
(
"
\2\2
,
\60\3\2\2\2
-+
\3\2\2\2
.
\60\3\2\2\2
/&
\3\2\2\2
/.
\3\2
"
)
buf
.
write
(
"
\2\2\60\61\3\2\2\2\61\62\7\b\2\2\62\t\3\2\2\2\63\64\7
"
)
buf
.
write
(
"
\13\2\2\64\13\3\2\2\2\6\20\31
+/"
)
return
buf
.
getvalue
()
...
...
@@ -178,12 +179,22 @@ class DFA_grammarParser ( Parser ):
self
.
enterRule
(
localctx
,
2
,
self
.
RULE_init
)
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
19
self
.
match
(
DFA_grammarParser
.
INIT
)
self
.
state
=
20
self
.
match
(
DFA_grammarParser
.
EQUALS
)
self
.
state
=
21
self
.
statename
()
self
.
state
=
23
self
.
_errHandler
.
sync
(
self
)
token
=
self
.
_input
.
LA
(
1
)
if
token
in
[
DFA_grammarParser
.
INIT
]:
self
.
state
=
19
self
.
match
(
DFA_grammarParser
.
INIT
)
self
.
state
=
20
self
.
match
(
DFA_grammarParser
.
EQUALS
)
self
.
state
=
21
self
.
statename
()
pass
elif
token
in
[
DFA_grammarParser
.
LEFT_PARENTHESIS
,
DFA_grammarParser
.
FINAL
]:
pass
else
:
raise
NoViableAltException
(
self
)
except
RecognitionException
as
re
:
localctx
.
exception
=
re
self
.
_errHandler
.
reportError
(
self
,
re
)
...
...
@@ -238,19 +249,19 @@ class DFA_grammarParser ( Parser ):
self
.
enterRule
(
localctx
,
4
,
self
.
RULE_production
)
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
23
self
.
match
(
DFA_grammarParser
.
LEFT_PARENTHESIS
)
self
.
state
=
24
self
.
statename
()
self
.
state
=
25
self
.
match
(
DFA_grammarParser
.
COMMA
)
self
.
match
(
DFA_grammarParser
.
LEFT_PARENTHESIS
)
self
.
state
=
26
self
.
statename
()
self
.
state
=
27
self
.
match
(
DFA_grammarParser
.
RIGHT_PARENTHESIS
)
self
.
match
(
DFA_grammarParser
.
COMMA
)
self
.
state
=
28
self
.
match
(
DFA_grammarParser
.
EQUALS
)
self
.
statename
(
)
self
.
state
=
29
self
.
match
(
DFA_grammarParser
.
RIGHT_PARENTHESIS
)
self
.
state
=
30
self
.
match
(
DFA_grammarParser
.
EQUALS
)
self
.
state
=
31
self
.
statename
()
except
RecognitionException
as
re
:
localctx
.
exception
=
re
...
...
@@ -313,27 +324,27 @@ class DFA_grammarParser ( Parser ):
self
.
_la
=
0
# Token type
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
3
1
self
.
state
=
3
3
self
.
match
(
DFA_grammarParser
.
FINAL
)
self
.
state
=
3
2
self
.
state
=
3
4
self
.
match
(
DFA_grammarParser
.
EQUALS
)
self
.
state
=
3
3
self
.
state
=
3
5
self
.
match
(
DFA_grammarParser
.
LEFT_BRACKET
)
self
.
state
=
4
3
self
.
state
=
4
5
self
.
_errHandler
.
sync
(
self
)
token
=
self
.
_input
.
LA
(
1
)
if
token
in
[
DFA_grammarParser
.
STATE
]:
self
.
state
=
3
4
self
.
state
=
3
6
self
.
statename
()
self
.
state
=
39
self
.
state
=
41
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
while
_la
==
DFA_grammarParser
.
COMMA
:
self
.
state
=
3
5
self
.
state
=
3
7
self
.
match
(
DFA_grammarParser
.
COMMA
)
self
.
state
=
3
6
self
.
state
=
3
8
self
.
statename
()
self
.
state
=
4
1
self
.
state
=
4
3
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
...
...
@@ -343,7 +354,7 @@ class DFA_grammarParser ( Parser ):
else
:
raise
NoViableAltException
(
self
)
self
.
state
=
4
5
self
.
state
=
4
7
self
.
match
(
DFA_grammarParser
.
RIGHT_BRACKET
)
except
RecognitionException
as
re
:
localctx
.
exception
=
re
...
...
@@ -383,7 +394,7 @@ class DFA_grammarParser ( Parser ):
self
.
enterRule
(
localctx
,
8
,
self
.
RULE_statename
)
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
4
7
self
.
state
=
4
9
self
.
match
(
DFA_grammarParser
.
STATE
)
except
RecognitionException
as
re
:
localctx
.
exception
=
re
...
...
NFA_grammar.g4
View file @
c802d0ab
...
...
@@ -4,7 +4,7 @@ grammar NFA_grammar;
start: init production* final;
init: INIT EQUALS statename;
init:
(
INIT EQUALS statename
| )
;
production: LEFT_PARENTHESIS statename COMMA statename RIGHT_PARENTHESIS EQUALS stateset;
...
...
NFA_grammar.interp
View file @
c802d0ab
...
...
@@ -34,4 +34,4 @@ statename
atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 12, 56, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 3, 2, 3, 2, 7, 2, 17, 10, 2, 12, 2, 14, 2, 20, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 7, 5, 40, 10, 5, 12, 5, 14, 5, 43, 11, 5, 3, 5, 5, 5, 46, 10, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 2, 2, 8, 2, 4, 6, 8, 10, 12, 2, 2, 2, 52, 2, 14, 3, 2, 2, 2, 4, 23, 3, 2, 2, 2, 6, 27, 3, 2, 2, 2, 8, 35, 3, 2, 2, 2, 10, 49, 3, 2, 2, 2, 12, 53, 3, 2, 2, 2, 14, 18, 5, 4, 3, 2, 15, 17, 5, 6, 4, 2, 16, 15, 3, 2, 2, 2, 17, 20, 3, 2, 2, 2, 18, 16, 3, 2, 2, 2, 18, 19, 3, 2, 2, 2, 19, 21, 3, 2, 2, 2, 20, 18, 3, 2, 2, 2, 21, 22, 5, 10, 6, 2, 22, 3, 3, 2, 2, 2, 23, 24, 7, 3, 2, 2, 24, 25, 7, 4, 2, 2, 25, 26, 5, 12, 7, 2, 26, 5, 3, 2, 2, 2, 27, 28, 7, 5, 2, 2, 28, 29, 5, 12, 7, 2, 29, 30, 7, 9, 2, 2, 30, 31, 5, 12, 7, 2, 31, 32, 7, 6, 2, 2, 32, 33, 7, 4, 2, 2, 33, 34, 5, 8, 5, 2, 34, 7, 3, 2, 2, 2, 35, 45, 7, 7, 2, 2, 36, 41, 5, 12, 7, 2, 37, 38, 7, 9, 2, 2, 38, 40, 5, 12, 7, 2, 39, 37, 3, 2, 2, 2, 40, 43, 3, 2, 2, 2, 41, 39, 3, 2, 2, 2, 41, 42, 3, 2, 2, 2, 42, 46, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 44, 46, 3, 2, 2, 2, 45, 36, 3, 2, 2, 2, 45, 44, 3, 2, 2, 2, 46, 47, 3, 2, 2, 2, 47, 48, 7, 8, 2, 2, 48, 9, 3, 2, 2, 2, 49, 50, 7, 10, 2, 2, 50, 51, 7, 4, 2, 2, 51, 52, 5, 8, 5, 2, 52, 11, 3, 2, 2, 2, 53, 54, 7, 11, 2, 2, 54, 13, 3, 2, 2, 2, 5, 18, 41, 45]
\ No newline at end of file
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 12, 58, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 3, 2, 3, 2, 7, 2, 17, 10, 2, 12, 2, 14, 2, 20, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 28, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 7, 5, 42, 10, 5, 12, 5, 14, 5, 45, 11, 5, 3, 5, 5, 5, 48, 10, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 2, 2, 8, 2, 4, 6, 8, 10, 12, 2, 2, 2, 55, 2, 14, 3, 2, 2, 2, 4, 27, 3, 2, 2, 2, 6, 29, 3, 2, 2, 2, 8, 37, 3, 2, 2, 2, 10, 51, 3, 2, 2, 2, 12, 55, 3, 2, 2, 2, 14, 18, 5, 4, 3, 2, 15, 17, 5, 6, 4, 2, 16, 15, 3, 2, 2, 2, 17, 20, 3, 2, 2, 2, 18, 16, 3, 2, 2, 2, 18, 19, 3, 2, 2, 2, 19, 21, 3, 2, 2, 2, 20, 18, 3, 2, 2, 2, 21, 22, 5, 10, 6, 2, 22, 3, 3, 2, 2, 2, 23, 24, 7, 3, 2, 2, 24, 25, 7, 4, 2, 2, 25, 28, 5, 12, 7, 2, 26, 28, 3, 2, 2, 2, 27, 23, 3, 2, 2, 2, 27, 26, 3, 2, 2, 2, 28, 5, 3, 2, 2, 2, 29, 30, 7, 5, 2, 2, 30, 31, 5, 12, 7, 2, 31, 32, 7, 9, 2, 2, 32, 33, 5, 12, 7, 2, 33, 34, 7, 6, 2, 2, 34, 35, 7, 4, 2, 2, 35, 36, 5, 8, 5, 2, 36, 7, 3, 2, 2, 2, 37, 47, 7, 7, 2, 2, 38, 43, 5, 12, 7, 2, 39, 40, 7, 9, 2, 2, 40, 42, 5, 12, 7, 2, 41, 39, 3, 2, 2, 2, 42, 45, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 48, 3, 2, 2, 2, 45, 43, 3, 2, 2, 2, 46, 48, 3, 2, 2, 2, 47, 38, 3, 2, 2, 2, 47, 46, 3, 2, 2, 2, 48, 49, 3, 2, 2, 2, 49, 50, 7, 8, 2, 2, 50, 9, 3, 2, 2, 2, 51, 52, 7, 10, 2, 2, 52, 53, 7, 4, 2, 2, 53, 54, 5, 8, 5, 2, 54, 11, 3, 2, 2, 2, 55, 56, 7, 11, 2, 2, 56, 13, 3, 2, 2, 2, 6, 18, 27, 43, 47]
\ No newline at end of file
NFA_grammarParser.py
View file @
c802d0ab
...
...
@@ -12,23 +12,24 @@ else:
def
serializedATN
():
with
StringIO
()
as
buf
:
buf
.
write
(
"
\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\f
"
)
buf
.
write
(
"
8
\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\3\2
"
)
buf
.
write
(
"
:
\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\3\2
"
)
buf
.
write
(
"
\3\2\7\2\21\n\2\f\2\16\2\24\13\2\3\2\3\2\3\3\3\3\3\3\3
"
)
buf
.
write
(
"
\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3\5\3\5\7\5
"
)
buf
.
write
(
"(
\n\5\f\5\16\5
+
\13\5\3\5\5\5
.
\n\5\3\5\3\5\3\6\3\6\3\6
"
)
buf
.
write
(
"
\3\6\3\7\3\7\3\7\2\2\b\2\4\6\b\n\f\2\2\2\64\2\16\3\2\2
"
)
buf
.
write
(
"
\2\4\27\3\2\2\2\6\33\3\2\2\2\b
#
\3\2\2\2\n\61\3\2\2\2\f
"
)
buf
.
write
(
"
\65\3\2\2\2\16\22\5\4\3\2\17\21\5\6\4\2\20\17\3\2\2\2
"
)
buf
.
write
(
"
\21\24\3\2\2\2\22\20\3\2\2\2\22\23\3\2\2\2\23\25\3\2\2
"
)
buf
.
write
(
"
\2\24\22\3\2\2\2\25\26\5\n\6\2\26\3\3\2\2\2\27\30\7\3
"
)
buf
.
write
(
"
\2\2\30\31\7\4\2\2\31\32\5\f\7\2\32\5\3\2\2\2\33\34\7
"
)
buf
.
write
(
"
\5\2\2\34\35\5\f\7\2\35\36\7\t\2\2\36\37\5\f\7\2\37
\7
"
)
buf
.
write
(
"
\6\2\2
!
\7\4\2\2
!
\"\5\b\5\2\"\7\3\2\2\2
#-
\7\7\2\2
$)
\5
"
)
buf
.
write
(
"
\f\7\2
%&
\7\t\2\2
&(
\5\f\7\2\'
%
\3\2\2\2
(+
\3\2\2\2
)
\'\3\2
"
)
buf
.
write
(
"
\2\2
)*
\3\2\2\2
*.
\3\2\2\2
+)
\3\2\2\2
,.
\3\2\2\2
-$
\3\2\2\2
"
)
buf
.
write
(
"-,
\3\2\2\2
./
\3\2\2\2
/
\60\7\b\2\2\60\t\3\2\2\2\61\62\7
"
)
buf
.
write
(
"
\n\2\2\62\63\7\4\2\2\63\64\5\b\5\2\64\13\3\2\2\2\65\66
"
)
buf
.
write
(
"
\7\13\2\2\66\r\3\2\2\2\5\22
)-"
)
buf
.
write
(
"
\3\5\3\34\n\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5
"
)
buf
.
write
(
"
\3\5\3\5\7\5
*
\n\5\f\5\16\5
-
\13\5\3\5\5\5\60\n\5\3\5\3
"
)
buf
.
write
(
"
\5\3\6\3\6\3\6\3\6\3\7\3\7\3\7\2\2\b\2\4\6\b\n\f\2\2\2
"
)
buf
.
write
(
"
\67\2\16\3\2\2\2\4\33\3\2\2\2\6\35\3\2\2\2\b
%
\3\2\2\2
"
)
buf
.
write
(
"
\n\63\3\2\2\2\f\67\3\2\2\2\16\22\5\4\3\2\17\21\5\6\4\2
"
)
buf
.
write
(
"
\20\17\3\2\2\2\21\24\3\2\2\2\22\20\3\2\2\2\22\23\3\2\2
"
)
buf
.
write
(
"
\2\23\25\3\2\2\2\24\22\3\2\2\2\25\26\5\n\6\2\26\3\3\2
"
)
buf
.
write
(
"
\2\2\27\30\7\3\2\2\30\31\7\4\2\2\31\34\5\f\7\2\32\34\3
"
)
buf
.
write
(
"
\2\2\2\33\27\3\2\2\2\33\32\3\2\2\2\34\5\3\2\2\2\35\36
"
)
buf
.
write
(
"
\7\5\2\2\36\37\5\f\7\2\37
\7\t\2\2
!
\5\f\7\2
!
\"\7\6\2
"
)
buf
.
write
(
"
\2\"
#
\7\4\2\2
#$
\5\b\5\2
$
\7\3\2\2\2
%/
\7\7\2\2
&+
\5\f\7\2
"
)
buf
.
write
(
"
\'
(
\7\t\2\2
(*
\5\f\7\2
)
\'\3\2\2\2
*-
\3\2\2\2
+)
\3\2\2\2
+"
)
buf
.
write
(
",
\3\2\2\2
,
\60\3\2\2\2
-+
\3\2\2\2
.
\60\3\2\2\2
/&
\3\2\2\2
"
)
buf
.
write
(
"/.
\3\2\2\2\60\61\3\2\2\2\61\62\7\b\2\2\62\t\3\2\2\2\63
"
)
buf
.
write
(
"
\64\7\n\2\2\64\65\7\4\2\2\65\66\5\b\5\2\66\13\3\2\2\2
"
)
buf
.
write
(
"
\67
8
\7\13\2\2
8
\r\3\2\2\2\6\22\33
+/"
)
return
buf
.
getvalue
()
...
...
@@ -180,12 +181,22 @@ class NFA_grammarParser ( Parser ):
self
.
enterRule
(
localctx
,
2
,
self
.
RULE_init
)
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
21
self
.
match
(
NFA_grammarParser
.
INIT
)
self
.
state
=
22
self
.
match
(
NFA_grammarParser
.
EQUALS
)
self
.
state
=
23
self
.
statename
()
self
.
state
=
25
self
.
_errHandler
.
sync
(
self
)
token
=
self
.
_input
.
LA
(
1
)
if
token
in
[
NFA_grammarParser
.
INIT
]:
self
.
state
=
21
self
.
match
(
NFA_grammarParser
.
INIT
)
self
.
state
=
22
self
.
match
(
NFA_grammarParser
.
EQUALS
)
self
.
state
=
23
self
.
statename
()
pass
elif
token
in
[
NFA_grammarParser
.
LEFT_PARENTHESIS
,
NFA_grammarParser
.
FINAL
]:
pass
else
:
raise
NoViableAltException
(
self
)
except
RecognitionException
as
re
:
localctx
.
exception
=
re
self
.
_errHandler
.
reportError
(
self
,
re
)
...
...
@@ -244,19 +255,19 @@ class NFA_grammarParser ( Parser ):
self
.
enterRule
(
localctx
,
4
,
self
.
RULE_production
)
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
25
self
.
match
(
NFA_grammarParser
.
LEFT_PARENTHESIS
)
self
.
state
=
26
self
.
statename
()
self
.
state
=
27
self
.
match
(
NFA_grammarParser
.
COMMA
)
self
.
match
(
NFA_grammarParser
.
LEFT_PARENTHESIS
)
self
.
state
=
28
self
.
statename
()
self
.
state
=
29
self
.
match
(
NFA_grammarParser
.
RIGHT_PARENTHESIS
)
self
.
match
(
NFA_grammarParser
.
COMMA
)
self
.
state
=
30
self
.
match
(
NFA_grammarParser
.
EQUALS
)
self
.
statename
(
)
self
.
state
=
31
self
.
match
(
NFA_grammarParser
.
RIGHT_PARENTHESIS
)
self
.
state
=
32
self
.
match
(
NFA_grammarParser
.
EQUALS
)
self
.
state
=
33
self
.
stateset
()
except
RecognitionException
as
re
:
localctx
.
exception
=
re
...
...
@@ -313,23 +324,23 @@ class NFA_grammarParser ( Parser ):
self
.
_la
=
0
# Token type
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
3
3
self
.
state
=
3
5
self
.
match
(
NFA_grammarParser
.
LEFT_BRACKET
)
self
.
state
=
4
3
self
.
state
=
4
5
self
.
_errHandler
.
sync
(
self
)
token
=
self
.
_input
.
LA
(
1
)
if
token
in
[
NFA_grammarParser
.
STATE
]:
self
.
state
=
3
4
self
.
state
=
3
6
self
.
statename
()
self
.
state
=
39
self
.
state
=
41
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
while
_la
==
NFA_grammarParser
.
COMMA
:
self
.
state
=
3
5
self
.
state
=
3
7
self
.
match
(
NFA_grammarParser
.
COMMA
)
self
.
state
=
3
6
self
.
state
=
3
8
self
.
statename
()
self
.
state
=
4
1
self
.
state
=
4
3
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
...
...
@@ -339,7 +350,7 @@ class NFA_grammarParser ( Parser ):
else
:
raise
NoViableAltException
(
self
)
self
.
state
=
4
5
self
.
state
=
4
7
self
.
match
(
NFA_grammarParser
.
RIGHT_BRACKET
)
except
RecognitionException
as
re
:
localctx
.
exception
=
re
...
...
@@ -386,11 +397,11 @@ class NFA_grammarParser ( Parser ):
self
.
enterRule
(
localctx
,
8
,
self
.
RULE_final
)
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
4
7
self
.
state
=
4
9
self
.
match
(
NFA_grammarParser
.
FINAL
)
self
.
state
=
48
self
.
state
=
50
self
.
match
(
NFA_grammarParser
.
EQUALS
)
self
.
state
=
49
self
.
state
=
51
self
.
stateset
()
except
RecognitionException
as
re
:
localctx
.
exception
=
re
...
...
@@ -430,7 +441,7 @@ class NFA_grammarParser ( Parser ):
self
.
enterRule
(
localctx
,
10
,
self
.
RULE_statename
)
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
5
1
self
.
state
=
5
3
self
.
match
(
NFA_grammarParser
.
STATE
)
except
RecognitionException
as
re
:
localctx
.
exception
=
re
...
...
fja_checker.py
View file @
c802d0ab
from
parser
import
Parser
from
parser
import
Parser
,
ParsingError
from
reg_automata
import
DFA
from
antlr4
import
RecognitionException
# type: ignore
import
sys
import
signal
def
transformation
(
solution
:
str
,
soluti
on_type
:
str
)
->
DFA
:
def
parse
(
string
:
str
,
automat
on_type
:
str
)
->
DFA
:
if
solution_type
in
{
"DFA"
,
"TOT"
}
:
try
:
parser
=
Parser
()
return
parser
.
str_to_dfa
(
solution
)
if
automaton_type
==
"DFA"
:
automaton
=
parser
.
str_to_dfa
(
string
)
elif
automaton_type
==
"NFA"
:
automaton
=
parser
.
str_to_nfa
(
string
).
determinize
()
elif
solution_type
==
"NFA"
:
parser
=
Parser
()
nfa
=
parser
.
str_to_nfa
(
solution
)
return
nfa
.
determinize
()
return
automaton
except
ParsingError
as
message
:
print
(
message
)
def
check_task
(
dfa
:
DFA
,
task
:
str
)
->
bool
:
if
task
==
"TOT"
and
not
dfa
.
is_total
():
print
(
"DFA není totální."
)
return
False
elif
task
==
"MIN"
and
not
dfa
.
is_minimal
():
print
(
"DFA není minimální."
)
return
False
elif
task
==
"CAN"
:
return
dfa
.
is_canonical
()
elif
task
==
"TOC"
:
return
dfa
.
is_total
()
and
dfa
.
is_canonical
()
elif
task
==
"MIC"
:
return
dfa
.
is_minimal
()
and
dfa
.
is_canonical
()
#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"
)
return
True
def
main
():
signal
.
alarm
(
60
)
parser
=
Parser
()
with
open
(
sys
.
argv
[
1
])
as
student_file
:
student_solution
=
student_file
.
read
()
...
...
@@ -33,25 +57,48 @@ def main():
if
argument
[:
2
]
==
"-o"
:
teacher_solution
=
argument
[
2
:]
task
,
teacher_solution
=
teacher_solution
.
split
(
":"
,
1
)
student_type
,
teacher_type
=
task
.
split
(
"-"
,
1
)
student_dfa
=
transformation
(
student_solution
,
student_type
)
teacher_dfa
=
transformation
(
teacher_solution
,
teacher_type
[:
3
])
task_prefix
,
teacher_solution
=
teacher_solution
.
split
(
":"
,
1
)
assert
len
(
task_prefix
)
>=
7
,
"Teachers solution could not be parsed correctly."
automata_type
,
task
,
_
=
task_prefix
.
split
(
"-"
,
2
)
assert
len
(
automata_type
)
==
3
and
len
(
task
)
==
3
,
"Teachers solution could not be parsed correctly."
student_dfa
=
parse
(
student_solution
,
automata_type
)
teacher_dfa
=
parse
(
teacher_solution
,
automata_type
)
try
:
parser
=
Parser
()
#
if
teacher_dfa
.
is_empty
()
and
student_dfa
.
is_empty
():
print
(
"Správné řešení."
)
exit
(
0
)
elif
student_dfa
.
characters
!=
teacher_dfa
.
characters
:
print
(
"Abecedy zadaného jazyka a studentova řešení se liší "
"(abeceda je odvozena ze všech písmen objevujících se v přechodové funkci)."
)
print
(
"Nesprávné řešení."
)
exit
(
1
)
result
=
student_dfa
.
is_equivalent
(
teacher_dfa
)
print
(
parser
.
dfa_to_str
(
teacher_dfa
))
if
result
:
if
result
and
check_task
(
student_dfa
,
task
):
print
(
"Správné řešení."
)
exit
(
0
)
el
se
:
el
if
not
result
:
student_word
,
teacher_word
=
result
.
left_counterexample
,
result
.
right_counterexample
print
(
"Hláška, že to není správně."
)
print
(
"Příklad slova, které je ve studentově řešení a není v zadaném jazyce: "
,
student_word
)
print
(
"Příklad slova, které chybí ve studentově řešení a je v zadaném jazyce: "
,
teacher_word
)
exit
(
1
)
except
RecognitionException
as
ex
:
print
(
ex
)
if
student_word
is
None
:
print
(
"Studentovo řešení je podmnožinou zadaného jazyka."
)
else
:
print
(
"Příklad slova, které je ve studentově řešení a není v zadaném jazyce: "
,
student_word
)
if
teacher_word
is
None
:
print
(
"Studentovo řešení je nadmnožinou zadaného jazyka."
)
else
:
print
(
"Příklad slova, které chybí ve studentově řešení a je v zadaném jazyce: "
,
teacher_word
)
print
(
"Nesprávné řešení."
)
exit
(
1
)
except
Exception
as
ex
:
exit
(
1
)
#print(ex)
main
()
\ No newline at end of file
parser.py
View file @
c802d0ab
...
...
@@ -10,6 +10,9 @@ from NFA_grammarLexer import NFA_grammarLexer
from
NFA_grammarParser
import
NFA_grammarParser
from
NFA_grammarListener
import
NFA_grammarListener
class
ParsingError
(
Exception
):
def
__init__
(
self
,
message
):
self
.
message
=
message
class
Parser
:
def
__init__
(
self
):
...
...
@@ -108,10 +111,16 @@ class Parser:
parser
=
DFA_grammarParser
(
tokens
)
tree
=
parser
.
start
()
print
er
=
DFA
Print
er
()
listen
er
=
DFA
Listen
er
()
walker
=
antlr4
.
ParseTreeWalker
()
walker
.
walk
(
printer
,
tree
)
dfa
=
DFA
(
printer
.
states
,
printer
.
characters
,
printer
.
transition
,
printer
.
init
,
printer
.
final
)
walker
.
walk
(
listener
,
tree
)
if
listener
.
init
is
None
:
listener
.
init
=
listener
.
first_state
if
listener
.
init
is
None
:
raise
ParsingError
(
"Automat musí obsahovat alespoň jeden stav."
)
dfa
=
DFA
(
listener
.
states
,
listener
.
characters
,
listener
.
transition
,
listener
.
init
,
listener
.
final
)
return
dfa
def
str_to_nfa
(
self
,
string
:
str
)
->
NFA
:
...
...
@@ -121,25 +130,33 @@ class Parser:
parser
=
NFA_grammarParser
(
tokens
)
tree
=
parser
.
start
()
print
er
=
NFA
Print
er
()
listen
er
=
NFA
Listen
er
()
walker
=
antlr4
.
ParseTreeWalker
()
walker
.
walk
(
printer
,
tree
)
nfa
=
NFA
(
printer
.
states
,
printer
.
characters
,
printer
.
transition
,
printer
.
init
,
printer
.
final
)
walker
.
walk
(
listener
,
tree
)
if
listener
.
init
is
None
:
listener
.
init
=
listener
.
first_state
if
listener
.
init
is
None
:
raise
ParsingError
(
"Automat musí obsahovat alespoň jeden stav."
)
nfa
=
NFA
(
listener
.
states
,
listener
.
characters
,
listener
.
transition
,
listener
.
init
,
listener
.
final
)
return
nfa
class
DFA
Print
er
(
DFA_grammarListener
):
class
DFA
Listen
er
(
DFA_grammarListener
):
def
__init__
(
self
):
self
.
states
=
set
()
self
.
characters
=
set
()
self
.
transition
=
{}
self
.
init
=
State
(
""
)
self
.
init
=
None
self
.
first_state
=
None
self
.
final
=
set
()
def
exitInit
(
self
,
ctx
):
state
=
State
(
str
(
ctx
.
statename
().
STATE
()))
self
.
init
=
state
self
.
states
.
add
(
state
)
if
ctx
.
statename
()
is
not
None
:
state
=
State
(
str
(
ctx
.
statename
().
STATE
()))
self
.
init
=
state
self
.
states
.
add
(
state
)
def
exitProduction
(
self
,
ctx
):
state
=
State
(
str
(
ctx
.
statename
(
0
).
STATE
()))
...
...
@@ -150,6 +167,9 @@ class DFAPrinter(DFA_grammarListener):
self
.
characters
.
add
(
character
)
self
.
transition
[
state
,
character
]
=
dest_state
if
self
.
first_state
is
None
:
self
.
first_state
=
state
def
exitFinal
(
self
,
ctx
):
i
=
0
while
ctx
.
statename
(
i
)
is
not
None
:
...
...
@@ -158,12 +178,13 @@ class DFAPrinter(DFA_grammarListener):
self
.
final
.
add
(
state
)
i
+=
1
class
NFA
Print
er
(
NFA_grammarListener
):
class
NFA
Listen
er
(
NFA_grammarListener
):
def
__init__
(
self
):
self
.
states
=
set
()
self
.
characters
=
set
()
self
.
transition
=
{}
self
.
init
=
State
(
""
)
self
.
init
=
None
self
.
first_state
=
None
self
.
final
=
set
()
def
exitInit
(
self
,
ctx
):
...
...
@@ -185,6 +206,9 @@ class NFAPrinter(NFA_grammarListener):
self
.
transition
[
state
,
character
].
add
(
dest_state
)
i
+=
1
if
self
.
first_state
is
None
:
self
.
first_state
=
state
def
exitFinal
(
self
,
ctx
):
i
=
0
while
ctx
.
stateset
().
statename
(
i
)
is
not
None
:
...
...
reg_automata.py
View file @
c802d0ab
...
...
@@ -422,21 +422,29 @@ class DFA:
return
self
.
complement
().
is_empty
()
# returns: True or (1. what IS in first language (self) and NOT in second (dfa), 2. analogically)
def
is_equivalent
(
self
,
dfa
:
DFA
)
->
bool
:
def
is_equivalent
(
self
,
dfa
:
DFA
)
->
IsEquivalentResult
:
left_empty
=
self
.
intersection
(
self
,
dfa
.
complement
()).
is_empty
()
right_empty
=
self
.
intersection
(
self
.
complement
(),
dfa
).
is_empty
()
if
left_empty
and
right_empty
:
result
=
IsEquivalentResult
()
else
:
result
=
IsEquivalentResult
(
left_empty
.
counterexample
,
right_empty
.
counterexample
)
return
result
def
is_part_identical
(
self
,
dfa
:
DFA
)
->
bool
:
return
self
.
states
==
dfa
.
states
and
self
.
characters
==
dfa
.
characters
and
\
self
.
transition
==
dfa
.
transition
and
self
.
init
==
dfa
.
init
and
\
self
.
final
==
dfa
.
final
def
is_minimal
(
self
)
->
bool
:
minimal
=
self
.
minimize
()
return
len
(
self
.
states
)
==
len
(
minimal
.
states
)
and
\