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
2fb0d5b0
Commit
2fb0d5b0
authored
Jul 19, 2020
by
Kateřina Sloupová
Browse files
add support for any value in quotation marks and tweak any values in comments
parent
aa6c3784
Changes
17
Hide whitespace changes
Inline
Side-by-side
demo.py
View file @
2fb0d5b0
...
...
@@ -346,7 +346,7 @@ def main():
grammar_test
(
"S'->a|aA''|\e;A''->a|bS'|<ab_0>''"
)
grammar_test
(
"S->a;
\n
S->aA;
\n
S->\e;
\n
A->a;
\n
A->bS;
\n
"
)
words
=
dfa_eq
(
"init=1 (1, a)=2 (2,a)=2 (1,b)=3 final={2,3}
$comment
#"
,
words
=
dfa_eq
(
"init=1 (1, a)=2 (2,a)=2 (1,b)=3 final={2,3} #
c
"
,
"init=A (A, a)=B (A,b)=C (C,b)=C final={B,C}"
)
print
(
words
.
right_counterexample
,
words
.
left_counterexample
,
words
.
inf
)
print
()
...
...
evalweb/web_checker.py
View file @
2fb0d5b0
...
...
@@ -115,7 +115,8 @@ class WebChecker:
task
=
self
.
task
,
student_string
=
self
.
student_string
)
except
ParsingError
as
ex
:
raise
ParsingError
(
ex
.
args
)
return
ex
.
args
#raise ParsingError(ex.args)
def
convert
(
self
,
student_type
):
...
...
@@ -143,7 +144,8 @@ class WebChecker:
return
parser
.
reggrammar_to_str
(
nfa
.
nfa_to_reggrammar
().
eliminate_useless
())
except
ParsingError
as
ex
:
raise
ParsingError
(
ex
.
args
)
return
ex
.
args
# raise ParsingError(ex.args)
except
Exception
as
ex
:
print
(
"Error inside of web checker:"
,
ex
.
args
)
...
...
@@ -151,7 +153,7 @@ class WebChecker:
def
relation
(
self
,
eq
:
bool
)
->
str
:
student
=
self
.
student
.
dfa
teacher
=
self
.
teacher
.
dfa
# language 0 on picture: complement of both
self
.
languages
[
0
]
=
self
.
language
((
reg
.
DFA
.
union
(
teacher
,
student
)).
complement
())
...
...
lib/parsing/CFG.g4
View file @
2fb0d5b0
...
...
@@ -8,7 +8,9 @@ onerule: nonterminal ARROW (rewrite DELIMITER)* rewrite;
rewrite: (term_or_nonterm+ | EPSILON);
term_or_nonterm: (TERMINAL | nonterminal);
term_or_nonterm: (terminal | nonterminal);
terminal: (TERMINAL | QUOTE anyvalue+ QUOTE);
nonterminal: (CAPS | (LEFT_ANGLE symbol+ RIGHT_ANGLE (APOSTROPHE*)) | (symbol APOSTROPHE+));
...
...
@@ -16,7 +18,7 @@ symbol: (TERMINAL | CAPS | UNDERSCORE);
comment: (HASH anyvalue* | );
anyvalue: LEFT_ANGLE | RIGHT_ANGLE | APOSTROPHE | UNDERSCORE | TERMINAL | CAPS | ARROW | EPSILON | DELIMITER | NEWLINE| ANYCHAR;
anyvalue: LEFT_ANGLE | RIGHT_ANGLE | APOSTROPHE | UNDERSCORE | TERMINAL | CAPS | ARROW | EPSILON | DELIMITER | NEWLINE| ANYCHAR
| HASH
;
/* Lexer Rules */
...
...
@@ -33,6 +35,7 @@ EPSILON : ('ε' | '\\''e');
DELIMITER : '|';
NEWLINE : ('\n' | ';' | ',');
HASH : '#';
QUOTE : '"';
/* Characters to be ignored */
WS : [ \r\t]+ -> skip ;
...
...
lib/parsing/CFGLexer.py
View file @
2fb0d5b0
...
...
@@ -8,30 +8,31 @@ import sys
def
serializedATN
():
with
StringIO
()
as
buf
:
buf
.
write
(
"
\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\
17
"
)
buf
.
write
(
"
B
\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7
"
)
buf
.
write
(
"
\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\
20
"
)
buf
.
write
(
"
F
\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7
"
)
buf
.
write
(
"
\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16
"
)
buf
.
write
(
"
\t\16\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7
"
)
buf
.
write
(
"
\3\b\3\b\3\b\5\b
-
\n\b\3\t\3\t\3\t\5\t\62\n\t\3\n\3\n\3
"
)
buf
.
write
(
"
\13\3\13\3\f\3\f\3\r\6\r
;
\n\r\r\r\16\r
<
\3\r\3\r\3\16\3
"
)
buf
.
write
(
"
\16\2\2\17\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25
"
)
buf
.
write
(
"
\f\27\r\31\16\33\17\3\2\6\4\2\62
;c|
\3\2
C
\\\5\2\f\f
..="
)
buf
.
write
(
"=
\5\2\13\13\17\17\"\"\2
D
\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3
"
)
buf
.
write
(
"
\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2
"
)
buf
.
write
(
"
\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2
"
)
buf
.
write
(
"
\2\31\3\2\2\2\2\33\3\2\2\2\3\35\3\2\2\2\5\37\3\2\2\2\7
"
)
buf
.
write
(
"!
\3\2\2\2\t
#
\3\2\2\2\13
%
\3\2\2\2\r\'\3\2\2\2\17
,
\3\2\2
"
)
buf
.
write
(
"
\2\21\61\3\2\2\2\23\63\3\2\2\2\25\65\3\2\2\2\27\67\3\2
"
)
buf
.
write
(
"
\2\2\31
:
\3\2\2\2\33
@
\3\2\2\2\35\36\7
>
\2\2\36\4\3\2\2\2
"
)
buf
.
write
(
"
\37
\7
@
\2\2
\6\3\2\2\2
!
\"\7
)
\2\2\"\b\3\2\2\2
#$
\7
a
\2\2
"
)
buf
.
write
(
"$
\n\3\2\2\2
%&
\t\2\2\2
&
\f\3\2\2\2\'
(
\t\3\2\2
(
\16\3\2\2
"
)
buf
.
write
(
"
\2
)-
\7\u2194\2\2
*+
\7
/
\2\2
+-
\7
@
\2\2
,)
\3\2\2\2
,*
\3\2\2\2
"
)
buf
.
write
(
"-
\20\3\2\2\2
.
\62\7\u03b7\2\2
/
\60\7
^
\2\2\60\62\7
g
\2\2\61
"
)
buf
.
write
(
".
\3\2\2\2\61
/
\3\2\2\2\62\22\3\2\2\2\63\64\7
~
\2\2\64\24
"
)
buf
.
write
(
"
\3\2\2\2\65\66\t\4\2\2\66\26\3\2\2\2\67
8
\7
%
\2\2
8
\30\3
"
)
buf
.
write
(
"
\2\2\2
9;
\t\5\2\2
:9
\3\2\2\2
;<
\3\2\2\2
<:
\3\2\2\2
<=
\3\2\2
"
)
buf
.
write
(
"
\2
=>
\3\2\2\2
>?
\b\r\2\2
?
\32\3\2\2\2
@A
\13\2\2\2
A
\34\3\2
"
)
buf
.
write
(
"
\2\2\6\2
,
\61
<
\3\b\2\2
"
)
buf
.
write
(
"
\t\16\4\17\t\17\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3
"
)
buf
.
write
(
"
\6\3\7\3\7\3\b\3\b\3\b\5\b
/
\n\b\3\t\3\t\3\t\5\t\64\n\t
"
)
buf
.
write
(
"
\3\n\3\n\3\13\3\13\3\f\3\f\3\r\3\r\3\16\6\16
?
\n\16\r\16
"
)
buf
.
write
(
"
\16\16
@
\3\16\3\16\3\17\3\17\2\2\20\3\3\5\4\7\5\t\6\13
"
)
buf
.
write
(
"
\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\3\2
"
)
buf
.
write
(
"
\6\4\2\62
;c|
\3\2
C
\\\5\2\f\f
..==
\5\2\13\13\17\17\"\"\2
"
)
buf
.
write
(
"H
\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13
"
)
buf
.
write
(
"
\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3
"
)
buf
.
write
(
"
\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2
"
)
buf
.
write
(
"
\2\2\2\35\3\2\2\2\3\37\3\2\2\2\5
!
\3\2\2\2\7
#
\3\2\2\2\t
"
)
buf
.
write
(
"%
\3\2\2\2\13\'\3\2\2\2\r
)
\3\2\2\2\17
.
\3\2\2\2\21\63\3
"
)
buf
.
write
(
"
\2\2\2\23\65\3\2\2\2\25\67\3\2\2\2\27
9
\3\2\2\2\31
;
\3\2
"
)
buf
.
write
(
"
\2\2\33
>
\3\2\2\2\35
D
\3\2\2\2\37
\7
>
\2\2
\4\3\2\2\2
!
\"
"
)
buf
.
write
(
"
\7
@
\2\2\"\6\3\2\2\2
#$
\7
)
\2\2
$
\b\3\2\2\2
%&
\7
a
\2\2
&
\n\3
"
)
buf
.
write
(
"
\2\2\2\'
(
\t\2\2\2
(
\f\3\2\2\2
)*
\t\3\2\2
*
\16\3\2\2\2
+/
\7
"
)
buf
.
write
(
"
\u2194\2\2
,-
\7
/
\2\2
-/
\7
@
\2\2
.+
\3\2\2\2
.,
\3\2\2\2
/
\20\3
"
)
buf
.
write
(
"
\2\2\2\60\64\7\u03b7\2\2\61\62\7
^
\2\2\62\64\7
g
\2\2\63
"
)
buf
.
write
(
"
\60\3\2\2\2\63\61\3\2\2\2\64\22\3\2\2\2\65\66\7
~
\2\2\66
"
)
buf
.
write
(
"
\24\3\2\2\2\67
8
\t\4\2\2
8
\26\3\2\2\2
9:
\7
%
\2\2
:
\30\3\2\2
"
)
buf
.
write
(
"
\2
;<
\7
$
\2\2
<
\32\3\2\2\2
=?
\t\5\2\2
>=
\3\2\2\2
?@
\3\2\2\2
"
)
buf
.
write
(
"@>
\3\2\2\2
@A
\3\2\2\2
AB
\3\2\2\2
BC
\b\16\2\2
C
\34\3\2\2\2
"
)
buf
.
write
(
"DE
\13\2\2\2
E
\36\3\2\2\2\6\2
.
\63
@
\3\b\2\2
"
)
return
buf
.
getvalue
()
...
...
@@ -52,24 +53,25 @@ class CFGLexer(Lexer):
DELIMITER
=
9
NEWLINE
=
10
HASH
=
11
WS
=
12
ANYCHAR
=
13
QUOTE
=
12
WS
=
13
ANYCHAR
=
14
channelNames
=
[
u
"DEFAULT_TOKEN_CHANNEL"
,
u
"HIDDEN"
]
modeNames
=
[
"DEFAULT_MODE"
]
literalNames
=
[
"<INVALID>"
,
"'<'"
,
"'>'"
,
"'''"
,
"'_'"
,
"'|'"
,
"'#'"
]
"'<'"
,
"'>'"
,
"'''"
,
"'_'"
,
"'|'"
,
"'#'"
,
"'
\"
'"
]
symbolicNames
=
[
"<INVALID>"
,
"LEFT_ANGLE"
,
"RIGHT_ANGLE"
,
"APOSTROPHE"
,
"UNDERSCORE"
,
"TERMINAL"
,
"CAPS"
,
"ARROW"
,
"EPSILON"
,
"DELIMITER"
,
"NEWLINE"
,
"HASH"
,
"WS"
,
"ANYCHAR"
]
"QUOTE"
,
"WS"
,
"ANYCHAR"
]
ruleNames
=
[
"LEFT_ANGLE"
,
"RIGHT_ANGLE"
,
"APOSTROPHE"
,
"UNDERSCORE"
,
"TERMINAL"
,
"CAPS"
,
"ARROW"
,
"EPSILON"
,
"DELIMITER"
,
"NEWLINE"
,
"HASH"
,
"WS"
,
"ANYCHAR"
]
"HASH"
,
"QUOTE"
,
"WS"
,
"ANYCHAR"
]
grammarFileName
=
"CFG.g4"
...
...
lib/parsing/CFGListener.py
View file @
2fb0d5b0
...
...
@@ -44,6 +44,15 @@ class CFGListener(ParseTreeListener):
pass
# Enter a parse tree produced by CFGParser#terminal.
def
enterTerminal
(
self
,
ctx
:
CFGParser
.
TerminalContext
):
pass
# Exit a parse tree produced by CFGParser#terminal.
def
exitTerminal
(
self
,
ctx
:
CFGParser
.
TerminalContext
):
pass
# Enter a parse tree produced by CFGParser#nonterminal.
def
enterNonterminal
(
self
,
ctx
:
CFGParser
.
NonterminalContext
):
pass
...
...
lib/parsing/CFGParser.py
View file @
2fb0d5b0
...
...
@@ -11,39 +11,43 @@ else:
def
serializedATN
():
with
StringIO
()
as
buf
:
buf
.
write
(
"
\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\17
"
)
buf
.
write
(
"e
\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b
"
)
buf
.
write
(
"
\t\b\4\t\t\t\3\2\3\2\6\2\25\n\2\r\2\16\2\26\7\2\31\n\2
"
)
buf
.
write
(
"
\f\2\16\2\34\13\2\3\2\3\2\6\2
\n\2\r\2\16\2
!
\3\2\5\2
%"
)
buf
.
write
(
"
\n\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\7\3
.
\n\3\f\3\16\3\61
"
)
buf
.
write
(
"
\13\3\3\3\3\3\3\4\6\4\66\n\4\r\4\16\4\67\3\4\5\4
;
\n\4
"
)
buf
.
write
(
"
\3\5\3\5\5\5
?
\n\5\3\6\3\6\3\6\6\6
D
\n\6\r\6\16\6
E
\3\6\3
"
)
buf
.
write
(
"
\6\7\6
J
\n\6\f\6\16\6
M
\13\6\3\6\3\6\6\6
Q
\n\6\r\6\16\6
R"
)
buf
.
write
(
"
\5\6
U
\n\6\3\7\3\7\3\b\3\b\7\b
[
\n\b\f\b\16\b
^
\13\b\3\b
"
)
buf
.
write
(
"
\5\b
a
\n\b\3\t\3\t\3\t\2\2\n\2\4\6\b\n\f\16\20\2\4\3\2
"
)
buf
.
write
(
"
\6\b\4\2\3\f\17\17\2
k
\2\32\3\2\2\2\4
(
\3\2\2\2\6
:
\3\2\2
"
)
buf
.
write
(
"
\2\b
>
\3\2\2\2\n
T
\3\2\2\2\f
V
\3\2\2\2\16
`
\3\2\2\2\20
b
\3
"
)
buf
.
write
(
"
\2\2\2\22\24\5\4\3\2\23\25\7\f\2\2\24\23\3\2\2\2\25\26
"
)
buf
.
write
(
"
\3\2\2\2\26\24\3\2\2\2\26\27\3\2\2\2\27\31\3\2\2\2\30
"
)
buf
.
write
(
"
\22\3\2\2\2\31\34\3\2\2\2\32\30\3\2\2\2\32\33\3\2\2\2
"
)
buf
.
write
(
"
\33\35\3\2\2\2\34\32\3\2\2\2\35
$
\5\4\3\2\36
\7\f\2\2\37
"
)
buf
.
write
(
"
\36\3\2\2\2
!
\3\2\2\2
!
\37\3\2\2\2
!
\"\3\2\2\2\"
%
\3\2\2
"
)
buf
.
write
(
"
\2
#%
\3\2\2\2
$
\37\3\2\2\2
$#
\3\2\2\2
%&
\3\2\2\2
&
\'\5\16\b
"
)
buf
.
write
(
"
\2\'\3\3\2\2\2
()
\5\n\6\2
)/
\7\t\2\2
*+
\5\6\4\2
+,
\7\13\2
"
)
buf
.
write
(
"
\2
,.
\3\2\2\2
-*
\3\2\2\2
.
\61\3\2\2\2
/-
\3\2\2\2
/
\60\3\2\2
"
)
buf
.
write
(
"
\2\60\62\3\2\2\2\61
/
\3\2\2\2\62\63\5\6\4\2\63\5\3\2\2
"
)
buf
.
write
(
"
\2\64\66\5\b\5\2\65\64\3\2\2\2\66\67\3\2\2\2\67\65\3\2
"
)
buf
.
write
(
"
\2\2\67
8
\3\2\2\2
8;
\3\2\2\2
9;
\7\n\2\2
:
\65\3\2\2\2
:9
\3\2
"
)
buf
.
write
(
"
\2\2
;
\7\3\2\2\2
<?
\7\7\2\2
=?
\5\n\6\2
><
\3\2\2\2
>=
\3\2\2
"
)
buf
.
write
(
"
\2
?
\t\3\2\2\2
@U
\7\b\2\2
AC
\7\3\2\2
BD
\5\f\7\2
CB
\3\2\2\2
"
)
buf
.
write
(
"DE
\3\2\2\2
EC
\3\2\2\2
EF
\3\2\2\2
FG
\3\2\2\2
GK
\7\4\2\2
HJ
\7
"
)
buf
.
write
(
"
\5\2\2
IH
\3\2\2\2
JM
\3\2\2\2
KI
\3\2\2\2
KL
\3\2\2\2
LU
\3\2\2
"
)
buf
.
write
(
"
\2
MK
\3\2\2\2
NP
\5\f\7\2
OQ
\7\5\2\2
PO
\3\2\2\2
QR
\3\2\2\2
R"
)
buf
.
write
(
"P
\3\2\2\2
RS
\3\2\2\2
SU
\3\2\2\2
T@
\3\2\2\2
TA
\3\2\2\2
TN
\3
"
)
buf
.
write
(
"
\2\2\2
U
\13\3\2\2\2
VW
\t\2\2\2
W
\r\3\2\2\2
X
\\\7\r\2\2
Y[
\5
"
)
buf
.
write
(
"
\20\t\2
ZY
\3\2\2\2
[^
\3\2\2\2\\
Z
\3\2\2\2\\
]
\3\2\2\2
]a
\3
"
)
buf
.
write
(
"
\2\2\2
^
\\\3\2\2\2
_a
\3\2\2\2
`X
\3\2\2\2
`_
\3\2\2\2
a
\17\3
"
)
buf
.
write
(
"
\2\2\2
bc
\t\3\2\2
c
\21\3\2\2\2\20\26\32
!$/
\67
:>EKRT
\\
`"
)
buf
.
write
(
"
\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\20
"
)
buf
.
write
(
"r
\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b
"
)
buf
.
write
(
"
\t\b\4\t\t\t\4\n\t\n\3\2\3\2\6\2\27\n\2\r\2\16\2\30\7
"
)
buf
.
write
(
"
\2\33\n\2\f\2\16\2\36\13\2\3\2\3\2\6\2\"\n\2\r\2\16\2
"
)
buf
.
write
(
"#
\3\2\5\2\'\n\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\7\3\60\n\3
"
)
buf
.
write
(
"
\f\3\16\3\63\13\3\3\3\3\3\3\4\6\4
8
\n\4\r\4\16\4
9
\3\4\5
"
)
buf
.
write
(
"
\4
=
\n\4\3\5\3\5\5\5
A
\n\5\3\6\3\6\3\6\6\6
F
\n\6\r\6\16\6
"
)
buf
.
write
(
"G
\3\6\3\6\5\6
L
\n\6\3\7\3\7\3\7\6\7
Q
\n\7\r\7\16\7
R
\3\7
"
)
buf
.
write
(
"
\3\7\7\7
W
\n\7\f\7\16\7
Z
\13\7\3\7\3\7\6\7
^
\n\7\r\7\16\7
"
)
buf
.
write
(
"_
\5\7
b
\n\7\3\b\3\b\3\t\3\t\7\t
h
\n\t\f\t\16\t
k
\13\t\3\t
"
)
buf
.
write
(
"
\5\t
n
\n\t\3\n\3\n\3\n\2\2\13\2\4\6\b\n\f\16\20\22\2\4
"
)
buf
.
write
(
"
\3\2\6\b\4\2\3\r\20\20\2
y
\2\34\3\2\2\2\4
*
\3\2\2\2\6
<
\3
"
)
buf
.
write
(
"
\2\2\2\b
@
\3\2\2\2\n
K
\3\2\2\2\f
a
\3\2\2\2\16
c
\3\2\2\2\20
"
)
buf
.
write
(
"m
\3\2\2\2\22
o
\3\2\2\2\24\26\5\4\3\2\25\27\7\f\2\2\26\25
"
)
buf
.
write
(
"
\3\2\2\2\27\30\3\2\2\2\30\26\3\2\2\2\30\31\3\2\2\2\31
"
)
buf
.
write
(
"
\33\3\2\2\2\32\24\3\2\2\2\33\36\3\2\2\2\34\32\3\2\2\2
"
)
buf
.
write
(
"
\34\35\3\2\2\2\35\37\3\2\2\2\36\34\3\2\2\2\37
&
\5\4\3\2
"
)
buf
.
write
(
"
\"\7\f\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
&!
\3\2\2\2
&%
\3\2\2\2\'
(
\3\2\2\2
("
)
buf
.
write
(
")
\5\20\t\2
)
\3\3\2\2\2
*+
\5\f\7\2
+
\61\7\t\2\2
,-
\5\6\4\2
"
)
buf
.
write
(
"-.
\7\13\2\2
.
\60\3\2\2\2
/,
\3\2\2\2\60\63\3\2\2\2\61
/
\3
"
)
buf
.
write
(
"
\2\2\2\61\62\3\2\2\2\62\64\3\2\2\2\63\61\3\2\2\2\64\65
"
)
buf
.
write
(
"
\5\6\4\2\65\5\3\2\2\2\66
8
\5\b\5\2\67\66\3\2\2\2
89
\3\2
"
)
buf
.
write
(
"
\2\2
9
\67\3\2\2\2
9:
\3\2\2\2
:=
\3\2\2\2
;=
\7\n\2\2
<
\67\3\2
"
)
buf
.
write
(
"
\2\2
<;
\3\2\2\2
=
\7\3\2\2\2
>A
\5\n\6\2
?A
\5\f\7\2
@>
\3\2\2
"
)
buf
.
write
(
"
\2
@?
\3\2\2\2
A
\t\3\2\2\2
BL
\7\7\2\2
CE
\7\16\2\2
DF
\5\22\n
"
)
buf
.
write
(
"
\2
ED
\3\2\2\2
FG
\3\2\2\2
GE
\3\2\2\2
GH
\3\2\2\2
HI
\3\2\2\2
I"
)
buf
.
write
(
"J
\7\16\2\2
JL
\3\2\2\2
KB
\3\2\2\2
KC
\3\2\2\2
L
\13\3\2\2\2
M"
)
buf
.
write
(
"b
\7\b\2\2
NP
\7\3\2\2
OQ
\5\16\b\2
PO
\3\2\2\2
QR
\3\2\2\2
RP
\3
"
)
buf
.
write
(
"
\2\2\2
RS
\3\2\2\2
ST
\3\2\2\2
TX
\7\4\2\2
UW
\7\5\2\2
VU
\3\2\2
"
)
buf
.
write
(
"
\2
WZ
\3\2\2\2
XV
\3\2\2\2
XY
\3\2\2\2
Yb
\3\2\2\2
ZX
\3\2\2\2
["
)
buf
.
write
(
"]
\5\16\b\2\\
^
\7\5\2\2
]
\\\3\2\2\2
^_
\3\2\2\2
_]
\3\2\2\2
_"
)
buf
.
write
(
"`
\3\2\2\2
`b
\3\2\2\2
aM
\3\2\2\2
aN
\3\2\2\2
a[
\3\2\2\2
b
\r\3
"
)
buf
.
write
(
"
\2\2\2
cd
\t\2\2\2
d
\17\3\2\2\2
ei
\7\r\2\2
fh
\5\22\n\2
gf
\3
"
)
buf
.
write
(
"
\2\2\2
hk
\3\2\2\2
ig
\3\2\2\2
ij
\3\2\2\2
jn
\3\2\2\2
ki
\3\2\2
"
)
buf
.
write
(
"
\2
ln
\3\2\2\2
me
\3\2\2\2
ml
\3\2\2\2
n
\21\3\2\2\2
op
\t\3\2\2
"
)
buf
.
write
(
"p
\23\3\2\2\2\22\30\34
#&
\61
9<@GKRX_aim"
)
return
buf
.
getvalue
()
...
...
@@ -59,23 +63,24 @@ class CFGParser ( Parser ):
literalNames
=
[
"<INVALID>"
,
"'<'"
,
"'>'"
,
"'''"
,
"'_'"
,
"<INVALID>"
,
"<INVALID>"
,
"<INVALID>"
,
"<INVALID>"
,
"'|'"
,
"<INVALID>"
,
"'#'"
]
"'#'"
,
"'
\"
'"
]
symbolicNames
=
[
"<INVALID>"
,
"LEFT_ANGLE"
,
"RIGHT_ANGLE"
,
"APOSTROPHE"
,
"UNDERSCORE"
,
"TERMINAL"
,
"CAPS"
,
"ARROW"
,
"EPSILON"
,
"DELIMITER"
,
"NEWLINE"
,
"HASH"
,
"WS"
,
"ANYCHAR"
]
"DELIMITER"
,
"NEWLINE"
,
"HASH"
,
"QUOTE"
,
"WS"
,
"ANYCHAR"
]
RULE_start
=
0
RULE_onerule
=
1
RULE_rewrite
=
2
RULE_term_or_nonterm
=
3
RULE_nonterminal
=
4
RULE_symbol
=
5
RULE_comment
=
6
RULE_anyvalue
=
7
RULE_terminal
=
4
RULE_nonterminal
=
5
RULE_symbol
=
6
RULE_comment
=
7
RULE_anyvalue
=
8
ruleNames
=
[
"start"
,
"onerule"
,
"rewrite"
,
"term_or_nonterm"
,
"
non
terminal"
,
"symbol"
,
"comment"
,
"anyvalue"
]
ruleNames
=
[
"start"
,
"onerule"
,
"rewrite"
,
"term_or_nonterm"
,
"terminal"
,
"nonterminal"
,
"symbol"
,
"comment"
,
"anyvalue"
]
EOF
=
Token
.
EOF
LEFT_ANGLE
=
1
...
...
@@ -89,8 +94,9 @@ class CFGParser ( Parser ):
DELIMITER
=
9
NEWLINE
=
10
HASH
=
11
WS
=
12
ANYCHAR
=
13
QUOTE
=
12
WS
=
13
ANYCHAR
=
14
def
__init__
(
self
,
input
:
TokenStream
,
output
:
TextIO
=
sys
.
stdout
):
super
().
__init__
(
input
,
output
)
...
...
@@ -145,42 +151,42 @@ class CFGParser ( Parser ):
self
.
_la
=
0
# Token type
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
2
4
self
.
state
=
2
6
self
.
_errHandler
.
sync
(
self
)
_alt
=
self
.
_interp
.
adaptivePredict
(
self
.
_input
,
1
,
self
.
_ctx
)
while
_alt
!=
2
and
_alt
!=
ATN
.
INVALID_ALT_NUMBER
:
if
_alt
==
1
:
self
.
state
=
1
6
self
.
state
=
1
8
self
.
onerule
()
self
.
state
=
18
self
.
state
=
20
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
while
True
:
self
.
state
=
1
7
self
.
state
=
1
9
self
.
match
(
CFGParser
.
NEWLINE
)
self
.
state
=
2
0
self
.
state
=
2
2
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
if
not
(
_la
==
CFGParser
.
NEWLINE
):
break
self
.
state
=
2
6
self
.
state
=
2
8
self
.
_errHandler
.
sync
(
self
)
_alt
=
self
.
_interp
.
adaptivePredict
(
self
.
_input
,
1
,
self
.
_ctx
)
self
.
state
=
2
7
self
.
state
=
2
9
self
.
onerule
()
self
.
state
=
3
4
self
.
state
=
3
6
self
.
_errHandler
.
sync
(
self
)
token
=
self
.
_input
.
LA
(
1
)
if
token
in
[
CFGParser
.
NEWLINE
]:
self
.
state
=
29
self
.
state
=
31
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
while
True
:
self
.
state
=
28
self
.
state
=
30
self
.
match
(
CFGParser
.
NEWLINE
)
self
.
state
=
3
1
self
.
state
=
3
3
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
if
not
(
_la
==
CFGParser
.
NEWLINE
):
...
...
@@ -192,7 +198,7 @@ class CFGParser ( Parser ):
else
:
raise
NoViableAltException
(
self
)
self
.
state
=
3
6
self
.
state
=
3
8
self
.
comment
()
except
RecognitionException
as
re
:
localctx
.
exception
=
re
...
...
@@ -249,24 +255,24 @@ class CFGParser ( Parser ):
self
.
enterRule
(
localctx
,
2
,
self
.
RULE_onerule
)
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
38
self
.
state
=
40
self
.
nonterminal
()
self
.
state
=
39
self
.
state
=
41
self
.
match
(
CFGParser
.
ARROW
)
self
.
state
=
4
5
self
.
state
=
4
7
self
.
_errHandler
.
sync
(
self
)
_alt
=
self
.
_interp
.
adaptivePredict
(
self
.
_input
,
4
,
self
.
_ctx
)
while
_alt
!=
2
and
_alt
!=
ATN
.
INVALID_ALT_NUMBER
:
if
_alt
==
1
:
self
.
state
=
4
0
self
.
state
=
4
2
self
.
rewrite
()
self
.
state
=
4
1
self
.
state
=
4
3
self
.
match
(
CFGParser
.
DELIMITER
)
self
.
state
=
4
7
self
.
state
=
4
9
self
.
_errHandler
.
sync
(
self
)
_alt
=
self
.
_interp
.
adaptivePredict
(
self
.
_input
,
4
,
self
.
_ctx
)
self
.
state
=
48
self
.
state
=
50
self
.
rewrite
()
except
RecognitionException
as
re
:
localctx
.
exception
=
re
...
...
@@ -314,25 +320,25 @@ class CFGParser ( Parser ):
self
.
_la
=
0
# Token type
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
5
6
self
.
state
=
5
8
self
.
_errHandler
.
sync
(
self
)
token
=
self
.
_input
.
LA
(
1
)
if
token
in
[
CFGParser
.
LEFT_ANGLE
,
CFGParser
.
UNDERSCORE
,
CFGParser
.
TERMINAL
,
CFGParser
.
CAPS
]:
self
.
state
=
5
1
if
token
in
[
CFGParser
.
LEFT_ANGLE
,
CFGParser
.
UNDERSCORE
,
CFGParser
.
TERMINAL
,
CFGParser
.
CAPS
,
CFGParser
.
QUOTE
]:
self
.
state
=
5
3
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
while
True
:
self
.
state
=
5
0
self
.
state
=
5
2
self
.
term_or_nonterm
()
self
.
state
=
5
3
self
.
state
=
5
5
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
if
not
((((
_la
)
&
~
0x3f
)
==
0
and
((
1
<<
_la
)
&
((
1
<<
CFGParser
.
LEFT_ANGLE
)
|
(
1
<<
CFGParser
.
UNDERSCORE
)
|
(
1
<<
CFGParser
.
TERMINAL
)
|
(
1
<<
CFGParser
.
CAPS
)))
!=
0
)):
if
not
((((
_la
)
&
~
0x3f
)
==
0
and
((
1
<<
_la
)
&
((
1
<<
CFGParser
.
LEFT_ANGLE
)
|
(
1
<<
CFGParser
.
UNDERSCORE
)
|
(
1
<<
CFGParser
.
TERMINAL
)
|
(
1
<<
CFGParser
.
CAPS
)
|
(
1
<<
CFGParser
.
QUOTE
)
))
!=
0
)):
break
pass
elif
token
in
[
CFGParser
.
EPSILON
]:
self
.
state
=
5
5
self
.
state
=
5
7
self
.
match
(
CFGParser
.
EPSILON
)
pass
else
:
...
...
@@ -353,8 +359,9 @@ class CFGParser ( Parser ):
super
().
__init__
(
parent
,
invokingState
)
self
.
parser
=
parser
def
TERMINAL
(
self
):
return
self
.
getToken
(
CFGParser
.
TERMINAL
,
0
)
def
terminal
(
self
):
return
self
.
getTypedRuleContext
(
CFGParser
.
TerminalContext
,
0
)
def
nonterminal
(
self
):
return
self
.
getTypedRuleContext
(
CFGParser
.
NonterminalContext
,
0
)
...
...
@@ -380,16 +387,16 @@ class CFGParser ( Parser ):
self
.
enterRule
(
localctx
,
6
,
self
.
RULE_term_or_nonterm
)
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
6
0
self
.
state
=
6
2
self
.
_errHandler
.
sync
(
self
)
la_
=
self
.
_interp
.
adaptivePredict
(
self
.
_input
,
7
,
self
.
_ctx
)
if
la_
==
1
:
self
.
state
=
58
self
.
match
(
CFGParser
.
TERMINAL
)
self
.
state
=
60
self
.
terminal
(
)
pass
elif
la_
==
2
:
self
.
state
=
59
self
.
state
=
61
self
.
nonterminal
()
pass
...
...
@@ -403,6 +410,86 @@ class CFGParser ( Parser ):
return
localctx
class
TerminalContext
(
ParserRuleContext
):
def
__init__
(
self
,
parser
,
parent
:
ParserRuleContext
=
None
,
invokingState
:
int
=-
1
):
super
().
__init__
(
parent
,
invokingState
)
self
.
parser
=
parser
def
TERMINAL
(
self
):
return
self
.
getToken
(
CFGParser
.
TERMINAL
,
0
)
def
QUOTE
(
self
,
i
:
int
=
None
):
if
i
is
None
:
return
self
.
getTokens
(
CFGParser
.
QUOTE
)
else
:
return
self
.
getToken
(
CFGParser
.
QUOTE
,
i
)
def
anyvalue
(
self
,
i
:
int
=
None
):
if
i
is
None
:
return
self
.
getTypedRuleContexts
(
CFGParser
.
AnyvalueContext
)
else
:
return
self
.
getTypedRuleContext
(
CFGParser
.
AnyvalueContext
,
i
)
def
getRuleIndex
(
self
):
return
CFGParser
.
RULE_terminal
def
enterRule
(
self
,
listener
:
ParseTreeListener
):
if
hasattr
(
listener
,
"enterTerminal"
):
listener
.
enterTerminal
(
self
)
def
exitRule
(
self
,
listener
:
ParseTreeListener
):
if
hasattr
(
listener
,
"exitTerminal"
):
listener
.
exitTerminal
(
self
)
def
terminal
(
self
):
localctx
=
CFGParser
.
TerminalContext
(
self
,
self
.
_ctx
,
self
.
state
)
self
.
enterRule
(
localctx
,
8
,
self
.
RULE_terminal
)
self
.
_la
=
0
# Token type
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
73
self
.
_errHandler
.
sync
(
self
)
token
=
self
.
_input
.
LA
(
1
)
if
token
in
[
CFGParser
.
TERMINAL
]:
self
.
state
=
64
self
.
match
(
CFGParser
.
TERMINAL
)
pass
elif
token
in
[
CFGParser
.
QUOTE
]:
self
.
state
=
65
self
.
match
(
CFGParser
.
QUOTE
)
self
.
state
=
67
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
while
True
:
self
.
state
=
66
self
.
anyvalue
()
self
.
state
=
69
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
if
not
((((
_la
)
&
~
0x3f
)
==
0
and
((
1
<<
_la
)
&
((
1
<<
CFGParser
.
LEFT_ANGLE
)
|
(
1
<<
CFGParser
.
RIGHT_ANGLE
)
|
(
1
<<
CFGParser
.
APOSTROPHE
)
|
(
1
<<
CFGParser
.
UNDERSCORE
)
|
(
1
<<
CFGParser
.
TERMINAL
)
|
(
1
<<
CFGParser
.
CAPS
)
|
(
1
<<
CFGParser
.
ARROW
)
|
(
1
<<
CFGParser
.
EPSILON
)
|
(
1
<<
CFGParser
.
DELIMITER
)
|
(
1
<<
CFGParser
.
NEWLINE
)
|
(
1
<<
CFGParser
.
HASH
)
|
(
1
<<
CFGParser
.
ANYCHAR
)))
!=
0
)):
break
self
.
state
=
71
self
.
match
(
CFGParser
.
QUOTE
)
pass
else
:
raise
NoViableAltException
(
self
)
except
RecognitionException
as
re
:
localctx
.
exception
=
re
self
.
_errHandler
.
reportError
(
self
,
re
)
self
.
_errHandler
.
recover
(
self
,
re
)
finally
:
self
.
exitRule
()
return
localctx
class
NonterminalContext
(
ParserRuleContext
):
def
__init__
(
self
,
parser
,
parent
:
ParserRuleContext
=
None
,
invokingState
:
int
=-
1
):
...
...
@@ -448,58 +535,58 @@ class CFGParser ( Parser ):
def
nonterminal
(
self
):
localctx
=
CFGParser
.
NonterminalContext
(
self
,
self
.
_ctx
,
self
.
state
)
self
.
enterRule
(
localctx
,
8
,
self
.
RULE_nonterminal
)
self
.
enterRule
(
localctx
,
10
,
self
.
RULE_nonterminal
)
self
.
_la
=
0
# Token type
try
:
self
.
enterOuterAlt
(
localctx
,
1
)
self
.
state
=
82
self
.
state
=
95
self
.
_errHandler
.
sync
(
self
)
la_
=
self
.
_interp
.
adaptivePredict
(
self
.
_input
,
1
1
,
self
.
_ctx
)
la_
=
self
.
_interp
.
adaptivePredict
(
self
.
_input
,
1
3
,
self
.
_ctx
)
if
la_
==
1
:
self
.
state
=
62
self
.
state
=
75
self
.
match
(
CFGParser
.
CAPS
)
pass
elif
la_
==
2
:
self
.
state
=
6
3
self
.
state
=
7
6
self
.
match
(
CFGParser
.
LEFT_ANGLE
)
self
.
state
=
65
self
.
state
=
78
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
while
True
:
self
.
state
=
64
self
.
state
=
77
self
.
symbol
()
self
.
state
=
67
self
.
state
=
80
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
if
not
((((
_la
)
&
~
0x3f
)
==
0
and
((
1
<<
_la
)
&
((
1
<<
CFGParser
.
UNDERSCORE
)
|
(
1
<<
CFGParser
.
TERMINAL
)
|
(
1
<<
CFGParser
.
CAPS
)))
!=
0
)):
break
self
.
state
=
69
self
.
state
=
82
self
.
match
(
CFGParser
.
RIGHT_ANGLE
)
self
.
state
=
73
self
.
state
=
86
self
.
_errHandler
.
sync
(
self
)
_la
=
self
.
_input
.
LA
(
1
)
while
_la
==
CFGParser
.
APOSTROPHE
:
self
.
state
=
70
self
.
state
=
83