mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 02:03:03 +00:00
* tests/glr-regr1.at (Badly Collapsed GLR States): Prototype yylex
and yyerror. Have yyerror `use' its arguments. * tests/calc.at (AT_CHECK_PUSHDEFS): AT_YYERROR_SEES_LOC_IF returns true when location & yacc & pure & parse-param. (_AT_DATA_CALC_Y): Let yyerror ``use'' its arguments.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2002-11-04 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* tests/glr-regr1.at (Badly Collapsed GLR States): Prototype yylex
|
||||||
|
and yyerror.
|
||||||
|
Have yyerror `use' its arguments.
|
||||||
|
* tests/calc.at (AT_CHECK_PUSHDEFS): AT_YYERROR_SEES_LOC_IF
|
||||||
|
returns true when location & yacc & pure & parse-param.
|
||||||
|
(_AT_DATA_CALC_Y): Let yyerror ``use'' its arguments.
|
||||||
|
|
||||||
2002-11-04 Akim Demaille <akim@epita.fr>
|
2002-11-04 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/location.h (LOCATION_PRINT): Use quotearg slot 3 to avoid
|
* src/location.h (LOCATION_PRINT): Use quotearg slot 3 to avoid
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ yyerror (const char *s
|
|||||||
]AT_YYERROR_ARG_LOC_IF([, YYLTYPE *yylloc])[
|
]AT_YYERROR_ARG_LOC_IF([, YYLTYPE *yylloc])[
|
||||||
]AT_PARAM_IF([, value_t *result, int *count])[)
|
]AT_PARAM_IF([, value_t *result, int *count])[)
|
||||||
{
|
{
|
||||||
|
]AT_PARAM_IF([(void) result; (void) count; ])[
|
||||||
]AT_YYERROR_SEES_LOC_IF([
|
]AT_YYERROR_SEES_LOC_IF([
|
||||||
fprintf (stderr, "%d.%d-%d.%d: ",
|
fprintf (stderr, "%d.%d-%d.%d: ",
|
||||||
LOC.first_line, LOC.first_column,
|
LOC.first_line, LOC.first_column,
|
||||||
@@ -441,10 +442,11 @@ m4_pushdef([AT_GLR_OR_PARAM_IF],
|
|||||||
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
||||||
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
||||||
[$2])])
|
[$2])])
|
||||||
# yyerror cannot see the locations if !glr & pure.
|
# yyerror cannot see the locations if !glr & pure & !param.
|
||||||
m4_pushdef([AT_YYERROR_SEES_LOC_IF],
|
m4_pushdef([AT_YYERROR_SEES_LOC_IF],
|
||||||
[AT_LOCATION_IF([AT_GLR_IF([$1],
|
[AT_LOCATION_IF([AT_GLR_IF([$1],
|
||||||
[AT_PURE_IF([$2], [$1])])],
|
[AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
|
||||||
|
[$1])])],
|
||||||
[$2])])
|
[$2])])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ AT_DATA([glr-regr1.y],
|
|||||||
|
|
||||||
#define YYSTYPE int
|
#define YYSTYPE int
|
||||||
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
|
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
|
||||||
|
int yylex (void);
|
||||||
|
int yyerror (char const *msg);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,24 +54,29 @@ E: E 'P' E { $$=1; printf("E -> E 'P' E\n"); } %merge <exprMerge>
|
|||||||
|
|
||||||
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1)
|
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1)
|
||||||
{
|
{
|
||||||
|
(void) x0;
|
||||||
|
(void) x1;
|
||||||
printf ("<OR>\n");
|
printf ("<OR>\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main (void)
|
||||||
{
|
{
|
||||||
yyparse();
|
yyparse();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int yyerror(char const *msg)
|
int
|
||||||
|
yyerror (char const *msg)
|
||||||
{
|
{
|
||||||
printf("%s\n", msg);
|
printf("%s\n", msg);
|
||||||
exit(4);
|
exit(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int yylex()
|
int
|
||||||
|
yylex (void)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
int ch = fgetc(stdin);
|
int ch = fgetc(stdin);
|
||||||
|
|||||||
Reference in New Issue
Block a user