Fixed a LALR(2) problem while scanning usertype resources which had

identifiers for both name and type.
This commit is contained in:
Bertho Stultiens 2000-08-25 21:32:18 +00:00 committed by Alexandre Julliard
parent 9e0ae86d06
commit c5a46ba96e
6 changed files with 54 additions and 14 deletions

View File

@ -6,3 +6,8 @@ ppy.tab.h
wrc wrc
y.tab.c y.tab.c
y.tab.h y.tab.h
ppy.tab.c
ppy.tab.h
y.output
ppy.output
lex.backup

View File

@ -1,3 +1,10 @@
---------------------------------------------------------------------------
Version 1.1.8 (24-Aug-2000)
Bertho Stultiens <bertho@akhphd.au.dk>
- Fixed a LALR(2) problem while scanning usertype resources which
had identifiers for both name and type.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Version 1.1.7 (24-Jul-2000) Version 1.1.7 (24-Jul-2000)

View File

@ -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 See the file CHANGES for differences between the version and what has been
corrected in the current version. corrected in the current version.
@ -113,7 +113,7 @@ __DATE__ | "May 1 2000" | Datestring of compilation
__WRC__  1 | Wrc's major version __WRC__  1 | Wrc's major version
__WRC_MINOR__ | 1 | Wrc's minor version __WRC_MINOR__ | 1 | Wrc's minor version
__WRC_MICRO__ | 7 | 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: Include-files are not read twice if they are protected with this scheme:
#ifndef SOME_DEFINE #ifndef SOME_DEFINE

View File

@ -435,7 +435,7 @@ cjunk : tTYPEDEF { strip_til_semicolon(); }
| tSTATIC { strip_til_semicolon(); } | tSTATIC { strip_til_semicolon(); }
| tINLINE { internal_error(__FILE__, __LINE__, "Don't yet know how to strip inline functions\n"); } | tINLINE { internal_error(__FILE__, __LINE__, "Don't yet know how to strip inline functions\n"); }
/* | tIDENT tIDENT { strip_til_semicolon(); } */ /* | 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_parenthesis(); } */
| tIDENT '*' { strip_til_semicolon(); } | tIDENT '*' { strip_til_semicolon(); }
| tNL /* | tNL /*
@ -467,21 +467,49 @@ cjunk : tTYPEDEF { strip_til_semicolon(); }
/* Parse top level resource definitions etc. */ /* Parse top level resource definitions etc. */
resource resource
: nameid usrcvt resource_definition { : expr usrcvt resource_definition {
$$ = $3; $$ = $3;
if($$) if($$)
{ {
$$->name = $1; if($1 > 65535 || $1 < -32768)
if($1->type == name_ord) yyerror("Resource's ID out of range (%d)", $1);
{ $$->name = new_name_id();
chat("Got %s (%d)",get_typename($3),$1->name.i_name); $$->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 { | stringtable {
/* Don't do anything, stringtables are converted to /* Don't do anything, stringtables are converted to
* resource_t structures when we are finished parsing and * resource_t structures when we are finished parsing and

View File

@ -16,8 +16,8 @@
#define WRC_MAJOR_VERSION 1 #define WRC_MAJOR_VERSION 1
#define WRC_MINOR_VERSION 1 #define WRC_MINOR_VERSION 1
#define WRC_MICRO_VERSION 7 #define WRC_MICRO_VERSION 8
#define WRC_RELEASEDATE "(24-Jul-2000)" #define WRC_RELEASEDATE "(24-Aug-2000)"
#define WRC_STRINGIZE(a) #a #define WRC_STRINGIZE(a) #a
#define WRC_EXP_STRINGIZE(a) WRC_STRINGIZE(a) #define WRC_EXP_STRINGIZE(a) WRC_STRINGIZE(a)

View File

@ -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 .SH NAME
wrc \- Wine Resource Compiler wrc \- Wine Resource Compiler
.SH SYNOPSIS .SH SYNOPSIS