From 7f7c27911f5428e5b5e2e425cb84e59ddbe2d73f Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Mon, 1 Dec 2014 10:37:59 +0100 Subject: [PATCH] modify make unique symbol --- alib2data/src/alphabet/Symbol.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/alib2data/src/alphabet/Symbol.cpp b/alib2data/src/alphabet/Symbol.cpp index 5ef6949175..4d8dae2132 100644 --- a/alib2data/src/alphabet/Symbol.cpp +++ b/alib2data/src/alphabet/Symbol.cpp @@ -6,7 +6,7 @@ */ #include "Symbol.h" -#include "../label/NextLabel.h" +#include "NextSymbol.h" #include "LabeledSymbol.h" #include <climits> #include "../exception/AlibException.h" @@ -14,17 +14,13 @@ namespace alphabet { alphabet::Symbol createUniqueSymbol(const alphabet::Symbol& base, const std::set<alphabet::Symbol>& terminalAlphabet, const std::set<alphabet::Symbol>& nonterminalAlphabet) { - label::NextLabel nextLabelCreator; + NextSymbol nextSymbolCreator; - if(alib::ObjectBase::typeId<LabeledSymbol>() != base.getData().selfTypeId()) - throw exception::AlibException("Could not create unique symbol with nonlabeled base symbol " + (std::string) base + "." ); - - label::Label nextLabel = static_cast<const alphabet::LabeledSymbol&>(base.getData()).getLabel(); + Symbol attempt = base; int i = 0; do { - nextLabel = nextLabelCreator.nextLabel(nextLabel); - alphabet::Symbol attempt = alphabet::Symbol(alphabet::LabeledSymbol(nextLabel)); + attempt = nextSymbolCreator.nextSymbol(attempt); if(terminalAlphabet.count(attempt) == 0 && nonterminalAlphabet.count(attempt) == 0) return attempt; } while(++i < INT_MAX); -- GitLab