#endif /* not YYPURE */
-#if YYDEBUG != 0
+#if YYDEBUG
int yydebug; /* nonzero means print parse trace */
/* [The following comment makes no sense to me. Could someone
{
yychar1 = YYTRANSLATE(yychar);
+#if YYDEBUG
+ /* We have to keep this `#if YYDEBUG', since we use variables
+ which are defined only if `YYDEBUG' is set. */
if (yydebug)
{
fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise meaning
- of a token, for further debugging info. */
+ /* Give the individual parser a way to print the precise
+ meaning of a token, for further debugging info. */
# ifdef YYPRINT
YYPRINT (stderr, yychar, yylval);
# endif
fprintf (stderr, ")\n");
}
+#endif
}
yyn += yychar1;
YYACCEPT;
/* Shift the lookahead token. */
-
+#if YYDEBUG
if (yydebug)
fprintf (stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
+#endif
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
size += strlen(yytname[x]) + 15, count++;
- msg = (char *) malloc(size + 15);
+ size += strlen ("parse error, unexpected `") + 1;
+ size += strlen (yytname[YYTRANSLATE (yychar)]);
+ msg = (char *) malloc (size);
if (msg != 0)
{
- strcpy(msg, "parse error");
+ strcpy (msg, "parse error, unexpected `");
+ strcat (msg, yytname[YYTRANSLATE (yychar)]);
+ strcat (msg, "'");
if (count < 5)
{
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
{
- strcat(msg, count == 0 ? ", expecting `" : " or `");
- strcat(msg, yytname[x]);
- strcat(msg, "'");
+ strcat (msg, count == 0 ? ", expecting `" : " or `");
+ strcat (msg, yytname[x]);
+ strcat (msg, "'");
count++;
}
}
- yyerror(msg);
- free(msg);
+ yyerror (msg);
+ free (msg);
}
else
yyerror ("parse error; also virtual memory exceeded");
}
else
#endif /* YYERROR_VERBOSE */
- yyerror("parse error");
+ yyerror ("parse error");
}
goto yyerrlab1;
/* return failure if at end of input */
if (yychar == YYEOF)
YYABORT;
-
+#if YYDEBUG
if (yydebug)
fprintf (stderr, "Discarding token %d (%s).\n",
yychar, yytname[yychar1]);
-
+#endif
yychar = YYEMPTY;
}