More wrc-bugs fixes.

Francois Gouget fgouget at free.fr
Sun Jun 3 14:26:07 CDT 2001


Maciek Kaliszewski wrote:
> Added support for RCINCLUDE directive.Now wrc ignores everything 
> except preprocesor directives (#include #if #define and so on.) from
> included *.h *.c files .

   Now that wrc no longer has to parse 'C-junk' I propose to remove all
the corresponding code:

Changelog:

 * tools/wrc/parser.h,
   tools/wrc/parser.l,
   tools/wrc/parser.y,
   tools/wrc/preproc.c

   Wrc no longer needs to parse C code. Remove c-junk handling code.


--
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
The nice thing about meditation is that it makes doing nothing quite respectable
                                  -- Paul Dean

-------------- next part --------------
Index: tools/wrc/parser.h
===================================================================
RCS file: /home/wine/wine/tools/wrc/parser.h,v
retrieving revision 1.5
diff -u -r1.5 parser.h
--- tools/wrc/parser.h	2000/05/23 01:18:38	1.5
+++ tools/wrc/parser.h	2001/06/03 06:25:46
@@ -20,9 +20,6 @@
 extern int yy_flex_debug;
 
 int yylex(void);
-void set_pp_ignore(int state);
-void strip_til_semicolon(void);
-void strip_til_parenthesis(void);
 
 #endif
 
Index: tools/wrc/parser.l
===================================================================
RCS file: /home/wine/wine/tools/wrc/parser.l,v
retrieving revision 1.16
diff -u -r1.16 parser.l
--- tools/wrc/parser.l	2000/09/24 03:02:13	1.16
+++ tools/wrc/parser.l	2001/06/03 06:25:48
@@ -173,9 +173,7 @@
 	{ "DLGINIT",		tDLGINIT,		0, 0, 0},
 	{ "EDITTEXT",		tEDITTEXT,		0, 0, 0},
 	{ "END",		tEND,			0, 0, 0},
-	{ "enum",		tENUM,			0, 1, 1},
 	{ "EXSTYLE",		tEXSTYLE,		0, 0, 0},
-	{ "extern",		tEXTERN,		0, 1, 1},
 	{ "FILEFLAGS",		tFILEFLAGS,		0, 0, 0},
 	{ "FILEFLAGSMASK",	tFILEFLAGSMASK,		0, 0, 0},
 	{ "FILEOS",		tFILEOS,		0, 0, 0},
@@ -191,7 +189,6 @@
 	{ "ICON",		tICON,			0, 0, 0},
 	{ "IMPURE",		tIMPURE,		0, 0, 0},
 	{ "INACTIVE",		tINACTIVE,		0, 0, 0},
-	{ "inline",		tINLINE,		0, 1, 1},
 	{ "LANGUAGE",		tLANGUAGE,		1, 0, 1},
 	{ "LISTBOX",		tLISTBOX,		0, 0, 0},
 	{ "LOADONCALL",		tLOADONCALL,		0, 0, 0},
@@ -217,13 +214,10 @@
 	{ "SEPARATOR",		tSEPARATOR,		0, 0, 0},
 	{ "SHIFT",		tSHIFT,			0, 0, 0},
 	{ "STATE3",		tSTATE3,		1, 0, 0},
-	{ "static",		tSTATIC,		0, 1, 1},
 	{ "STRING",		tSTRING,		0, 0, 0},
 	{ "STRINGTABLE",	tSTRINGTABLE,		0, 0, 1},
-	{ "struct",		tSTRUCT,		0, 1, 1},
 	{ "STYLE",		tSTYLE,			0, 0, 0},
 	{ "TOOLBAR",		tTOOLBAR,		1, 0, 0},
-	{ "typedef",		tTYPEDEF,		0, 1, 1},
 	{ "VALUE",		tVALUE,			0, 0, 0},
 	{ "VERSION",		tVERSION,		1, 0, 0},
 	{ "VERSIONINFO",	tVERSIONINFO,		0, 0, 0},
@@ -380,9 +374,7 @@
 
 				if(tok)
 				{
-					if(tok->token == tCLASS && !strcmp(yytext, "class"))
-						return tCPPCLASS;
-					else if(wanted_id && !tok->alwayskw)
+					if(wanted_id && !tok->alwayskw)
 					{
 						yylval.str = make_string(yytext);
 						return tIDENT;
@@ -427,7 +419,7 @@
 			}
 <yylstr>\\x[0-9a-fA-F]{1,3} {  yyerror("Invalid hex escape sequence '%s'", yytext); }
 
-<yylstr>\\[0-9]+	yyerror("Bad escape secuence");
+<yylstr>\\[0-9]+	yyerror("Bad escape sequence");
 <yylstr>\\a		addwchar('\a');
 <yylstr>\\b		addwchar('\b');
 <yylstr>\\f		addwchar('\f');
@@ -644,24 +636,3 @@
 	memcpy(str->str.cstr, s, str->size+1);
 	return str;
 }
-
-/* Called from the parser to kill c-junk */
-void strip_extern(void)
-{
-	cjunk_tagline = line_number;
-	yy_push_state(pp_stripe);
-}
-
-void strip_til_semicolon(void)
-{
-	cjunk_tagline = line_number;
-	yy_push_state(pp_strips);
-}
-
-void strip_til_parenthesis(void)
-{
-	cjunk_tagline = line_number;
-	stripplevel = 1;	/* One scanned already */
-	yy_push_state(pp_stripp);
-}
-
Index: tools/wrc/parser.y
===================================================================
RCS file: /home/wine/wine/tools/wrc/parser.y,v
retrieving revision 1.25
diff -u -r1.25 parser.y
--- tools/wrc/parser.y	2001/01/02 20:46:28	1.25
+++ tools/wrc/parser.y	2001/06/03 06:25:57
@@ -19,7 +19,7 @@
  * 14-Jan-2000 BS	- Redid the usertype resources so that they
  *			  are compatible.
  * 02-Jan-2000 BS	- Removed the preprocessor from the grammar
- *			  expect for the # command (line numbers).
+ *			  except for the # command (line numbers).
  *
  * 06-Nov-1999 JS	- see CHANGES
  * 
@@ -264,7 +264,7 @@
 	ani_any_t	*ani;
 }
 
