EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=621)
-   -   diff - parse errors (https://www.eqemulator.org/forums/showthread.php?t=10179)

Eglin 11-11-2003 12:45 PM

diff - parse errors
 
Small patch to include filenames in script parse error reports.

Code:

--- ./parser.h        Tue Nov 11 12:44:58 2003
+++ ../../../pristine-11-10/NewSource/zone/parser.h        Sun Nov  9 13:15:16 2003
@@ -84,7 +84,7 @@
 
        int                numtok(std::string text, const char * character);
 
-        int                ParseCommands(std::string text, int line, int justcheck, int32 npcid, Mob* other, Mob* mob, std::string filename = string("none"));
+        int                ParseCommands(std::string text, int line, int justcheck, int32 npcid, Mob* other, Mob* mob);
        int                ParseIf(std::string text);
        int                pcalc(char * string);
        void    ParseVars(std::string& text, int32 npcid, Mob* mob);
--- ./parser.cpp        Tue Nov 11 13:04:17 2003
+++ ../../../pristine-11-10/NewSource/zone/parser.cpp        Sun Nov  9 13:15:05 2003
@@ -956,7 +956,7 @@
                                if (bracket == 0)
                                {
                                buffer.replace(buffer.length()-1,buffer.length(),"");
-                                int heh = ParseCommands(buffer,line_num,0,0,0,0, filename);
+                                int heh = ParseCommands(buffer,line_num,0,0,0,0);
                                if (!heh) return 0;
                                event1->command = buffer;
                                buffer="";
@@ -964,7 +964,7 @@
                                }
                                if (bracket==-1)
                                {       
-                                        printf("Line: %d, File: %s | error C0006: syntax error : too many ')'s\n",line_num,filename.c_str());
+                                        printf("Line: %d | error C0006: syntax error : too many ')'s\n",line_num);
                                        return 0;
                                }
                        }
@@ -1401,7 +1401,7 @@
        return 1;
 }
 
-int Parser::ParseCommands(string text, int line, int justcheck, int32 npcid, Mob* other, Mob* mob, std::string filename)
+int Parser::ParseCommands(string text, int line, int justcheck, int32 npcid, Mob* other, Mob* mob)
 {
        string buffer,command,parms,temp,temp2;
        temp2 = text;
@@ -1431,7 +1431,7 @@
                        {
                                if (last_finished)
                                {
-                                        printf("Line: %d, File: %s | error C0008: syntax error : missing ';' before function '%s'\n", line, command.c_str(), filename.c_str());
+                                        printf("Line: %d | error C0008: syntax error : missing ';' before function '%s'\n", line, command.c_str());
                                        return 0;
                                }
                                command = buffer;
@@ -1439,7 +1439,7 @@
                                argnums = GetArgs(command);
                                if (argnums == -1)
                                {
-                                        printf("Line: %d, File: %s | error C0007: '%s' : Unknown function\n", line, command.c_str(), filename.c_str());
+                                        printf("Line: %d | error C0007: '%s' : Unknown function\n", line, command.c_str());
                                        return 0;
                                }
                        }
@@ -1459,7 +1459,7 @@
                        }
                        if (paren<0)
                        {
-                                printf("Line: %d, File: %s | error C0006: syntax error : too many ')'s\n",line, filename.c_str());
+                                printf("Line: %d | error C0006: syntax error : too many ')'s\n",line);
                                return 0;
                        }
                }                       
@@ -1479,12 +1479,12 @@
                        bracket--;
                        if (last_finished)
                        {
-                                printf("Line: %d, File: %s | error C0008: syntax error : missing ';' before '}'\n", line, filename.c_str());
+                                printf("Line: %d | error C0008: syntax error : missing ';' before '}'\n", line);
                                return 0;
                        }
                        if (bracket<0)
                        {
-                                printf("Line: %d, File: %s | error C0006: syntax error : too many '}'s\n",line, filename.c_str());
+                                printf("Line: %d | error C0006: syntax error : too many '}'s\n",line);
                                return 0;
                        }
                        if (bracket == 0)
@@ -1501,7 +1501,7 @@
                                last_finished=0;
                                if (argnums != 1 && argnums!=argit)
                                {
-                                        printf("Line: %d, File: %s | error C0001: '%s' : function does not take %d parameter(s)\n", line, command.c_str(), argit, filename.c_str());
+                                        printf("Line: %d | error C0001: '%s' : function does not take %d parameter(s)\n", line, command.c_str(), argit);
                                        return 0;
                                }
                                if (!justcheck)
@@ -1509,7 +1509,7 @@
                                argit=1;
                        }
                        else {
-                                printf("Line: %d, File: %s | error C0002: '%s' :syntax error : '(' %d '('s still not closed.\n", line, command.c_str(), paren, filename.c_str());
+                                printf("Line: %d | error C0002: '%s' :syntax error : '(' %d '('s still not closed.\n", line, command.c_str(), paren);
                                }
                }
                if (escape) escape--;
@@ -1517,7 +1517,7 @@
        }
        if (last_finished)
        {
-                printf("Line: %d, File: %s | error C0008: syntax error : missing ';' before '}'\n", line, filename.c_str());
+                printf("Line: %d | error C0008: syntax error : missing ';' before '}'\n", line);
                return 0;
        }
        return 1;


kathgar 11-11-2003 09:09 PM

That diff was confusing me for a little whie, you took the differences between you editted copy to the CVS copy. Not really big since we would manually merge it anyways. Other than that keep up the good work and i'll talk tot he maintainer of parser.cpp

Trumpcard 11-11-2003 10:54 PM

Smart change, identify the filename where the error is occuring..

Appreciate the change, in the future can you also attatch a .patch file (you know, diff old.txt new.txt > oldnew.patch )

You can use the output from the boards, but the spacing gets annoying to correct.. patch can be pretty finiky..

Thanks again!

Trumpcard 11-12-2003 09:45 AM

I merged this in, but you made quit a few mistakes in placement of the filename.c_str() 's.

You added them onto the end of all the printf's, even when they were not the last parameter in there.


All times are GMT -4. The time now is 03:57 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.