diff options
-rw-r--r-- | engines/parallaction/parser.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp index 8e30a631e4..7a893ca958 100644 --- a/engines/parallaction/parser.cpp +++ b/engines/parallaction/parser.cpp @@ -183,14 +183,14 @@ uint16 Script::readLineToken(bool errorOnEOF) { clearTokens(); - bool inBlockComment = false, inLineComment; + bool inBlockComment = false; char buf[200]; char *line = NULL; + char *start; do { - inLineComment = false; - line = readLine(buf, 200); + printf("read line: %s\n", line); if (line == NULL) { if (errorOnEOF) @@ -198,21 +198,27 @@ uint16 Script::readLineToken(bool errorOnEOF) { else return 0; } - line = Common::ltrim(line); + start = Common::ltrim(line); - if (isCommentLine(line)) { - inLineComment = true; + if (isCommentLine(start)) { + // ignore this line + start[0] = '\0'; } else - if (isStartOfCommentBlock(line)) { + if (isStartOfCommentBlock(start)) { + // mark this and the following lines as comment inBlockComment = true; } else - if (isEndOfCommentBlock(line)) { + if (isEndOfCommentBlock(start)) { + // comment is finished, so stop ignoring inBlockComment = false; + // the current line must be skipped, though, + // as it contains the end-of-comment marker + start[0] = '\0'; } - } while (inLineComment || inBlockComment || strlen(line) == 0); + } while (inBlockComment || strlen(start) == 0); - return fillTokens(line); + return fillTokens(start); } @@ -403,7 +409,9 @@ void PreProcessor::preprocessScript(Script &script, StatementList &list) { break; StatementDef *def = findDef(_tokens[0]); - assert(def); + if (!def) { + error("PreProcessor::preprocessScript: unknown statement '%s' found\n", _tokens[0]); + } text = def->makeLine(script); int score = getDefScore(def); |