mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
tests: handle %parse-param in the generated yyerror
* tests/local.at (AT_PARSE_PARAMS): New. (AT_YYERROR_FORMALS, AT_YYERROR_DEFINE): Use it to add the parse-param to yyerror. * tests/calc.at, tests/regression.at: Use AT_YYERROR_DEFINE and AT_YYERROR_DECLARE, now that they handle properly the parse-params. Be sure to let AT_BISON_OPTION_PUSHDEFS now what parse-params are used.
This commit is contained in:
@@ -1545,14 +1545,14 @@ AT_CLEANUP
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_SETUP([[Lex and parse params: $1]])
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton $1])
|
||||
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" %parse-param { int x } %parse-param { int y }])
|
||||
|
||||
## FIXME: Improve parsing of parse-param and use the generated
|
||||
## yyerror.
|
||||
AT_DATA_GRAMMAR([input.y],
|
||||
[[%defines
|
||||
%locations
|
||||
%skeleton $1
|
||||
%skeleton "$1"
|
||||
%union { int ival; }
|
||||
%parse-param { int x }
|
||||
// Spaces, tabs, and new lines.
|
||||
@@ -1566,26 +1566,18 @@ AT_DATA_GRAMMAR([input.y],
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
]AT_SKEL_CC_IF([], [[
|
||||
static
|
||||
void
|
||||
yyerror (int x, int y, const char *msg)
|
||||
{
|
||||
fprintf (stderr, "x: %d, y: %d, %s\n", x, y, msg);
|
||||
}]])[
|
||||
|
||||
]AT_YYERROR_DECLARE[
|
||||
]AT_YYLEX_DECLARE[
|
||||
%}
|
||||
|
||||
%%
|
||||
exp: 'a' { fprintf (stdout, "x: %d, y: %d\n", x, y); };
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE(["a"])[
|
||||
|
||||
]AT_SKEL_CC_IF(
|
||||
[AT_YYERROR_DEFINE
|
||||
|
||||
int
|
||||
[int
|
||||
yyparse (int x, int y)
|
||||
{
|
||||
yy::parser parser(x, y);
|
||||
@@ -1609,9 +1601,9 @@ AT_CLEANUP
|
||||
])
|
||||
|
||||
## FIXME: test Java, and iterate over skeletons.
|
||||
AT_TEST("yacc.c")
|
||||
AT_TEST("glr.c")
|
||||
AT_TEST("lalr1.cc")
|
||||
AT_TEST("glr.cc")
|
||||
AT_TEST([yacc.c])
|
||||
AT_TEST([glr.c])
|
||||
AT_TEST([lalr1.cc])
|
||||
AT_TEST([glr.cc])
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
Reference in New Issue
Block a user