* data/c.m4 (b4_yydestruct_generate, b4_symbol_actions): New.

* data/yacc.c: Rename yychar1 as yytoken, as in glr.c.
Don't work on yychar (i.e., do set it to YYEMPTY, don't match
it against YYEMPTY and so forth), work on yytoken (i.e., set
it to YYEMPTY etc.).
(yydestruct): Replace with a b4_yydestruct_generate invocation.
(b4_symbol_actions): Remove.
* data/glr.c (YYTRANSLATE): As for yacc.c, if negative, it stands
for 0, end-of-input.
This commit is contained in:
Akim Demaille
2002-11-12 08:45:40 +00:00
parent 72f889cca3
commit b0400cc6ef
4 changed files with 92 additions and 80 deletions

View File

@@ -267,8 +267,9 @@ b4_syncline([@oline@], [@ofile@])
#define YYUNDEFTOK ]b4_undef_token_number[
#define YYMAXUTOK ]b4_user_token_number_max[
#define YYTRANSLATE(YYX) \
((unsigned)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
#define YYTRANSLATE(YYX) \
((YYX <= 0) ? YYEOF : \
(unsigned)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
@@ -1505,7 +1506,7 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk,
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX;
*yytokenp = YYTRANSLATE(yychar);
*yytokenp = YYTRANSLATE (yychar);
YYDPRINTF ((stderr, "Next token is %s\n",
yytokenName (*yytokenp)));
}
@@ -1578,8 +1579,7 @@ yyreportParseError (yyGLRStack* yystack,
yysize += strlen (yytokenName (yyx)) + strlen (yyprefix),
yycount += 1, yyprefix = " or ";
yymsg = yyp = (char*) malloc (yysize);
sprintf (yyp, "parse error, unexpected %s",
yytokenName (*yytokenp));
sprintf (yyp, "parse error, unexpected %s", yytokenName (*yytokenp));
yyp += strlen (yyp);
if (yycount < 5)
{