aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/parser_br.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/parallaction/parser_br.cpp')
-rw-r--r--engines/parallaction/parser_br.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp
index 001906c2e5..5b44b47748 100644
--- a/engines/parallaction/parser_br.cpp
+++ b/engines/parallaction/parser_br.cpp
@@ -1058,9 +1058,7 @@ DECLARE_INSTRUCTION_PARSER(text) {
DECLARE_INSTRUCTION_PARSER(if_op) {
debugC(7, kDebugParser, "INSTRUCTION_PARSER(if_op) ");
-
- if (ctxt.openIf)
- error("cannot nest 'if' blocks");
+ beginIfStatement();
parseLValue(ctxt.inst->_opA, _tokens[1]);
parseRValue(ctxt.inst->_opB, _tokens[3]);
@@ -1075,20 +1073,27 @@ DECLARE_INSTRUCTION_PARSER(if_op) {
ctxt.inst->_index = INST_IFLT;
} else
error("unknown test operator '%s' in if-clause", _tokens[2]);
+}
- ctxt.openIf = ctxt.inst;
+void ProgramParser_br::beginIfStatement() {
+ if (_openIfStatement != -1)
+ error("cannot nest 'if' statements");
+ _openIfStatement = _currentInstruction;
}
+void ProgramParser_br::endIfStatement() {
+ if (_openIfStatement == -1)
+ error("unexpected 'endif' in script");
-DECLARE_INSTRUCTION_PARSER(endif) {
- debugC(7, kDebugParser, "INSTRUCTION_PARSER(endif) ");
+ _program->_instructions[_openIfStatement]->_endif = _currentInstruction;
+ _openIfStatement = -1;
+}
- if (!ctxt.openIf)
- error("unexpected 'endif'");
-// ctxt.openIf->_endif = ctxt.inst;
- ctxt.openIf = InstructionPtr();
+DECLARE_INSTRUCTION_PARSER(endif) {
+ debugC(7, kDebugParser, "INSTRUCTION_PARSER(endif) ");
+ endIfStatement();
ctxt.inst->_index = _parser->_lookup;
}
@@ -1142,6 +1147,11 @@ void ProgramParser_br::parseRValue(ScriptVar &v, const char *str) {
}
+void ProgramParser_br::parse(Script *script, ProgramPtr program) {
+ _openIfStatement = -1;
+ ProgramParser_ns::parse(script, program);
+}
+
void LocationParser_br::init() {