From 73f9436ed963433665d2b14dd602f471478bbbcb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 30 Jun 2010 14:08:59 +0200 Subject: [PATCH] fixed round brackets parsing bug --- components/compiler/exprparser.cpp | 17 +++++++++++++++-- components/compiler/exprparser.hpp | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index e780fdd31..e2b68f70f 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "generator.hpp" #include "scanner.hpp" @@ -51,6 +52,11 @@ namespace Compiler return mOperators[mOperators.size()-1]; } + bool ExprParser::isOpen() const + { + return std::find (mOperators.begin(), mOperators.end(), '(')!=mOperators.end(); + } + void ExprParser::popOperator() { assert (!mOperators.empty()); @@ -293,8 +299,15 @@ namespace Compiler if (code==Scanner::S_close && !mNextOperand) { - close(); - return true; + if (isOpen()) + { + close(); + return true; + } + + mTokenLoc = loc; + scanner.putbackSpecial (code, loc); + return false; } if (!mNextOperand) diff --git a/components/compiler/exprparser.hpp b/components/compiler/exprparser.hpp index 14c530010..47b2151bb 100644 --- a/components/compiler/exprparser.hpp +++ b/components/compiler/exprparser.hpp @@ -30,6 +30,8 @@ namespace Compiler char getOperator() const; + bool isOpen() const; + void popOperator(); void popOperand();