MOHAWK: Fix associativity of LBCode operators.
This commit is contained in:
parent
dd7b1399f3
commit
d7f50b925e
1 changed files with 47 additions and 48 deletions
|
@ -277,8 +277,7 @@ LBValue LBCode::runCode(byte terminator) {
|
|||
void LBCode::parseStatement() {
|
||||
parseComparisons();
|
||||
|
||||
if (_currToken != kTokenAnd && _currToken != kTokenOr)
|
||||
return;
|
||||
while (_currToken == kTokenAnd || _currToken == kTokenOr) {
|
||||
byte op = _currToken;
|
||||
if (op == kTokenAnd)
|
||||
debugN(" && ");
|
||||
|
@ -299,6 +298,7 @@ void LBCode::parseStatement() {
|
|||
debugN(" [--> %s]", result ? "true" : "false");
|
||||
_stack.push(result);
|
||||
}
|
||||
}
|
||||
|
||||
void LBCode::parseComparisons() {
|
||||
parseConcat();
|
||||
|
@ -365,9 +365,7 @@ void LBCode::parseComparisons() {
|
|||
void LBCode::parseConcat() {
|
||||
parseArithmetic1();
|
||||
|
||||
if (_currToken != kTokenConcat)
|
||||
return;
|
||||
|
||||
while (_currToken == kTokenConcat) {
|
||||
debugN(" & ");
|
||||
nextToken();
|
||||
parseArithmetic1();
|
||||
|
@ -378,13 +376,12 @@ void LBCode::parseConcat() {
|
|||
debugN(" [--> \"%s\"]", result.c_str());
|
||||
_stack.push(result);
|
||||
}
|
||||
}
|
||||
|
||||
void LBCode::parseArithmetic1() {
|
||||
parseArithmetic2();
|
||||
|
||||
if (_currToken != kTokenMinus && _currToken != kTokenPlus)
|
||||
return;
|
||||
|
||||
while (_currToken == kTokenMinus || _currToken == kTokenPlus) {
|
||||
byte op = _currToken;
|
||||
if (op == kTokenMinus)
|
||||
debugN(" - ");
|
||||
|
@ -402,8 +399,10 @@ void LBCode::parseArithmetic1() {
|
|||
result = val1.toInt() - val2.toInt();
|
||||
else
|
||||
result = val1.toInt() + val2.toInt();
|
||||
debugN(" [--> %d]", result.toInt());
|
||||
_stack.push(result);
|
||||
}
|
||||
}
|
||||
|
||||
void LBCode::parseArithmetic2() {
|
||||
// FIXME: other math operators
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue