* data/bison.simple (b4_pure_if): New.

Use it instead of #ifdef YYPURE.
This commit is contained in:
Akim Demaille
2002-06-19 10:00:24 +00:00
parent 58612f1de0
commit 7431029172
2 changed files with 46 additions and 34 deletions

View File

@@ -1,6 +1,11 @@
2002-06-19 Akim Demaille <akim@epita.fr> 2002-06-19 Akim Demaille <akim@epita.fr>
* data/bison.simple (m4_location_if): New. * data/bison.simple (b4_pure_if): New.
Use it instead of #ifdef YYPURE.
2002-06-19 Akim Demaille <akim@epita.fr>
* data/bison.simple (b4_location_if): New.
Use it instead of #ifdef YYLSP_NEEDED. Use it instead of #ifdef YYLSP_NEEDED.
2002-06-19 Akim Demaille <akim@epita.fr> 2002-06-19 Akim Demaille <akim@epita.fr>

View File

@@ -63,6 +63,19 @@ m4_define([b4_rhs_location],
## -------------- ##
## %pure-parser. ##
## -------------- ##
# b4_pure_if(IF-TRUE, IF-FALSE)
# -----------------------------
# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
m4_define([b4_pure_if],
[m4_if(b4_pure, [1],
[$1],
[$2])])
## ------------------- ## ## ------------------- ##
## Output file names. ## ## Output file names. ##
## ------------------- ## ## ------------------- ##
@@ -522,15 +535,13 @@ while (0)
/* YYLEX -- calling `yylex' with the right arguments. */ /* YYLEX -- calling `yylex' with the right arguments. */
#if YYPURE b4_pure_if(
# ifdef YYLEX_PARAM [#ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, b4_location_if([&yylloc, ])YYLEX_PARAM) # define YYLEX yylex (&yylval, b4_location_if([&yylloc, ])YYLEX_PARAM)
# else #else
# define YYLEX yylex (&yylval, b4_location_if([&yylloc, ])) # define YYLEX yylex (&yylval, b4_location_if([&yylloc, ]))
# endif #endif],
#else /* !YYPURE */ [#define YYLEX yylex ()])
# define YYLEX yylex ()
#endif /* !YYPURE */
/* Enable debugging if requested. */ /* Enable debugging if requested. */
#if YYDEBUG #if YYDEBUG
@@ -658,37 +669,33 @@ int yyparse (void);
#endif #endif
static void yydestructor (int symbol_type, YYSTYPE symbol_value); static void yydestructor (int symbol_type, YYSTYPE symbol_value);
/* YY_DECL_VARIABLES -- depending whether we use a pure parser, m4_divert_push([KILL])# ======================== M4 code.
variables are global, or local to YYPARSE. */ # b4_declare_parser_variables
# ---------------------------
# Declare the variables that are global, or local to YYPARSE if
# pure-parser
m4_define([b4_declare_parser_variables],
[/* The lookahead symbol. */
int yychar;
#define YY_DECL_VARIABLES \ /* The semantic value of the lookahead symbol. */
/* The lookahead symbol. */ \ YYSTYPE yylval;
int yychar; \
\ /* Number of parse errors so far. */
/* The semantic value of the lookahead symbol. */ \ int yynerrs;b4_location_if([
YYSTYPE yylval; \ /* Location data for the lookahead symbol. */
\
/* Number of parse errors so far. */ \
int yynerrs;b4_location_if([ \
/* Location data for the lookahead symbol. */ \
YYLTYPE yylloc;]) YYLTYPE yylloc;])
])
m4_divert_pop([KILL])dnl# ====================== End of M4 code.
b4_pure_if([],
/* If nonreentrant, generate the variables here. */ [b4_declare_parser_variables])
#if !YYPURE
YY_DECL_VARIABLES
#endif /* !YYPURE */
int int
yyparse (YYPARSE_PARAM_ARG) yyparse (YYPARSE_PARAM_ARG)
YYPARSE_PARAM_DECL YYPARSE_PARAM_DECL
{[ {[
/* If reentrant, generate the variables here. */ ]b4_pure_if([b4_declare_parser_variables])[
#if YYPURE
YY_DECL_VARIABLES
#endif /* !YYPURE */
register int yystate; register int yystate;
register int yyn; register int yyn;
int yyresult; int yyresult;
@@ -1284,7 +1291,7 @@ typedef union b4_stype yystype;
# define YYSTYPE yystype # define YYSTYPE yystype
#endif #endif
m4_if(b4_pure, [0], b4_pure_if([],
[extern YYSTYPE b4_prefix[]lval;]) [extern YYSTYPE b4_prefix[]lval;])
b4_location_if( b4_location_if(