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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Oct 14 22:59:46 CEST 2007


Revision: 29220
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29220&view=rev
Author:   peres001
Date:     2007-10-14 13:59:46 -0700 (Sun, 14 Oct 2007)

Log Message:
-----------
Made location parser more fault-tolerant, in that it prints out a warning message instead of exiting ScummVM when it encounters an unexpected keywords in the scripts.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parser_br.cpp
    scummvm/trunk/engines/parallaction/parser_ns.cpp
    scummvm/trunk/engines/parallaction/staticres.cpp

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-10-14 18:44:50 UTC (rev 29219)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-10-14 20:59:46 UTC (rev 29220)
@@ -723,7 +723,8 @@
 		int numZones;
 	} _locParseCtxt;
 
-	DECLARE_UNQUALIFIED_LOCATION_PARSER(invalid);
+	void warning_unexpected();
+
 	DECLARE_UNQUALIFIED_LOCATION_PARSER(endlocation);
 	DECLARE_UNQUALIFIED_LOCATION_PARSER(location);
 	DECLARE_UNQUALIFIED_LOCATION_PARSER(disk);
@@ -738,8 +739,6 @@
 	DECLARE_UNQUALIFIED_LOCATION_PARSER(endcomment);
 	DECLARE_UNQUALIFIED_LOCATION_PARSER(sound);
 	DECLARE_UNQUALIFIED_LOCATION_PARSER(music);
-	DECLARE_UNQUALIFIED_LOCATION_PARSER(redundant);
-	DECLARE_UNQUALIFIED_ZONE_PARSER(invalid);
 	DECLARE_UNQUALIFIED_ZONE_PARSER(limits);
 	DECLARE_UNQUALIFIED_ZONE_PARSER(moveto);
 	DECLARE_UNQUALIFIED_ZONE_PARSER(type);
@@ -748,7 +747,6 @@
 	DECLARE_UNQUALIFIED_ZONE_PARSER(flags);
 	DECLARE_UNQUALIFIED_ZONE_PARSER(endzone);
 	DECLARE_UNQUALIFIED_ZONE_PARSER(null);
-	DECLARE_UNQUALIFIED_ANIM_PARSER(invalid);
 	DECLARE_UNQUALIFIED_ANIM_PARSER(script);
 	DECLARE_UNQUALIFIED_ANIM_PARSER(commands);
 	DECLARE_UNQUALIFIED_ANIM_PARSER(type);
@@ -758,7 +756,6 @@
 	DECLARE_UNQUALIFIED_ANIM_PARSER(position);
 	DECLARE_UNQUALIFIED_ANIM_PARSER(moveto);
 	DECLARE_UNQUALIFIED_ANIM_PARSER(endanimation);
-	DECLARE_UNQUALIFIED_COMMAND_PARSER(invalid);
 	DECLARE_UNQUALIFIED_COMMAND_PARSER(flags);
 	DECLARE_UNQUALIFIED_COMMAND_PARSER(animation);
 	DECLARE_UNQUALIFIED_COMMAND_PARSER(zone);

Modified: scummvm/trunk/engines/parallaction/parser_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_br.cpp	2007-10-14 18:44:50 UTC (rev 29219)
+++ scummvm/trunk/engines/parallaction/parser_br.cpp	2007-10-14 20:59:46 UTC (rev 29220)
@@ -784,6 +784,8 @@
 #define LOCATION_PARSER(sig) 	OpcodeV2(this, &Parallaction_br::locParse_##sig)
 #define COMMAND_PARSER(sig) 	OpcodeV2(this, &Parallaction_br::cmdParse_##sig)
 
