From b37a889f2f7e5b6869ce3a31186f6cbca2c66f9f Mon Sep 17 00:00:00 2001 From: Bertho Stultiens Date: Tue, 25 Jul 2000 17:44:08 +0000 Subject: [PATCH] - Implemented a bug-work-around for Berkeley yacc (byacc) which does not generate proper default transition rules for non-terminals. See comments in parser.y how the fix works. - Changed the error-line/char position to make emacs happy parsing the position of the error. - Added comments in the documentation in which order the line-numer and character-position of the error is written. --- tools/wrc/CHANGES | 12 ++++++++++ tools/wrc/Makefile.in | 2 +- tools/wrc/README.wrc | 6 ++--- tools/wrc/parser.y | 55 ++++++++++++++++++++++++++++++++++++++++++- tools/wrc/utils.c | 2 +- tools/wrc/wrc.h | 4 ++-- tools/wrc/wrc.man | 18 +++++++++++--- 7 files changed, 88 insertions(+), 11 deletions(-) diff --git a/tools/wrc/CHANGES b/tools/wrc/CHANGES index e0f4bbbc2e3..c320375ed87 100644 --- a/tools/wrc/CHANGES +++ b/tools/wrc/CHANGES @@ -1,3 +1,15 @@ +--------------------------------------------------------------------------- +Version 1.1.7 (24-Jul-2000) + +Bertho Stultiens +- Implemented a bug-work-arround for Berkeley yacc (byacc) which + does not generate proper default transition rules for non-terminals. + See comments in parser.y how the fix works. +- Changed the error-line/char position to make emacs happy parsing + the position of the error. +- Added comments in the documentation in which order the line-numer + and character-position of the error is written. + --------------------------------------------------------------------------- Version 1.1.6 (05-Jun-2000) diff --git a/tools/wrc/Makefile.in b/tools/wrc/Makefile.in index f3909ea59f7..ccf7dbba59a 100644 --- a/tools/wrc/Makefile.in +++ b/tools/wrc/Makefile.in @@ -45,7 +45,7 @@ lex.ppl.c: ppl.l $(LEX) $(LEXOPT) -d -Ppp -8 -olex.ppl.c $(SRCDIR)/ppl.l clean:: - $(RM) ppy.tab.h ppy.output lex.backup y.output + $(RM) ppy.tab.h ppy.output parser.output parser.tab.h lex.backup y.output install:: $(PROGRAMS) [ -d $(bindir) ] || $(MKDIR) $(bindir) diff --git a/tools/wrc/README.wrc b/tools/wrc/README.wrc index 91993685f40..e1bb5dfcd74 100644 --- a/tools/wrc/README.wrc +++ b/tools/wrc/README.wrc @@ -1,4 +1,4 @@ -Release 1.1.6 of wrc (05-Jul-2000), the wine resource compiler. +Release 1.1.7 of wrc (24-Jul-2000), the wine resource compiler. See the file CHANGES for differences between the version and what has been corrected in the current version. @@ -112,8 +112,8 @@ __TIME__ | "23:59:59" | Timestring of compilation __DATE__ | "May 1 2000" | Datestring of compilation __WRC__  1 | Wrc's major version __WRC_MINOR__ | 1 | Wrc's minor version -__WRC_MICRO__ | 6 | Wrc's minor version -__WRC_PATCH__ | 6 | Alias of __WRC_MICRO__ +__WRC_MICRO__ | 7 | Wrc's minor version +__WRC_PATCH__ | 7 | 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 fae37fdaa7c..faa69b38b77 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -4,6 +4,8 @@ * Copyright 1998-2000 Bertho A. Stultiens (BS) * 1999 Juergen Schmied (JS) * + * 24-Jul-2000 BS - Made a fix for broken Berkeley yacc on + * non-terminals (see cjunk rule). * 21-May-2000 BS - Partial implementation of font resources. * - Corrected language propagation for binary * resources such as bitmaps, isons, cursors, @@ -125,6 +127,31 @@ #include "wingdi.h" #include "winuser.h" +#if defined(YYBYACC) + /* Berkeley yacc (byacc) doesn't seem to know about these */ + /* Some *BSD supplied versions do define these though */ +# ifndef YYEMPTY +# define YYEMPTY (-1) /* Empty lookahead value of yychar */ +# endif +# ifndef YYLEX +# define YYLEX yylex() +# endif + +#elif defined(YYBISON) + /* Bison was used for original development */ + /* #define YYEMPTY -2 */ + /* #define YYLEX yylex() */ + +#else + /* No yacc we know yet */ +# if !defined(YYEMPTY) || !defined(YYLEX) +# error Yacc version/type unknown. This version needs to be verified for settings of YYEMPTY and YYLEX. +# elif defined(__GNUC__) /* gcc defines the #warning directive */ +# warning Yacc version/type unknown. It defines YYEMPTY and YYLEX, but is not tested + /* #else we just take a chance that it works... */ +# endif +#endif + int want_nl = 0; /* Signal flex that we need the next newline */ int want_id = 0; /* Signal flex that we need the next identifier */ stringtable_t *tagstt; /* Stringtable tag. @@ -411,6 +438,31 @@ cjunk : tTYPEDEF { strip_til_semicolon(); } | tIDENT tIDENT '(' { strip_til_parenthesis(); } /* | 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. */ @@ -459,7 +511,8 @@ resource dont_want_id = 1; if(yychar == tNL) - yychar = YYEMPTY; + yychar = YYEMPTY; /* Could use 'yyclearin', but we already need the*/ + /* direct access to yychar in rule 'usrcvt' below. */ else if(yychar == tIDENT) yywarning("LANGUAGE statement not delimited with newline; next identifier might be wrong"); diff --git a/tools/wrc/utils.c b/tools/wrc/utils.c index ec06da61c1f..0812154930a 100644 --- a/tools/wrc/utils.c +++ b/tools/wrc/utils.c @@ -36,7 +36,7 @@ void make_print(char *str) static void generic_msg(const char *s, const char *t, const char *n, va_list ap) { - fprintf(stderr, "%s %s: %d, %d: ", t, input_name ? input_name : "stdin", line_number, char_number); + fprintf(stderr, "%s:%d:%d: %s: ", input_name ? input_name : "stdin", line_number, char_number, t); vfprintf(stderr, s, ap); #ifdef WANT_NEAR_INDICATION { diff --git a/tools/wrc/wrc.h b/tools/wrc/wrc.h index 0db0dd333f8..ee9fb21f5c8 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 6 -#define WRC_RELEASEDATE "(05-Jul-2000)" +#define WRC_MICRO_VERSION 7 +#define WRC_RELEASEDATE "(24-Jul-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 9e552fdfbeb..a86b115449e 100644 --- a/tools/wrc/wrc.man +++ b/tools/wrc/wrc.man @@ -1,4 +1,4 @@ -.TH WRC 1 "July 05, 2000" "Version 1.1.6" "Wine Resource Compiler" +.TH WRC 1 "July 24, 2000" "Version 1.1.7" "Wine Resource Compiler" .SH NAME wrc \- Wine Resource Compiler .SH SYNOPSIS @@ -44,9 +44,9 @@ Create an assembly file from a binary \fB.res\fR file. .TP .I \-B x Win32 only; set output byte\-ordering, where \fIx\fR is one of n[ative], -l[ittle] or b[ig]. Only resource in source-form can be reorderd. Native +l[ittle] or b[ig]. Only resources in source-form can be reorderd. Native ordering depends on the system on which \fBwrc\fR was built. You can see -the native ordering by typing \fI\"wrc \-?\"\fR. +the native ordering by typing \fIwrc \-?\fR. .TP .I \-c Add 'const' prefix to C constants when writing header files. @@ -182,6 +182,16 @@ Win32 compilation mode also sets __WIN32__ to 1 and __FLAT__ to 1. .PP Special macros __FILE__, __LINE__, __TIME__ and __DATE__ are also recognized and expand to their respective equivalent. +.SH "ERROR REPORTING" +All errors and warnings are written to standard error and report: +.br +\fIfilename\fR:\fIline\-number\fR:\fIcharacter\-pos\fR:\fI{Error,Warning}\fR:\fI\fR +.br +The character\-position is always at the next token. I.e. the error +or warning happened before. The line\-number suffers from the same +problem if the error occurred at the last token of the previous line. +The line\-number will be several lines off when the error was followed +by several empry lines. See also \fBBUGS\fR. .SH AUTHORS .B wrc was written by Bertho A. Stultiens and is a nearly complete rewrite of @@ -192,6 +202,8 @@ den Haan. Bugfixes have been contributed by many wine developpers. \- The preprocessor recognizes variable argument macros, but does not expanded them correctly .br +\- Error reporting should be more to the point (and verbose) +.br \- Codepage/UNICODE translations are not/not correct implemented .br \- Default memory options should differ between win16 and win32.