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
661fac22
Commit
661fac22
authored
Mar 24, 2022
by
Vladimír Štill
Browse files
lib: Change in set operations grammar
parent
a30ceb7d
Pipeline
#122025
passed with stage
in 1 minute and 25 seconds
Changes
5
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
lib/parser/SET.g4
View file @
661fac22
...
...
@@ -26,10 +26,12 @@ unop
parentheses: LEFT_PAR expr[0] RIGHT_PAR;
atom_set
: LEFT_BR ( |
symbol | symbol (COMMA symbol
) ) RIGHT_BR
: LEFT_BR ( |
word ( | COMMA word
) ) RIGHT_BR
| EMPTYSET
;
word : symbol+;
symbol : (ALPHABET | EPSILON | QUOTE anyvalue+ QUOTE);
comment: (HASH anyvalue* | );
...
...
lib/parser/SETListener.py
View file @
661fac22
...
...
@@ -62,6 +62,15 @@ class SETListener(ParseTreeListener):
pass
# Enter a parse tree produced by SETParser#word.
def
enterWord
(
self
,
ctx
:
SETParser
.
WordContext
):
pass
# Exit a parse tree produced by SETParser#word.
def
exitWord
(
self
,
ctx
:
SETParser
.
WordContext
):
pass
# Enter a parse tree produced by SETParser#symbol.
def
enterSymbol
(
self
,
ctx
:
SETParser
.
SymbolContext
):
pass
...
...
lib/parser/SETParser.py
View file @
661fac22
This diff is collapsed.
Click to expand it.
lib/parser/SETVisitor.py
View file @
661fac22
...
...
@@ -39,6 +39,11 @@ class SETVisitor(ParseTreeVisitor):
return
self
.
visitChildren
(
ctx
)
# Visit a parse tree produced by SETParser#word.
def
visitWord
(
self
,
ctx
:
SETParser
.
WordContext
):
return
self
.
visitChildren
(
ctx
)
# Visit a parse tree produced by SETParser#symbol.
def
visitSymbol
(
self
,
ctx
:
SETParser
.
SymbolContext
):
return
self
.
visitChildren
(
ctx
)
...
...
lib/parser/__init__.py
View file @
661fac22
...
...
@@ -76,7 +76,7 @@ def dfa_to_str(dfa: DFA, full: bool = False) -> str:
transition
+=
f
"(
{
state_1
.
name
}
,
{
character
.
name
}
)=
{
dest_state
.
name
}
"
init
=
f
"init=
{
dfa
.
init
.
name
}
"
final
=
f
"final=
{
_names_to_str
(
dfa
.
final
)
}
"
final
=
f
"final=
{
_names_to_str
(
sorted
(
dfa
.
final
)
)
}
"
# full - verbose description of DFA - only for development, dismiss later
if
full
:
...
...
@@ -123,7 +123,7 @@ def nfa_to_str(nfa: NFA, full: bool = False) -> str:
f
"
{
_names_to_str
(
dest_states
)
}
"
init
=
f
"init=
{
nfa
.
init
.
name
}
"
final
=
f
"final=
{
_names_to_str
(
nfa
.
final
)
}
"
final
=
f
"final=
{
_names_to_str
(
sorted
(
nfa
.
final
)
)
}
"
if
full
:
return
f
"NFA = (
{
_names_to_str
(
nfa
.
states
)
}
, "
\
...
...
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