Skip to content
Snippets Groups Projects
Commit 3c112153 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

fix inifinte loop

parent 04660dc6
No related branches found
No related tags found
No related merge requests found
......@@ -93,9 +93,11 @@ alphabet::Symbol Symbol::createUniqueSymbol(const alphabet::Symbol& base, const
if(baseSymbol == NULL)
throw exception::AlibException("Could not create unique symbol with nonlabeled base symbol " + (std::string) base.getSymbol() + "." );
 
label::Label nextLabel = baseSymbol->getLabel();
int i = 0;
do {
label::Label nextLabel = nextLabelCreator.nextLabel(baseSymbol->getLabel());
nextLabel = nextLabelCreator.nextLabel(nextLabel);
alphabet::Symbol attempt = alphabet::Symbol(alphabet::LabeledSymbol(nextLabel));
if(terminalAlphabet.count(attempt) == 0 && nonterminalAlphabet.count(attempt) == 0)
return attempt;
......
......@@ -80,9 +80,11 @@ std::ostream& operator<<(std::ostream& os, const Automaton& automaton) {
State Automaton::createUniqueState(const State& base, const std::set<State>& other) {
label::NextLabel nextLabelCreator;
 
label::Label nextLabel = base.getName();
int i = 0;
do {
label::Label nextLabel = nextLabelCreator.nextLabel(base.getName());
nextLabel = nextLabelCreator.nextLabel(nextLabel);
if(other.count(State(nextLabel)) == 0)
return State(nextLabel);
} while(++i < INT_MAX);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment