mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-13 11:39:47 +00:00
added bracket parsing
This commit is contained in:
parent
48f6ad0f89
commit
c8c5ef5467
2 changed files with 27 additions and 0 deletions
components/compiler
|
@ -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…
Reference in a new issue