-%token tTYPEDEF tEXTERN tSTRUCT tENUM tCPPCLASS tINLINE tSTATIC tNL
+%token tNL
 %token <num> tNUMBER tLNUMBER
 %token <str> tSTRING tIDENT tFILENAME
 %token <raw> tRAWDATA
@@ -423,49 +423,9 @@
 			want_id = 1;
 		dont_want_id = 0;
 		}
-	| resources cjunk			{ $$ = $1; want_id = 1; }
 	;
 
 
-/* C ignore stuff */
-cjunk	: tTYPEDEF			{ strip_til_semicolon(); }
-	| tSTRUCT			{ strip_til_semicolon(); }
-	| tEXTERN			{ strip_til_semicolon(); }
-	| tENUM				{ strip_til_semicolon(); }
-	| tCPPCLASS			{ strip_til_semicolon(); }
-	| tSTATIC			{ strip_til_semicolon(); }
-	| tINLINE			{ internal_error(__FILE__, __LINE__, "Don't yet know how to strip inline functions\n"); }
-/*	| tIDENT tIDENT			{ strip_til_semicolon(); } */
-/*	| tIDENT tIDENT '('		{ strip_til_parenthesis(); } See comments in 'resource' below */
-/*	| tIDENT '('			{ strip_til_parenthesis(); } */
-	| tIDENT '*'			{ strip_til_semicolon(); }
-	| tNL	/*
-		 * This newline rule will never get reduced because we never
-		 * get the tNL token, unless we explicitely set the 'want_nl'
-		 * flag, which we don't.
-		 * The *ONLY* reason for this to be here is because Berkeley
-		 * yacc (byacc), at least version 1.9, has a bug.
-		 * (identified in the generated parser on the second
-		 *  line with:
-		 *  static char yysccsid[] = "@(#)yaccpar   1.9 (Berkeley) 02/21/93";
-		 * )
-		 * This extra rule fixes it.
-		 * The problem is that the expression handling rule "expr: xpr"
-		 * is not reduced on non-terminal tokens, defined above in the
-		 * %token declarations. Token tNL is the only non-terminal that
-		 * can occur. The error becomes visible in the language parsing
-		 * rule below, which looks at the look-ahead token and tests it
-		 * for tNL. However, byacc already generates an error upon reading
-		 * the token instead of keeping it as a lookahead. The reason
-		 * lies in the lack of a $default transition in the "expr : xpr . "
-		 * state (currently state 25). It is probably ommitted because tNL
-		 * is a non-terminal and the state contains 2 s/r conflicts. The
-		 * state enumerates all possible transitions instead of using a
-		 * $default transition.
-		 * All in all, it is a bug in byacc. (period)
-		 */
-	;
-
 /* Parse top level resource definitions etc. */
 resource
 	: expr usrcvt resource_definition {
@@ -490,27 +450,6 @@
 			chat("Got %s (%s)", get_typename($3), $$->name->name.s_name->str.cstr);
 		}
 		}
