diff options
author | Alyssa Milburn | 2011-12-01 23:51:52 +0100 |
---|---|---|
committer | Alyssa Milburn | 2011-12-01 23:51:52 +0100 |
commit | d015a37e00b5c3c1ca03ee04bd523730cd5ace05 (patch) | |
tree | 4c1a9741788faaca9bfbd4cd0a6314fe42c03f5e | |
parent | ec8d8207202d74ebb78ec52720bf8ae70ae2afd4 (diff) | |
download | scummvm-rg350-d015a37e00b5c3c1ca03ee04bd523730cd5ace05.tar.gz scummvm-rg350-d015a37e00b5c3c1ca03ee04bd523730cd5ace05.tar.bz2 scummvm-rg350-d015a37e00b5c3c1ca03ee04bd523730cd5ace05.zip |
MOHAWK: Fix parameterless calls when parsing LB scripts.
-rw-r--r-- | engines/mohawk/livingbooks_code.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp index 836ad8ce6d..be4173f67d 100644 --- a/engines/mohawk/livingbooks_code.cpp +++ b/engines/mohawk/livingbooks_code.cpp @@ -682,7 +682,7 @@ Common::Array<LBValue> LBCode::readParams() { byte numParams = _data[_currOffset++]; if (!numParams) { - debugN("()\n"); + debugN("()"); nextToken(); return params; } @@ -1486,6 +1486,8 @@ uint LBCode::parseCode(const Common::String &source) { break; // open bracket case '(': + bool parameterless; + parameterless = false; if (wasFunction) { // function call parameters wasFunction = false; @@ -1501,6 +1503,7 @@ uint LBCode::parseCode(const Common::String &source) { continue; if (source[i] != ')') break; + parameterless = true; code[code.size() - 1] = 0; break; } @@ -1508,14 +1511,20 @@ uint LBCode::parseCode(const Common::String &source) { // brackets around expression counterPositions.push_back(0); } - code.push_back(kTokenOpenBracket); + if (!parameterless) + code.push_back(kTokenOpenBracket); break; // close bracket case ')': if (counterPositions.empty()) error("while parsing script '%s', encountered unmatched )", source.c_str()); + + // don't push a kTokenCloseBracket for a parameterless function call + uint counterPos2; + counterPos2 = counterPositions.back(); + if (!counterPos2 || code[counterPos2]) + code.push_back(kTokenCloseBracket); counterPositions.pop_back(); - code.push_back(kTokenCloseBracket); break; // comma (seperating function params) case ',': |