aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2008-02-05 09:55:17 +0000
committerNicola Mettifogo2008-02-05 09:55:17 +0000
commit17fdd182b6727220329efec61fbeed2c6b3feb8d (patch)
tree140b2c5f142b86ca92e03e814773f0d3ee6306e8 /engines
parent265621de5899b149cfb1a5a39ce823371d11b749 (diff)
downloadscummvm-rg350-17fdd182b6727220329efec61fbeed2c6b3feb8d.tar.gz
scummvm-rg350-17fdd182b6727220329efec61fbeed2c6b3feb8d.tar.bz2
scummvm-rg350-17fdd182b6727220329efec61fbeed2c6b3feb8d.zip
Enhanced parser to handle multi-line comments in scripts.
svn-id: r30797
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/parser.cpp30
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);
}