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

modify make unique symbol

parent 14578991
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
   
#include "Symbol.h" #include "Symbol.h"
#include "../label/NextLabel.h" #include "NextSymbol.h"
#include "LabeledSymbol.h" #include "LabeledSymbol.h"
#include <climits> #include <climits>
#include "../exception/AlibException.h" #include "../exception/AlibException.h"
...@@ -14,17 +14,13 @@ ...@@ -14,17 +14,13 @@
namespace alphabet { namespace alphabet {
   
alphabet::Symbol createUniqueSymbol(const alphabet::Symbol& base, const std::set<alphabet::Symbol>& terminalAlphabet, const std::set<alphabet::Symbol>& nonterminalAlphabet) { 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()) Symbol attempt = base;
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();
   
int i = 0; int i = 0;
do { do {
nextLabel = nextLabelCreator.nextLabel(nextLabel); attempt = nextSymbolCreator.nextSymbol(attempt);
alphabet::Symbol attempt = alphabet::Symbol(alphabet::LabeledSymbol(nextLabel));
if(terminalAlphabet.count(attempt) == 0 && nonterminalAlphabet.count(attempt) == 0) if(terminalAlphabet.count(attempt) == 0 && nonterminalAlphabet.count(attempt) == 0)
return attempt; return attempt;
} while(++i < INT_MAX); } 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