+#define WARNING_PARSER(sig)		OpcodeV2(this, &Parallaction_br::warning_##sig)
+
 void Parallaction_br::initParsers() {
 
 	static const OpcodeV2 op0[] = {
@@ -827,7 +829,7 @@
 
 
 	static const OpcodeV2 op2[] = {
-		COMMAND_PARSER(invalid),
+		WARNING_PARSER(unexpected),
 		COMMAND_PARSER(flags),		// set
 		COMMAND_PARSER(flags),		// clear
 		COMMAND_PARSER(animation),	// start
@@ -853,8 +855,8 @@
 		COMMAND_PARSER(math),		// inc
 		COMMAND_PARSER(math),		// dec
 		COMMAND_PARSER(test),		// test
-		COMMAND_PARSER(invalid),
-		COMMAND_PARSER(invalid),
+		WARNING_PARSER(unexpected),
+		WARNING_PARSER(unexpected),
 		COMMAND_PARSER(math),		// let
 		COMMAND_PARSER(music),
 		COMMAND_PARSER(zone),		// fix
@@ -865,7 +867,7 @@
 		COMMAND_PARSER(give),
 		COMMAND_PARSER(text),
 		COMMAND_PARSER(unary),		// part
-		COMMAND_PARSER(invalid),
+		WARNING_PARSER(unexpected),
 		COMMAND_PARSER(simple),		// return
 		COMMAND_PARSER(simple),		// onsave
 		COMMAND_PARSER(simple),		// offsave
@@ -878,7 +880,7 @@
 		_commandParsers.push_back(&op2[i]);
 
 	static const OpcodeV2 op4[] = {
-		LOCATION_PARSER(invalid),
+		WARNING_PARSER(unexpected),
 		LOCATION_PARSER(character),
 		LOCATION_PARSER(endlocation),
 		LOCATION_PARSER(ifchar),
@@ -899,14 +901,13 @@
 		LOCATION_PARSER(zeta),
 		LOCATION_PARSER(music),
 		LOCATION_PARSER(sound)
-//		LOCATION_PARSER(redundant)	// for redundant endanimation
 	};
 
 	for (i = 0; i < ARRAYSIZE(op4); i++)
 		_locationParsers.push_back(&op4[i]);
 
 	static const OpcodeV2 op5[] = {
-		ZONE_PARSER(invalid),
+		WARNING_PARSER(unexpected),
 		ZONE_PARSER(endzone),
 		ZONE_PARSER(limits),
 		ZONE_PARSER(moveto),
@@ -920,7 +921,7 @@
 		_locationZoneParsers.push_back(&op5[i]);
 
 	static const OpcodeV2 op6[] = {
-		ANIM_PARSER(invalid),
+		WARNING_PARSER(unexpected),
 		ANIM_PARSER(endanimation),
 		ANIM_PARSER(endanimation),		// endzone
 		ANIM_PARSER(script),

Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp	2007-10-14 18:44:50 UTC (rev 29219)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp	2007-10-14 20:59:46 UTC (rev 29220)
@@ -74,12 +74,8 @@
 #define DECLARE_LOCATION_PARSER(sig) void Parallaction_ns::locParse_##sig()
 
 
-
-
-DECLARE_ANIM_PARSER(invalid)  {
-	debugC(7, kDebugParser, "ANIM_PARSER(invalid) ");
-
-	error("unknown statement '%s' in animation %s", _tokens[0], _locParseCtxt.a->_label._text);
+void Parallaction_ns::warning_unexpected() {
+	warning("unexpected keyword '%s'", _tokens[0]);
 }
 
 
@@ -590,12 +586,6 @@
 	addCommand();
 }
 
-DECLARE_COMMAND_PARSER(invalid)  {
-	debugC(7, kDebugParser, "COMMAND_PARSER(invalid) ");
-
-	error("Can't parse unknown command '%s'", _tokens[0]);
-}
-
 DECLARE_COMMAND_PARSER(endcommands)  {
 	debugC(7, kDebugParser, "COMMAND_PARSER(endcommands) ");
 
@@ -822,12 +812,6 @@
 }
 
 
-DECLARE_LOCATION_PARSER(invalid)  {
-	debugC(7, kDebugParser, "LOCATION_PARSER(invalid) ");
-
-	error("unknown keyword '%s' in location '%s'", _tokens[0], _locParseCtxt.filename);
-}
-
 DECLARE_LOCATION_PARSER(endlocation)  {
 	debugC(7, kDebugParser, "LOCATION_PARSER(endlocation) ");
 
@@ -967,13 +951,7 @@
 		_soundMan->setMusicFile(_tokens[1]);
 }
 
-DECLARE_LOCATION_PARSER(redundant)  {
-	debugC(7, kDebugParser, "LOCATION_PARSER(redundant) ");
 
-	warning("redundant '%s' line found in script '%s'", _tokens[0], _locParseCtxt.filename);
-}
-
-
 void Parallaction_ns::parseLocation(const char *filename) {
     debugC(1, kDebugParser, "parseLocation('%s')", filename);
 
@@ -1050,6 +1028,8 @@
 #define LOCATION_PARSER(sig) 	OpcodeV1(this, &Parallaction_ns::locParse_##sig)
 #define COMMAND_PARSER(sig) 	OpcodeV1(this, &Parallaction_ns::cmdParse_##sig)
 
+#define WARNING_PARSER(sig)		OpcodeV1(this, &Parallaction_br::warning_##sig)
+
 void Parallaction_ns::initParsers() {
 
 	static const OpcodeV1 op0[] = {
@@ -1081,7 +1061,7 @@
 
 
 	static const OpcodeV1 op2[] = {
-		COMMAND_PARSER(invalid),
+		WARNING_PARSER(unexpected),
 		COMMAND_PARSER(flags),			// set
 		COMMAND_PARSER(flags),			// clear
 		COMMAND_PARSER(animation),		// start
@@ -1107,7 +1087,7 @@
 
 
 	static const OpcodeV1 op4[] = {
-		LOCATION_PARSER(invalid),
+		WARNING_PARSER(unexpected),
 		LOCATION_PARSER(endlocation),
 		LOCATION_PARSER(location),
 		LOCATION_PARSER(disk),
@@ -1121,30 +1101,28 @@
 		LOCATION_PARSER(comment),
 		LOCATION_PARSER(endcomment),
 		LOCATION_PARSER(sound),
-		LOCATION_PARSER(music),
-		LOCATION_PARSER(redundant)	// for redundant endanimation
+		LOCATION_PARSER(music)
 	};
 
 	for (i = 0; i < ARRAYSIZE(op4); i++)
 		_locationParsers.push_back(&op4[i]);
 
 	static const OpcodeV1 op5[] = {
-		ZONE_PARSER(invalid),
+		WARNING_PARSER(unexpected),
 		ZONE_PARSER(limits),
 		ZONE_PARSER(moveto),
 		ZONE_PARSER(type),
 		ZONE_PARSER(commands),
 		ZONE_PARSER(label),
 		ZONE_PARSER(flags),
-		ZONE_PARSER(endzone),
-		ZONE_PARSER(null)
+		ZONE_PARSER(endzone)
 	};
 
 	for (i = 0; i < ARRAYSIZE(op5); i++)
 		_locationZoneParsers.push_back(&op5[i]);
 
 	static const OpcodeV1 op6[] = {
-		ANIM_PARSER(invalid),
+		WARNING_PARSER(unexpected),
 		ANIM_PARSER(script),
 		ANIM_PARSER(commands),
 		ANIM_PARSER(type),
@@ -1196,12 +1174,6 @@
 }
 
 
-DECLARE_ZONE_PARSER(invalid)  {
-	debugC(7, kDebugParser, "ZONE_PARSER(invalid) ");
-
-	error("unknown statement '%s' in zone %s", _tokens[0], _locParseCtxt.z->_label._text);
-}
-
 DECLARE_ZONE_PARSER(endzone)  {
 	debugC(7, kDebugParser, "ZONE_PARSER(endzone) ");
 

Modified: scummvm/trunk/engines/parallaction/staticres.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/staticres.cpp	2007-10-14 18:44:50 UTC (rev 29219)
+++ scummvm/trunk/engines/parallaction/staticres.cpp	2007-10-14 20:59:46 UTC (rev 29220)
@@ -332,8 +332,7 @@
 	"comment",
 	"endcomment",
 	"sound",
-	"music",
-	"endanimation"
+	"music"
 };
 
 const char *_locationZoneStmtRes_ns[] = {
@@ -343,8 +342,7 @@
 	"commands",
 	"label",
 	"flags",
-	"endzone",
-	"endcommands"		// this to prevent unexpected statements in the scripts to crash the parser
+	"endzone"
 };
 
 const char *_locationAnimStmtRes_ns[] = {


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