Alexandre Julliard : widl: Change the prefix on bison-generated names to avoid the name-prefix directive .

Alexandre Julliard julliard at wine.codeweavers.com
Tue Sep 12 07:30:07 CDT 2006


Module: wine
Branch: master
Commit: 86bb809e5b65e566151747d38f96d69ee1abd8ef
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=86bb809e5b65e566151747d38f96d69ee1abd8ef

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Sep 12 09:05:07 2006 +0200

widl: Change the prefix on bison-generated names to avoid the name-prefix directive.

---

 tools/widl/header.c |    4 ++--
 tools/widl/parser.h |   10 +++++-----
 tools/widl/parser.l |   30 +++++++++++++++---------------
 tools/widl/parser.y |    2 --
 tools/widl/proxy.c  |    2 +-
 tools/widl/utils.c  |    8 ++++----
 tools/widl/utils.h  |    4 ++--
 tools/widl/widl.c   |   12 ++++++------
 8 files changed, 35 insertions(+), 37 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index 168f4c6..5415785 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -716,7 +716,7 @@ static void write_method_proto(const typ
         fprintf(header, ");\n");
       }
       else {
-        yywarning("invalid call_as attribute (%s -> %s)\n", get_name(def), cas->name);
+        parser_warning("invalid call_as attribute (%s -> %s)\n", get_name(def), cas->name);
       }
     }
 
@@ -802,7 +802,7 @@ static void write_coclass_guid(type_t *c
 static void write_com_interface(type_t *iface)
 {
   if (!iface->funcs && !iface->ref) {
-    yywarning("%s has no methods", iface->name);
+    parser_warning("%s has no methods", iface->name);
     return;
   }
 
diff --git a/tools/widl/parser.h b/tools/widl/parser.h
index 2217dbf..5baf655 100644
--- a/tools/widl/parser.h
+++ b/tools/widl/parser.h
@@ -21,14 +21,14 @@
 #ifndef __WIDL_PARSER_H
 #define __WIDL_PARSER_H
 
-int yyparse(void);
+int parser_parse(void);
 
-extern FILE *yyin;
-extern char *yytext;
-extern int yydebug;
+extern FILE *parser_in;
+extern char *parser_text;
+extern int parser_debug;
 extern int yy_flex_debug;
 
-int yylex(void);
+int parser_lex(void);
 
 extern int import_stack_ptr;
 int do_import(char *fname);
diff --git a/tools/widl/parser.l b/tools/widl/parser.l
index 4fedd34..21faf7b 100644
--- a/tools/widl/parser.l
+++ b/tools/widl/parser.l
@@ -20,7 +20,7 @@
 
 %option stack
 %option nounput noyy_top_state
-%option 8bit never-interactive
+%option 8bit never-interactive prefix="parser_"
 
 nl	\r?\n
 ws	[ \f\t\r]
@@ -110,14 +110,14 @@ static UUID* parse_uuid(const char*u)
                             yy_pop_state();
                             lineno = (int)strtol(yytext, &cptr, 10);
                             if(!lineno)
-                                yyerror("Malformed '#...' line-directive; invalid linenumber");
+                                parser_error("Malformed '#...' line-directive; invalid linenumber");
                             fname = strchr(cptr, '"');
                             if(!fname)
-                                yyerror("Malformed '#...' line-directive; missing filename");
+                                parser_error("Malformed '#...' line-directive; missing filename");
                             fname++;
                             cptr = strchr(fname, '"');
                             if(!cptr)
-                                yyerror("Malformed '#...' line-directive; missing terminating \"");
+                                parser_error("Malformed '#...' line-directive; missing terminating \"");
                             *cptr = '\0';
                             line_number = lineno - 1;  /* We didn't read the newline */
                             free( input_name );
@@ -126,7 +126,7 @@ static UUID* parse_uuid(const char*u)
 \"			yy_push_state(QUOTE); cbufidx = 0;
 <QUOTE>\"		{
 				yy_pop_state();
-				yylval.str = get_buffered_cstring();
+				parser_lval.str = get_buffered_cstring();
 				return aSTRING;
 			}
 <QUOTE>\\\\		|
@@ -134,15 +134,15 @@ static UUID* parse_uuid(const char*u)
 <QUOTE>\\.		addcchar('\\'); addcchar(yytext[1]);
 <QUOTE>.		addcchar(yytext[0]);
 {uuid}			{
-				yylval.uuid = parse_uuid(yytext);
+				parser_lval.uuid = parse_uuid(yytext);
 				return aUUID;
 			}
 {hex}			{
-				yylval.num = strtoul(yytext, NULL, 0);
+				parser_lval.num = strtoul(yytext, NULL, 0);
 				return aHEXNUM;
 			}
 {int}			{
-				yylval.num = strtoul(yytext, NULL, 0);
+				parser_lval.num = strtoul(yytext, NULL, 0);
 				return aNUM;
 			}
 SAFEARRAY{ws}*/\(	return tSAFEARRAY;
@@ -161,8 +161,8 @@ SAFEARRAY{ws}*/\(	return tSAFEARRAY;
 			}
 %%
 
-#ifndef yywrap
-int yywrap(void)
+#ifndef parser_wrap
+int parser_wrap(void)
 {
 	return 1;
 }
@@ -338,10 +338,10 @@ #else
 	}
 #endif
 	if (kwp) {
-		yylval.str = (char*)kwp->kw;
+		parser_lval.str = (char*)kwp->kw;
 		return kwp->token;
 	}
-	yylval.str = xstrdup(kw);
+	parser_lval.str = xstrdup(kw);
 	return is_type(kw) ? aKNOWNTYPE : aIDENTIFIER;
 }
 
