style: rename b4_lex as b4_yylex

For consistency with b4_yyerror_formals, etc.

* data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/d.m4,
* data/skeletons/glr.c, data/skeletons/glr2.cc,
* data/skeletons/java.m4, data/skeletons/lalr1.cc,
* data/skeletons/lalr1.d, data/skeletons/lalr1.java,
* data/skeletons/yacc.c
(b4_lex, b4_lex_formals): Rename as...
(b4_yylex, b4_yylex_formals): these.
This commit is contained in:
Akim Demaille
2021-08-08 08:53:11 +02:00
parent 3c5f73fe51
commit b2a00ed5dd
6 changed files with 31 additions and 22 deletions

View File

@@ -73,6 +73,15 @@ skeletons. If you are to write a new skeleton, please, implement them for
your language. Overall, be sure to follow the same patterns as the existing your language. Overall, be sure to follow the same patterns as the existing
skeletons. skeletons.
## Vocabulary
We use "formal arguments", or "formals" for short, to denote the declared
parameters of a function (e.g., `int argc, const char **argv`). Yes, this
is somewhat contradictory with `param` in the `%param` directives.
We use "effective arguments", or "args" for short, to denote the values
passed in function calls (e.g., `argc, argv`).
## Symbols ## Symbols
### `b4_symbol(NUM, FIELD)` ### `b4_symbol(NUM, FIELD)`

View File

@@ -107,21 +107,21 @@ b4_percent_define_default([[api.symbol.prefix]], [[YYSYMBOL_]])
## Pure/impure interfaces. ## ## Pure/impure interfaces. ##
## ------------------------ ## ## ------------------------ ##
# b4_lex_formals # b4_yylex_formals
# -------------- # ----------------
# All the yylex formal arguments. # All the yylex formal arguments.
# b4_lex_param arrives quoted twice, but we want to keep only one level. # b4_lex_param arrives quoted twice, but we want to keep only one level.
m4_define([b4_lex_formals], m4_define([b4_yylex_formals],
[b4_pure_if([[[b4_api_PREFIX[STYPE *yylvalp]], [[&yylval]]][]dnl [b4_pure_if([[[b4_api_PREFIX[STYPE *yylvalp]], [[&yylval]]][]dnl
b4_locations_if([, [b4_api_PREFIX[LTYPE *yyllocp], [&yylloc]]])])dnl b4_locations_if([, [b4_api_PREFIX[LTYPE *yyllocp], [&yylloc]]])])dnl
m4_ifdef([b4_lex_param], [, ]b4_lex_param)]) m4_ifdef([b4_lex_param], [, ]b4_lex_param)])
# b4_lex # b4_yylex
# ------ # --------
# Call yylex. # Call yylex.
m4_define([b4_lex], m4_define([b4_yylex],
[b4_function_call([yylex], [int], b4_lex_formals)]) [b4_function_call([yylex], [int], b4_yylex_formals)])
# b4_user_args # b4_user_args

View File

