diff options
author | Nicola Mettifogo | 2007-10-14 21:32:43 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-10-14 21:32:43 +0000 |
commit | 963e63d985a7ffe9c1ae8907470c764202e947fc (patch) | |
tree | 2a0684b6fbe028ce629961975bd4f519e913eb01 /engines/parallaction/parser.cpp | |
parent | 652069f1a639cac69d5c4fd87149f1f068251c38 (diff) | |
download | scummvm-rg350-963e63d985a7ffe9c1ae8907470c764202e947fc.tar.gz scummvm-rg350-963e63d985a7ffe9c1ae8907470c764202e947fc.tar.bz2 scummvm-rg350-963e63d985a7ffe9c1ae8907470c764202e947fc.zip |
Integrated low-level routines into the Script class, turning it into a self-contained parser for location, program and table scripts.
svn-id: r29221
Diffstat (limited to 'engines/parallaction/parser.cpp')
-rw-r--r-- | engines/parallaction/parser.cpp | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp index 70e43babba..c3f4e50cc1 100644 --- a/engines/parallaction/parser.cpp +++ b/engines/parallaction/parser.cpp @@ -30,7 +30,7 @@ namespace Parallaction { char _tokens[20][40]; -Script::Script(Common::SeekableReadStream *input, bool disposeSource) : _input(input), _disposeSource(disposeSource) { +Script::Script(Common::ReadStream *input, bool disposeSource) : _input(input), _disposeSource(disposeSource), _line(0) { } Script::~Script() { @@ -50,6 +50,8 @@ char *Script::readLine(char *buf, size_t bufSize) { if (!_input->eos() && _si < bufSize) buf[_si] = v2; } + _line++; + if (_si == 0 && _input->eos()) return 0; @@ -60,27 +62,9 @@ char *Script::readLine(char *buf, size_t bufSize) { } -uint32 Script::read(void *dataPtr, uint32 dataSize) { - error("binary read not supported on Script streams"); -} -bool Script::eos() const { - error("EoS not supported on Script streams"); -} - -uint32 Script::pos() const { - error("position not supported on Script streams"); -} - -uint32 Script::size() const { - error("can't get size of Script streams"); -} - -void Script::seek(int32 offset, int whence) { - error("seek not supported on Script streams"); -} -void clearTokens() { +void Script::clearTokens() { for (uint16 i = 0; i < 20; i++) _tokens[i][0] = '\0'; @@ -89,10 +73,10 @@ void clearTokens() { } -void skip(Script* script, const char* endToken) { +void Script::skip(const char* endToken) { while (scumm_stricmp(_tokens[0], endToken)) { - fillBuffers(*script, true); + readLineToken(true); } } @@ -165,7 +149,7 @@ char *parseNextToken(char *s, char *tok, uint16 count, const char *brk, bool ign } -uint16 fillTokens(char* line) { +uint16 Script::fillTokens(char* line) { uint16 i = 0; while (strlen(line) > 0 && i < 20) { @@ -177,14 +161,14 @@ uint16 fillTokens(char* line) { return i; } -uint16 fillBuffers(Common::SeekableReadStream &stream, bool errorOnEOF) { +uint16 Script::readLineToken(bool errorOnEOF) { clearTokens(); char buf[200]; char *line = NULL; do { - line = stream.readLine(buf, 200); + line = readLine(buf, 200); if (line == NULL) { if (errorOnEOF) error("unexpected end of file while parsing"); |