Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
28cbfc9d
Commit
28cbfc9d
authored
11 years ago
by
Jan Vesely
Browse files
Options
Downloads
Patches
Plain Diff
add precomputing of pop and push symbols
parent
dd66de43
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
adeterminize/src/idpda/IdpdaDeterminizer.cpp
+19
-8
19 additions, 8 deletions
adeterminize/src/idpda/IdpdaDeterminizer.cpp
adeterminize/src/idpda/IdpdaDeterminizer.h
+4
-2
4 additions, 2 deletions
adeterminize/src/idpda/IdpdaDeterminizer.h
with
23 additions
and
10 deletions
adeterminize/src/idpda/IdpdaDeterminizer.cpp
+
19
−
8
View file @
28cbfc9d
...
...
@@ -9,6 +9,21 @@ void IdpdaDeterminizer::initDeterminization()
Utils
::
copyInputAlphabet
(
*
this
->
nidpda
,
*
this
->
didpda
);
Utils
::
copyStackAlphabet
(
*
this
->
nidpda
,
*
this
->
didpda
);
this
->
states
.
clear
();
this
->
findPopAndPushSymbols
();
}
void
IdpdaDeterminizer
::
findPopAndPushSymbols
()
{
for
(
const
auto
&
symbol
:
this
->
nidpda
->
getInputAlphabet
())
{
for
(
const
auto
&
transition
:
this
->
nidpda
->
getTransitions
())
{
if
(
transition
.
getInput
()
==
symbol
)
{
this
->
popSymbols
[
symbol
]
=
transition
.
getPop
();
this
->
pushSymbols
[
symbol
]
=
transition
.
getPush
();
break
;
}
}
}
}
...
...
@@ -18,15 +33,12 @@ const State& IdpdaDeterminizer::getOrCreateState(const set<State>& originalState
}
set
<
State
>
IdpdaDeterminizer
::
findToStates
(
const
set
<
State
>&
nidpdaStates
,
const
Symbol
&
input
,
list
<
Symbol
>*
stackPop
,
list
<
Symbol
>*
stackPush
)
set
<
State
>
IdpdaDeterminizer
::
findToStates
(
const
set
<
State
>&
nidpdaStates
,
const
Symbol
&
input
)
{
set
<
State
>
targetStates
;
for
(
const
auto
&
state
:
nidpdaStates
)
{
for
(
const
auto
&
transition
:
this
->
nidpda
->
getTransitions
())
{
if
(
transition
.
getFrom
()
==
state
&&
transition
.
getInput
()
==
input
)
{
*
stackPop
=
transition
.
getPop
();
*
stackPush
=
transition
.
getPush
();
targetStates
.
insert
(
transition
.
getTo
());
}
}
...
...
@@ -68,10 +80,9 @@ Automaton* IdpdaDeterminizer::determinize()
}
for
(
const
auto
&
input
:
this
->
nidpda
->
getInputAlphabet
())
{
list
<
Symbol
>
stackPop
;
list
<
Symbol
>
stackPush
;
const
set
<
State
>&
nidpdaToStates
=
this
->
findToStates
(
unmarkedStateData
->
originalStates
,
input
,
&
stackPop
,
&
stackPush
);
list
<
Symbol
>
stackPop
=
this
->
popSymbols
[
input
];
list
<
Symbol
>
stackPush
=
this
->
pushSymbols
[
input
];
const
set
<
State
>&
nidpdaToStates
=
this
->
findToStates
(
unmarkedStateData
->
originalStates
,
input
);
if
(
nidpdaToStates
.
size
()
>
0
)
{
const
State
&
targetState
=
this
->
getOrCreateState
(
nidpdaToStates
);
TransitionPDA
transition
(
unmarkedStateData
->
state
,
input
,
targetState
,
stackPop
,
stackPush
);
...
...
This diff is collapsed.
Click to expand it.
adeterminize/src/idpda/IdpdaDeterminizer.h
+
4
−
2
View file @
28cbfc9d
...
...
@@ -29,11 +29,13 @@ class IdpdaDeterminizer : public Determinizer
PDA* nidpda;
PDA* didpda;
map<string, StateData> states;
map<Symbol, list<Symbol>> popSymbols;
map<Symbol, list<Symbol>> pushSymbols;
void initDeterminization();
void findPopAndPushSymbols();
const State& getOrCreateState(const set<State>& originalStates);
set<State> findToStates(const set<State>& nidpdaStates, const Symbol& input, list<Symbol>* stackPop,
list<Symbol>* stackPush);
set<State> findToStates(const set<State>& nidpdaStates, const Symbol& input);
public:
IdpdaDeterminizer(PDA* automaton);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment