1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-26 07:06:48 +00:00

fixed round brackets parsing bug

This commit is contained in:
Marc Zinnschlag 2010-06-30 14:08:59 +02:00
parent ed92ffcf89
commit 73f9436ed9
2 changed files with 17 additions and 2 deletions

View file

@ -3,6 +3,7 @@
#include <stdexcept> #include <stdexcept>
#include <cassert> #include <cassert>
#include <algorithm>
#include "generator.hpp" #include "generator.hpp"
#include "scanner.hpp" #include "scanner.hpp"
@ -51,6 +52,11 @@ namespace Compiler
return mOperators[mOperators.size()-1]; return mOperators[mOperators.size()-1];
} }
bool ExprParser::isOpen() const
{
return std::find (mOperators.begin(), mOperators.end(), '(')!=mOperators.end();
}
void ExprParser::popOperator() void ExprParser::popOperator()
{ {
assert (!mOperators.empty()); assert (!mOperators.empty());
@ -292,11 +298,18 @@ namespace Compiler
} }
if (code==Scanner::S_close && !mNextOperand) if (code==Scanner::S_close && !mNextOperand)
{
if (isOpen())
{ {
close(); close();
return true; return true;
} }
mTokenLoc = loc;
scanner.putbackSpecial (code, loc);
return false;
}
if (!mNextOperand) if (!mNextOperand)
{ {
mTokenLoc = loc; mTokenLoc = loc;

View file

@ -30,6 +30,8 @@ namespace Compiler
char getOperator() const; char getOperator() const;
bool isOpen() const;
void popOperator(); void popOperator();
void popOperand(); void popOperand();