@@ -352,7 +352,7 @@ static void addcchar(char c)
 		cbufalloc += 1024;
 		cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
 		if(cbufalloc > 65536)
-			yywarning("Reallocating string buffer larger than 64kB");
+			parser_warning("Reallocating string buffer larger than 64kB");
 	}
 	cbuffer[cbufidx++] = c;
 }
@@ -414,7 +414,7 @@ int do_import(char *fname)
 	first_import = import;
 
         if (!(path = wpp_find_include( fname, input_name )))
-            yyerror("Unable to open include file %s", fname);
+            parser_error("Unable to open include file %s", fname);
 
 	import_stack[ptr].temp_name = temp_name;
 	import_stack[ptr].input_name = input_name;
@@ -427,7 +427,7 @@ int do_import(char *fname)
         if (ret) exit(1);
 
 	if((f = fopen(temp_name, "r")) == NULL)
-		yyerror("Unable to open %s", temp_name);
+		parser_error("Unable to open %s", temp_name);
 
 	import_stack[ptr].state = YY_CURRENT_BUFFER;
 	yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 922df4d..63e4c6d 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -126,8 +126,6 @@ #define tsUNION  3
 	unsigned int num;
 }
 
-%name-prefix="yy"
-
 %token <str> aIDENTIFIER
 %token <str> aKNOWNTYPE
 %token <num> aNUM aHEXNUM
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index 8d4d467..3480b7d 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -936,7 +936,7 @@ static void write_proxy(type_t *iface)
       gen_proxy(iface, cur, idx);
       gen_stub(iface, cur, cname);
       if (midx == -1) midx = idx;
-      else if (midx != idx) yyerror("method index mismatch in write_proxy");
+      else if (midx != idx) parser_error("method index mismatch in write_proxy");
       midx++;
     }
     cur = PREV_LINK(cur);
diff --git a/tools/widl/utils.c b/tools/widl/utils.c
index fea0540..98a66dd 100644
--- a/tools/widl/utils.c
+++ b/tools/widl/utils.c
@@ -68,21 +68,21 @@ #endif
 }
 
 
-int yyerror(const char *s, ...)
+int parser_error(const char *s, ...)
 {
 	va_list ap;
 	va_start(ap, s);
-	generic_msg(s, "Error", yytext, ap);
+	generic_msg(s, "Error", parser_text, ap);
 	va_end(ap);
 	exit(1);
 	return 1;
 }
 
-int yywarning(const char *s, ...)
+int parser_warning(const char *s, ...)
 {
 	va_list ap;
 	va_start(ap, s);
-	generic_msg(s, "Warning", yytext, ap);
+	generic_msg(s, "Warning", parser_text, ap);
 	va_end(ap);
 	return 0;
 }
diff --git a/tools/widl/utils.h b/tools/widl/utils.h
index 089607d..3641aae 100644
--- a/tools/widl/utils.h
+++ b/tools/widl/utils.h
@@ -33,8 +33,8 @@ #ifndef __GNUC__
 #define __attribute__(X)
 #endif
 
-int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
-int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
+int parser_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
+int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
 void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
 void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
 void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index 39cd9be..c04d07f 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -84,7 +84,7 @@ static const char version_string[] = "Wi
 
 int win32 = 1;
 int debuglevel = DEBUGLEVEL_NONE;
-int yydebug, yy_flex_debug;
+int parser_debug, yy_flex_debug;
 
 int pedantic = 0;
 static int do_everything = 1;
@@ -271,7 +271,7 @@ #endif
     setbuf(stderr,0);
   }
 
-  yydebug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
+  parser_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
   yy_flex_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
 
   wpp_set_debug( (debuglevel & DEBUGLEVEL_PPLEX) != 0,
@@ -330,13 +330,13 @@ #endif
 
     if(ret) exit(1);
     if(preprocess_only) exit(0);
-    if(!(yyin = fopen(temp_name, "r"))) {
+    if(!(parser_in = fopen(temp_name, "r"))) {
       fprintf(stderr, "Could not open %s for input\n", temp_name);
       return 1;
     }
   }
   else {
-    if(!(yyin = fopen(input_name, "r"))) {
+    if(!(parser_in = fopen(input_name, "r"))) {
       fprintf(stderr, "Could not open %s for input\n", input_name);
       return 1;
     }
@@ -380,7 +380,7 @@ #endif
   }
 
   init_types();
-  ret = yyparse();
+  ret = parser_parse();
 
   if(do_header) {
     fprintf(header, "/* Begin additional prototypes for all interfaces */\n");
@@ -405,7 +405,7 @@ #endif
     fclose(idfile);
   }
 
-  fclose(yyin);
+  fclose(parser_in);
 
   if(ret) {
     exit(1);




More information about the wine-cvs mailing list