@@ -848,7 +848,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
try try
{ {
#endif // YY_EXCEPTIONS #endif // YY_EXCEPTIONS
*yycharp = ]b4_lex[; *yycharp = ]b4_yylex[;
#if YY_EXCEPTIONS #if YY_EXCEPTIONS
} }
catch (const ]b4_namespace_ref[::]b4_parser_class[::syntax_error& yyexc) catch (const ]b4_namespace_ref[::]b4_parser_class[::syntax_error& yyexc)
@@ -862,7 +862,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
*yycharp = ]b4_symbol(error, id)[; *yycharp = ]b4_symbol(error, id)[;
} }
#endif // YY_EXCEPTIONS]], [[ #endif // YY_EXCEPTIONS]], [[
*yycharp = ]b4_lex[;]])[ *yycharp = ]b4_yylex[;]])[
} }
if (*yycharp <= ]b4_symbol(eof, [id])[) if (*yycharp <= ]b4_symbol(eof, [id])[)
{ {

View File

@@ -173,10 +173,10 @@ m4_define([b4_call_merger],
[yy0.b4_symbol($3, slot) = $2 (yy0, yy1);])], [yy0.b4_symbol($3, slot) = $2 (yy0, yy1);])],
[yy0 = $2 (yy0, yy1);])])]) [yy0 = $2 (yy0, yy1);])])])
# b4_lex # b4_yylex
# ------ # --------
# Call yylex. # Call yylex.
m4_define([b4_lex], m4_define([b4_yylex],
[b4_token_ctor_if( [b4_token_ctor_if(
[b4_function_call([yylex], [b4_function_call([yylex],
[symbol_type], m4_ifdef([b4_lex_param], b4_lex_param))], [symbol_type], m4_ifdef([b4_lex_param], b4_lex_param))],
@@ -3102,14 +3102,14 @@ private:
#endif // YY_EXCEPTIONS #endif // YY_EXCEPTIONS
{]b4_token_ctor_if([[ {]b4_token_ctor_if([[
typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_type symbol_type; typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_type symbol_type;
symbol_type yylookahead = ]b4_lex[; symbol_type yylookahead = ]b4_yylex[;
this->yytoken = yylookahead.kind ();]b4_variant_if([[ this->yytoken = yylookahead.kind ();]b4_variant_if([[
]b4_symbol_variant([this->yytoken], ]b4_symbol_variant([this->yytoken],
[this->yylval], [move], [yylookahead.value])], [[ [this->yylval], [move], [yylookahead.value])], [[
this->yylval = yylookahead.value;]])[]b4_locations_if([ this->yylval = yylookahead.value;]])[]b4_locations_if([
this->yylloc = yylookahead.location; this->yylloc = yylookahead.location;
yylookahead.kind_ = symbol_kind::S_YYEMPTY;])[]], [[ yylookahead.kind_ = symbol_kind::S_YYEMPTY;])[]], [[
yychar = ]b4_lex[;]])[ yychar = ]b4_yylex[;]])[
} }
#if YY_EXCEPTIONS #if YY_EXCEPTIONS
} }

View File

@@ -145,10 +145,10 @@ b4_dollar_popdef[]dnl
])]) ])])
# b4_lex # b4_yylex
# ------ # --------
# Call yylex. # Call yylex.
m4_define([b4_lex], m4_define([b4_yylex],
[b4_token_ctor_if( [b4_token_ctor_if(
[b4_function_call([yylex], [b4_function_call([yylex],
[symbol_type], m4_ifdef([b4_lex_param], b4_lex_param))], [symbol_type], m4_ifdef([b4_lex_param], b4_lex_param))],
@@ -912,9 +912,9 @@ b4_dollar_popdef])[]dnl
try try
#endif // YY_EXCEPTIONS #endif // YY_EXCEPTIONS
{]b4_token_ctor_if([[ {]b4_token_ctor_if([[
symbol_type yylookahead (]b4_lex[); symbol_type yylookahead (]b4_yylex[);
yyla.move (yylookahead);]], [[ yyla.move (yylookahead);]], [[
yyla.kind_ = yytranslate_ (]b4_lex[);]])[ yyla.kind_ = yytranslate_ (]b4_yylex[);]])[
} }
#if YY_EXCEPTIONS #if YY_EXCEPTIONS
catch (const syntax_error& yyexc) catch (const syntax_error& yyexc)

View File

@@ -371,7 +371,7 @@ m4_define([b4_declare_yyerror_and_yylex],
]b4_function_declare([b4_prefix[error]], void, b4_yyerror_formals)[ ]b4_function_declare([b4_prefix[error]], void, b4_yyerror_formals)[
#endif #endif
#if !defined ]b4_prefix[lex && !defined ]b4_api_PREFIX[LEX_IS_DECLARED #if !defined ]b4_prefix[lex && !defined ]b4_api_PREFIX[LEX_IS_DECLARED
]b4_function_declare([b4_prefix[lex]], int, b4_lex_formals)[ ]b4_function_declare([b4_prefix[lex]], int, b4_yylex_formals)[
#endif #endif
]])dnl ]])dnl
]) ])
@@ -1532,7 +1532,7 @@ yypull_parse (yypstate *yyps]b4_user_formals[)
int yystatus; int yystatus;
do { do {
]b4_pure_if([[ YYSTYPE yylval; ]b4_pure_if([[ YYSTYPE yylval;
int ]])[yychar = ]b4_lex[; int ]])[yychar = ]b4_yylex[;
yystatus = yypush_parse (yyps]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[); yystatus = yypush_parse (yyps]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[);
} while (yystatus == YYPUSH_MORE); } while (yystatus == YYPUSH_MORE);
return yystatus; return yystatus;
@@ -1836,7 +1836,7 @@ yyread_pushed_token:]])[
yylval = *yypushed_val;]b4_locations_if([[ yylval = *yypushed_val;]b4_locations_if([[
if (yypushed_loc) if (yypushed_loc)
yylloc = *yypushed_loc;]])])], [[ yylloc = *yypushed_loc;]])])], [[
yychar = ]b4_lex[;]])[ yychar = ]b4_yylex[;]])[
} }
if (yychar <= ]b4_symbol(eof, [id])[) if (yychar <= ]b4_symbol(eof, [id])[)