mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* data/push.c (yychar_set, yylval_set, yylloc_set): Delete.
(yypushparse): Add yynchar, yynlval, yynlloc parameters. (b4_declare_parser_variables): Do not declare yynerrs for push mode. (struct yypvars): Remove b4_declare_parser_variables. (yypvarsinit): Remove init code for removed variables. (global scope): Do not declare b4_declare_parser_variables if push or pure mode. (yypushparse): Add b4_declare_parser_variables. Init new local variables, and remove init code for removed yypvars variables. (yyparse): Delete. * tests/calc.at (_AT_DATA_CALC_Y): Call yypushparse for push mode and yyparse for other modes. (AT_CHECK_CALC_LALR): Added '%skeleton "push.c"' for push tests. * tests/local.at (AT_PUSH_IF, AT_PURE_OR_PUSH_IF): Added. (AT_YYERROR_SEES_LOC_IF): push-parser makes this false. (AT_PURE_LEX_IF): True if pure or push parser.
This commit is contained in:
@@ -336,7 +336,17 @@ main (int argc, const char **argv)
|
||||
|
||||
]AT_SKEL_CC_IF([], [m4_bmatch([$4], [%debug],
|
||||
[ yydebug = 1;])])[
|
||||
status = yyparse (]AT_PARAM_IF([&result, &count])[);
|
||||
]AT_PUSH_IF([
|
||||
{
|
||||
struct yypvars *ctx = yypvarsinit ();
|
||||
YYSTYPE my_lval;
|
||||
]AT_LOCATION_IF([YYLTYPE my_lloc;])[
|
||||
do {
|
||||
status = yypushparse (ctx, yylex (&my_lval]AT_LOCATION_IF([[, &my_lloc]])[), &my_lval]AT_LOCATION_IF([[, &my_lloc]])[);
|
||||
} while (status == YYPUSH_MORE);
|
||||
free (ctx);
|
||||
}],[
|
||||
status = yyparse (]AT_PARAM_IF([[&result, &count]])[);])[
|
||||
fclose (input);
|
||||
if (global_result != result)
|
||||
abort ();
|
||||
@@ -562,7 +572,7 @@ AT_CHECK_CALC_LALR([%yacc])
|
||||
AT_CHECK_CALC_LALR([%error-verbose])
|
||||
|
||||
AT_CHECK_CALC_LALR([%pure-parser %locations])
|
||||
AT_CHECK_CALC_LALR([%push-parser %locations])
|
||||
AT_CHECK_CALC_LALR([%push-parser %locations %skeleton "push.c"])
|
||||
AT_CHECK_CALC_LALR([%error-verbose %locations])
|
||||
|
||||
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||
@@ -571,7 +581,7 @@ AT_CHECK_CALC_LALR([%debug])
|
||||
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||
|
||||
AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR([%push-parser %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR([%push-parser %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %skeleton "push.c"])
|
||||
|
||||
AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
|
||||
|
||||
@@ -58,6 +58,10 @@ m4_pushdef([AT_LOCATION_IF],
|
||||
[m4_bmatch([$3], [%locations], [$1], [$2])])
|
||||
m4_pushdef([AT_PURE_IF],
|
||||
[m4_bmatch([$3], [%pure-parser], [$1], [$2])])
|
||||
m4_pushdef([AT_PUSH_IF],
|
||||
[m4_bmatch([$3], [%push-parser], [$1], [$2])])
|
||||
m4_pushdef([AT_PURE_OR_PUSH_IF],
|
||||
[m4_bmatch([$3], [%pure-parser\|%push-parser], [$1], [$2])])
|
||||
m4_pushdef([AT_PURE_AND_LOC_IF],
|
||||
[m4_bmatch([$3], [%locations.*%pure-parser\|%pure-parser.*%locations],
|
||||
[$1], [$2])])
|
||||
@@ -72,17 +76,17 @@ m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
||||
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
||||
[$2])])
|
||||
# yyerror always sees the locations (when activated), except if
|
||||
# yacc & pure & !param.
|
||||
# push or (yacc & pure & !param).
|
||||
m4_pushdef([AT_YYERROR_SEES_LOC_IF],
|
||||
[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
|
||||
[AT_PUSH_IF([$2],[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
|
||||
[$1])],
|
||||
[$1])],
|
||||
[$2])])
|
||||
[$2])])])
|
||||
|
||||
# The interface is pure: either because %pure-parser, or because we
|
||||
# are using the C++ parsers.
|
||||
m4_pushdef([AT_PURE_LEX_IF],
|
||||
[AT_PURE_IF([$1],
|
||||
[AT_PURE_OR_PUSH_IF([$1],
|
||||
[AT_SKEL_CC_IF([$1], [$2])])])
|
||||
|
||||
AT_PURE_LEX_IF(
|
||||
|
||||
Reference in New Issue
Block a user