diff options
-rw-r--r-- | engines/parallaction/parser.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp index 2d92635cd6..cc0a772b45 100644 --- a/engines/parallaction/parser.cpp +++ b/engines/parallaction/parser.cpp @@ -161,14 +161,31 @@ uint16 Script::fillTokens(char* line) { return i; } +bool isCommentLine(char *text) { + return text[0] == '#'; +} + +bool isStartOfCommentBlock(char *text) { + return (text[0] == '['); +} + +bool isEndOfCommentBlock(char *text) { + return (text[0] == ']'); +} + uint16 Script::readLineToken(bool errorOnEOF) { clearTokens(); + bool inBlockComment = false, inLineComment; + char buf[200]; char *line = NULL; do { + inLineComment = false; + line = readLine(buf, 200); + if (line == NULL) { if (errorOnEOF) error("unexpected end of file while parsing"); @@ -176,7 +193,18 @@ uint16 Script::readLineToken(bool errorOnEOF) { return 0; } line = Common::ltrim(line); - } while (strlen(line) == 0 || line[0] == '#'); + + if (isCommentLine(line)) { + inLineComment = true; + } else + if (isStartOfCommentBlock(line)) { + inBlockComment = true; + } else + if (isEndOfCommentBlock(line)) { + inBlockComment = false; + } + + } while (inLineComment || inBlockComment || strlen(line) == 0); return fillTokens(line); } |