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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Aug 19 16:07:49 CEST 2008


Revision: 34038
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34038&view=rev
Author:   peres001
Date:     2008-08-19 14:07:48 +0000 (Tue, 19 Aug 2008)

Log Message:
-----------
Fixed bug in low-level parser. Block comments weren't interpreted correctly.

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

Modified: scummvm/trunk/engines/parallaction/parser.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser.cpp	2008-08-19 13:11:42 UTC (rev 34037)
+++ scummvm/trunk/engines/parallaction/parser.cpp	2008-08-19 14:07:48 UTC (rev 34038)
@@ -183,14 +183,14 @@
 
 	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 @@
 			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 @@
 			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);


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