diff options
author | Nicola Mettifogo | 2008-05-04 15:09:23 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2008-05-04 15:09:23 +0000 |
commit | 42953929067c30dcb7a72c1d4c7b26d85d626384 (patch) | |
tree | 145b13a0cb638948eacaba18bedc04e64c1f0d6f /engines/parallaction/parser.cpp | |
parent | a3794c5f378cbb76521ec82e6a3634908cadc42f (diff) | |
download | scummvm-rg350-42953929067c30dcb7a72c1d4c7b26d85d626384.tar.gz scummvm-rg350-42953929067c30dcb7a72c1d4c7b26d85d626384.tar.bz2 scummvm-rg350-42953929067c30dcb7a72c1d4c7b26d85d626384.zip |
Added new Parser class, which will gradually grow to include all parsing code from the engine class.
svn-id: r31865
Diffstat (limited to 'engines/parallaction/parser.cpp')
-rw-r--r-- | engines/parallaction/parser.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp index cc0a772b45..665da16636 100644 --- a/engines/parallaction/parser.cpp +++ b/engines/parallaction/parser.cpp @@ -209,4 +209,47 @@ uint16 Script::readLineToken(bool errorOnEOF) { return fillTokens(line); } + +void Parser::reset() { + _currentOpcodes = 0; + _currentStatements = 0; + _script = 0; +} + +void Parser::pushTables(OpcodeSet *opcodes, Table *statements) { + _opcodes.push(_currentOpcodes); + _statements.push(_currentStatements); + + _currentOpcodes = opcodes; + _currentStatements = statements; +} + +void Parser::popTables() { + assert(_opcodes.size() > 0); + + _currentOpcodes = _opcodes.pop(); + _currentStatements = _statements.pop(); +} + +void Parser::parseStatement() { + assert(_currentOpcodes != 0); + + _script->readLineToken(true); + _lookup = _currentStatements->lookup(_tokens[0]); + + debugC(9, kDebugParser, "parseStatement: %s (lookup = %i)", _tokens[0], _lookup); + + (*(*_currentOpcodes)[_lookup])(); +} + +void Parser::bind(Script *script) { + reset(); + _script = script; +} + +void Parser::unbind() { + reset(); +} + + } // namespace Parallaction |