1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 03:54:40 +00:00

added bracket parsing

This commit is contained in:
Marc Zinnschlag 2010-06-29 16:24:54 +02:00
parent 48f6ad0f89
commit c8c5ef5467
2 changed files with 27 additions and 0 deletions

View File

@ -14,6 +14,10 @@ namespace Compiler
{
switch (op)
{
case '(':
return 0;
case '+':
case '-':
@ -143,6 +147,14 @@ namespace Compiler
mNextOperand = true;
}
void ExprParser::close()
{
while (getOperator()!='(')
pop();
popOperator();
}
ExprParser::ExprParser (ErrorHandler& errorHandler, Context& context, Locals& locals,
Literals& literals)
: Parser (errorHandler, context), mLocals (locals), mLiterals (literals),
@ -209,6 +221,19 @@ namespace Compiler
return true;
}
if (code==Scanner::S_open && mNextOperand)
{
mOperators.push_back ('(');
mTokenLoc = loc;
return true;
}
if (code==Scanner::S_close && !mNextOperand)
{
close();
return true;
}
mTokenLoc = loc;
switch (code)

View File

@ -43,6 +43,8 @@ namespace Compiler
void pushBinaryOperator (char c);
void close();
public:
ExprParser (ErrorHandler& errorHandler, Context& context, Locals& locals,