-	| tIDENT usrcvt tIDENT '('	{ /* cjunk */ strip_til_parenthesis(); $$ = NULL; }
-		/* The above rule is inserted here with explicit tIDENT
-		 * references to avoid a nasty LALR(2) problem when
-		 * considering the 'cjunk' rules with respect to the usertype
-		 * resources.
-		 * A usertype resource can have two leading identifiers before
-		 * it qualifies as shift into usertype rules. However, the
-		 * cjunk scanner also has a rule of two leading identifiers.
-		 * The problem occurs because the second identifier is at the
-		 * second lookahead (hence LALR(2)) seen from the recursion
-		 * rule 'resources'.
-		 * Thus, the scanner will pick *one* of the rules in preference
-		 * of the other (in this case it was 'cjunk') and generates a
-		 * syntax error if the trailing context wasn't seen. The
-		 * correct action would have been to rollback the stack and
-		 * decent into the 'userres' rule, but this cannot be done
-		 * because yacc only parses LALR(1).
-		 * The problem is prevented from happening by making the decent
-		 * into the cjunk-scanning obsolete and explicitly force the
-		 * scanner to require no more than 1 lookahead.
-		 */
 	| stringtable {
 		/* Don't do anything, stringtables are converted to
 		 * resource_t structures when we are finished parsing and
@@ -869,7 +808,6 @@
 	| dlg_attributes tCAPTION tSTRING	{ $$=dialog_caption($3,$1); }
 	| dlg_attributes opt_font		{ $$=dialog_font($2,$1); }
 	| dlg_attributes tCLASS nameid_s	{ $$=dialog_class($3,$1); }
-	| dlg_attributes tCPPCLASS nameid_s	{ $$=dialog_class($3,$1); }
 	| dlg_attributes tMENU nameid		{ $$=dialog_menu($3,$1); }
 	| dlg_attributes opt_language		{ $$=dialog_language($2,$1); }
 	| dlg_attributes opt_characts		{ $$=dialog_characteristics($2,$1); }
@@ -1082,7 +1020,6 @@
 	| dlgex_attribs opt_font		{ $$=dialogex_font($2,$1); }
 	| dlgex_attribs opt_exfont		{ $$=dialogex_font($2,$1); }
 	| dlgex_attribs tCLASS nameid_s		{ $$=dialogex_class($3,$1); }
-	| dlgex_attribs tCPPCLASS nameid_s	{ $$=dialogex_class($3,$1); }
 	| dlgex_attribs tMENU nameid		{ $$=dialogex_menu($3,$1); }
 	| dlgex_attribs opt_language		{ $$=dialogex_language($2,$1); }
 	| dlgex_attribs opt_characts		{ $$=dialogex_characteristics($2,$1); }
Index: tools/wrc/preproc.c
===================================================================
RCS file: /home/wine/wine/tools/wrc/preproc.c,v
retrieving revision 1.3
diff -u -r1.3 preproc.c
--- tools/wrc/preproc.c	2000/05/01 20:06:00	1.3
+++ tools/wrc/preproc.c	2001/06/03 06:26:04
@@ -15,8 +15,6 @@
 #include "preproc.h"
 
 
-extern void set_pp_ignore(int);	/* From parser.l */
-
 #define HASHKEY		2039
 static pp_entry_t *pp_defines[HASHKEY];
 


More information about the wine-patches mailing list