[Scummvm-cvs-logs] SF.net SVN: scummvm: [30797] scummvm/trunk/engines/parallaction/parser.cpp

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Feb 5 10:55:17 CET 2008


Revision: 30797
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30797&view=rev
Author:   peres001
Date:     2008-02-05 01:55:17 -0800 (Tue, 05 Feb 2008)

Log Message:
-----------
Enhanced parser to handle multi-line comments in scripts.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/parser.cpp

Modified: scummvm/trunk/engines/parallaction/parser.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser.cpp	2008-02-05 09:30:58 UTC (rev 30796)
+++ scummvm/trunk/engines/parallaction/parser.cpp	2008-02-05 09:55:17 UTC (rev 30797)
@@ -161,14 +161,31 @@
 	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,8 +193,19 @@
 				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);
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list