From c5a46ba96ee85d212714dd958cef327fc7b0eff8 Mon Sep 17 00:00:00 2001 From: Bertho Stultiens Date: Fri, 25 Aug 2000 21:32:18 +0000 Subject: [PATCH] Fixed a LALR(2) problem while scanning usertype resources which had identifiers for both name and type. --- tools/wrc/.cvsignore | 5 +++++ tools/wrc/CHANGES | 7 +++++++ tools/wrc/README.wrc | 4 ++-- tools/wrc/parser.y | 46 +++++++++++++++++++++++++++++++++++--------- tools/wrc/wrc.h | 4 ++-- tools/wrc/wrc.man | 2 +- 6 files changed, 54 insertions(+), 14 deletions(-) diff --git a/tools/wrc/.cvsignore b/tools/wrc/.cvsignore index e2959437d89..5bb0841ebc7 100644 --- a/tools/wrc/.cvsignore +++ b/tools/wrc/.cvsignore @@ -6,3 +6,8 @@ ppy.tab.h wrc y.tab.c y.tab.h +ppy.tab.c +ppy.tab.h +y.output +ppy.output +lex.backup diff --git a/tools/wrc/CHANGES b/tools/wrc/CHANGES index c320375ed87..df976da2f88 100644 --- a/tools/wrc/CHANGES +++ b/tools/wrc/CHANGES @@ -1,3 +1,10 @@ +--------------------------------------------------------------------------- +Version 1.1.8 (24-Aug-2000) + +Bertho Stultiens +- Fixed a LALR(2) problem while scanning usertype resources which + had identifiers for both name and type. + --------------------------------------------------------------------------- Version 1.1.7 (24-Jul-2000) diff --git a/tools/wrc/README.wrc b/tools/wrc/README.wrc index e1bb5dfcd74..a33e6350730 100644 --- a/tools/wrc/README.wrc +++ b/tools/wrc/README.wrc @@ -1,4 +1,4 @@ -Release 1.1.7 of wrc (24-Jul-2000), the wine resource compiler. +Release 1.1.8 of wrc (24-Aug-2000), the wine resource compiler. See the file CHANGES for differences between the version and what has been corrected in the current version. @@ -113,7 +113,7 @@ __DATE__ | "May 1 2000" | Datestring of compilation __WRC__  1 | Wrc's major version __WRC_MINOR__ | 1 | Wrc's minor version __WRC_MICRO__ | 7 | Wrc's minor version -__WRC_PATCH__ | 7 | Alias of __WRC_MICRO__ +__WRC_PATCH__ | 8 | Alias of __WRC_MICRO__ Include-files are not read twice if they are protected with this scheme: #ifndef SOME_DEFINE diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y index faa69b38b77..2e4eac4ff4a 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -435,7 +435,7 @@ cjunk : tTYPEDEF { 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(); } +/* | tIDENT tIDENT '(' { strip_til_parenthesis(); } See comments in 'resource' below */ /* | tIDENT '(' { strip_til_parenthesis(); } */ | tIDENT '*' { strip_til_semicolon(); } | tNL /* @@ -467,21 +467,49 @@ cjunk : tTYPEDEF { strip_til_semicolon(); } /* Parse top level resource definitions etc. */ resource - : nameid usrcvt resource_definition { + : expr usrcvt resource_definition { $$ = $3; if($$) { - $$->name = $1; - if($1->type == name_ord) - { - chat("Got %s (%d)",get_typename($3),$1->name.i_name); + if($1 > 65535 || $1 < -32768) + yyerror("Resource's ID out of range (%d)", $1); + $$->name = new_name_id(); + $$->name->type = name_ord; + $$->name->name.i_name = $1; + chat("Got %s (%d)", get_typename($3), $$->name->name.i_name); } - else if($1->type == name_str) - { - chat("Got %s (%s)",get_typename($3),$1->name.s_name->str.cstr); } + | tIDENT usrcvt resource_definition { + $$ = $3; + if($$) + { + $$->name = new_name_id(); + $$->name->type = name_str; + $$->name->name.s_name = $1; + 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 diff --git a/tools/wrc/wrc.h b/tools/wrc/wrc.h index ee9fb21f5c8..88529ea5f5e 100644 --- a/tools/wrc/wrc.h +++ b/tools/wrc/wrc.h @@ -16,8 +16,8 @@ #define WRC_MAJOR_VERSION 1 #define WRC_MINOR_VERSION 1 -#define WRC_MICRO_VERSION 7 -#define WRC_RELEASEDATE "(24-Jul-2000)" +#define WRC_MICRO_VERSION 8 +#define WRC_RELEASEDATE "(24-Aug-2000)" #define WRC_STRINGIZE(a) #a #define WRC_EXP_STRINGIZE(a) WRC_STRINGIZE(a) diff --git a/tools/wrc/wrc.man b/tools/wrc/wrc.man index a86b115449e..b00bd3fd701 100644 --- a/tools/wrc/wrc.man +++ b/tools/wrc/wrc.man @@ -1,4 +1,4 @@ -.TH WRC 1 "July 24, 2000" "Version 1.1.7" "Wine Resource Compiler" +.TH WRC 1 "August 24, 2000" "Version 1.1.8" "Wine Resource Compiler" .SH NAME wrc \- Wine Resource Compiler .SH SYNOPSIS