added bracket parsing

actorid
Marc Zinnschlag 15 years ago
parent 48f6ad0f89
commit c8c5ef5467

@ -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)

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

Loading…
Cancel
Save