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
161a397d
Commit
161a397d
authored
Mar 05, 2022
by
Vladimír Štill
Browse files
lib: Determinise string representation of {D,N}FA
parent
597b1e4e
Pipeline
#113846
passed with stage
in 1 minute and 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/parser/__init__.py
View file @
161a397d
...
...
@@ -71,7 +71,7 @@ def _unquote(txt: str) -> str:
def
dfa_to_str
(
dfa
:
DFA
,
full
:
bool
=
False
)
->
str
:
transition
=
""
for
key
,
dest_state
in
dfa
.
transition
.
items
():
for
key
,
dest_state
in
sorted
(
dfa
.
transition
.
items
()
)
:
state_1
,
character
=
key
transition
+=
f
"(
{
state_1
.
name
}
,
{
character
.
name
}
)=
{
dest_state
.
name
}
"
...
...
@@ -116,7 +116,7 @@ def cfg_to_str(gra: CFG, full: bool = False) -> str:
def
nfa_to_str
(
nfa
:
NFA
,
full
:
bool
=
False
)
->
str
:
transition
=
""
for
key
,
set_states
in
nfa
.
transition
.
items
():
for
key
,
set_states
in
sorted
(
nfa
.
transition
.
items
()
)
:
state
,
character
=
key
dest_states
=
nfa
.
transition
[
state
,
character
]
transition
+=
f
"(
{
state
.
name
}
,
{
character
.
name
}
)="
\
...
...
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