From 52e33ea9619fb4c9f64452a3a9070d53c70fcba7 Mon Sep 17 00:00:00 2001 From: evandar <tomaspecka@gmail.com> Date: Mon, 11 Nov 2013 15:16:06 +0100 Subject: [PATCH] Fix: infinite cycle and type set membership test in alib grammar package --- alib/src/grammar/RightRegularGrammar.cpp | 2 +- alib/src/grammar/Rule.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/alib/src/grammar/RightRegularGrammar.cpp b/alib/src/grammar/RightRegularGrammar.cpp index e2c49a6b20..2f7b4c5c89 100644 --- a/alib/src/grammar/RightRegularGrammar.cpp +++ b/alib/src/grammar/RightRegularGrammar.cpp @@ -59,7 +59,7 @@ bool RightRegularGrammar::checkRightSide(const list<Symbol>& rightSide) const { //check if all symbols except the last are terminal symbols for (list<Symbol>::const_iterator symbol = rightSide.begin(); symbol != --rightSide.end(); symbol++) { - if (terminalSymbols.find(*symbol) != terminalSymbols.end()) { + if (terminalSymbols.find(*symbol) == terminalSymbols.end()) { return false; } } diff --git a/alib/src/grammar/Rule.cpp b/alib/src/grammar/Rule.cpp index 4d1af3ec69..0052bf55da 100644 --- a/alib/src/grammar/Rule.cpp +++ b/alib/src/grammar/Rule.cpp @@ -53,6 +53,7 @@ bool Rule::operator <(const Rule& other) const { if (*left != *otherLeft) { return *left < *otherLeft; } + left ++; } list<Symbol>::const_iterator right = rightSide.begin(); @@ -61,6 +62,7 @@ bool Rule::operator <(const Rule& other) const { if (*right != *otherRight) { return *right < *otherRight; } + right ++; } return false; -- GitLab