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
720af47b
Commit
720af47b
authored
10 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
method to set initial set of symbols at once
parent
1cfff42f
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
alib2/src/automaton/PDA/PDA.cpp
+14
-3
14 additions, 3 deletions
alib2/src/automaton/PDA/PDA.cpp
alib2/src/automaton/PDA/PDA.h
+9
-1
9 additions, 1 deletion
alib2/src/automaton/PDA/PDA.h
with
23 additions
and
4 deletions
alib2/src/automaton/PDA/PDA.cpp
+
14
−
3
View file @
720af47b
...
...
@@ -139,7 +139,6 @@ const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>
}
void
PDA
::
addInitialSymbol
(
const
alphabet
::
Symbol
&
start
)
{
if
(
stackAlphabet
.
find
(
start
)
==
stackAlphabet
.
end
())
{
throw
AutomatonException
(
"Stack symbol
\"
"
+
start
.
getSymbol
()
+
"
\"
doesn't exist."
);
}
...
...
@@ -151,10 +150,22 @@ void PDA::addInitialSymbol(const alphabet::Symbol& start) {
}
void
PDA
::
removeInitialSymbol
(
const
alphabet
::
Symbol
&
start
)
{
if
(
this
->
initialSymbols
.
size
()
<=
1
)
throw
AutomatonException
(
"There must be at least one initial symbol"
);
int
removed
=
this
->
initialSymbols
.
erase
(
start
);
if
(
!
removed
)
{
if
(
!
removed
)
throw
AutomatonException
(
"Transition doesn't exist."
);
}
}
void
PDA
::
setInitialSymbols
(
const
std
::
set
<
alphabet
::
Symbol
>&
symbols
)
{
if
(
symbols
.
size
()
<
1
)
throw
AutomatonException
(
"There must be at least one initial symbol"
);
std
::
set
<
alphabet
::
Symbol
>
tmp
(
symbols
);
tmp
.
erase
(
this
->
stackAlphabet
.
begin
(),
this
->
stackAlphabet
.
end
());
if
(
tmp
.
size
()
!=
0
)
throw
AutomatonException
(
"Initial symbols not in stack alphabet"
);
this
->
initialSymbols
=
symbols
;
}
const
std
::
set
<
alphabet
::
Symbol
>&
PDA
::
getInitialSymbols
()
const
{
...
...
This diff is collapsed.
Click to expand it.
alib2/src/automaton/PDA/PDA.h
+
9
−
1
View file @
720af47b
...
...
@@ -97,9 +97,17 @@ public:
* Adds initial symbol. Initial symbols are symbols that are pushed
* to the stack when PDA is created.
* @param start new initial symbol
* @throws AutomatonException when symbol is not present in the s
tack alphabet or it is not present in the set
* @throws AutomatonException when symbol is not present in the s
et of initial symbols
*/
void removeInitialSymbol(const alphabet::Symbol& start);
/**
* Sets initial symbols. Initial symbols are symbols that are pushed
* to the stack when PDA is created.
* @param symbols new initial symbols
* @throws AutomatonException when any of symbols is not present in the stack alphabet
*/
void setInitialSymbols(const std::set<alphabet::Symbol>& symbols);
/**
* @return list of start symbols
...
...
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