aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2008-08-19 14:07:48 +0000
committerNicola Mettifogo2008-08-19 14:07:48 +0000
commit389575b5c1531801f3847c2f51da0ea89c893a12 (patch)
treef73f4b92aa7032f83acdb7111561de73f7f6d91d /engines
parentb7dce00942611cb84dd96a0e81fce6ddaea26ef5 (diff)
downloadscummvm-rg350-389575b5c1531801f3847c2f51da0ea89c893a12.tar.gz
scummvm-rg350-389575b5c1531801f3847c2f51da0ea89c893a12.tar.bz2
scummvm-rg350-389575b5c1531801f3847c2f51da0ea89c893a12.zip
Fixed bug in low-level parser. Block comments weren't interpreted correctly.
svn-id: r34038
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/parser.cpp30
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);