summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorAdrian Vogelsgesang <avogelsgesang@tableau.com>2020-02-13 10:22:21 +0100
committerAkim Demaille <akim.demaille@gmail.com>2020-02-27 18:13:43 +0100
commitd4fcd5c3d0508bd18e2e5b79bd89c905b4b7a4eb (patch)
treeadc6b6d1df3f662665ad6d581e4649e076ea07ef /data
parent368fcf0af561d0d84935b13dd9d30e2012cf843f (diff)
downloadbison-d4fcd5c3d0508bd18e2e5b79bd89c905b4b7a4eb.tar.gz
skeletons: prefer b4_parse_error_{case,bmatch} over manual solution
Prefer b4_parse_error_case over the adhoc solution `m4_case + b4_percent_define_get`. Same for b4_parse_error_bmatch. * data/skeletons/glr.c: here * data/skeletons/yacc.c: here
Diffstat (limited to 'data')
-rw-r--r--data/skeletons/glr.c16
-rw-r--r--data/skeletons/lalr1.java8
-rw-r--r--data/skeletons/yacc.c19
3 files changed, 21 insertions, 22 deletions
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index 39b56a65..f68ec3b4 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -700,14 +700,14 @@ static void yypdumpstack (yyGLRStack* yystackp)
#endif /* !]b4_api_PREFIX[DEBUG */
-]m4_case(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_case(
[simple],
[[]],
[[#ifndef yystrlen
# define yystrlen(S) (YY_CAST (ptrdiff_t, strlen (S)))
#endif
-]m4_bmatch(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_bmatch(
[detailed\|verbose],
[[#ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
@@ -729,7 +729,7 @@ yystpcpy (char *yydest, const char *yysrc)
# endif
#endif]])[
-]m4_case(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_case(
[verbose],
[[#ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
@@ -2089,7 +2089,7 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
return yyok;
}
-]m4_if(b4_percent_define_get([[parse.error]]), [simple], [],
+]b4_parse_error_case([simple], [],
[[/* Put in YYARG at most YYARGN of the expected tokens given the
current YYSTACKP, and return the number of tokens stored in YYARG. If
YYARG is null, return the number of expected tokens (guaranteed to
@@ -2175,7 +2175,7 @@ yysyntax_error_arguments (const yyGLRStack* yystackp,
}
]])[
-]m4_case(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_case(
[custom],
[[/* User defined function to report a syntax error. */
typedef yyGLRStack yyparse_context_t;
@@ -2199,7 +2199,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
{
if (yystackp->yyerrState != 0)
return;
-]m4_case(b4_percent_define_get([parse.error]),
+]b4_parse_error_case(
[custom],
[[ if (yyreport_syntax_error (yystackp]b4_user_args[))
yyMemoryExhausted (yystackp);]],
@@ -2247,7 +2247,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
for (yyi = 0; yyi < yycount; ++yyi)
{
ptrdiff_t yysz
- = ]m4_case(b4_percent_define_get([[parse.error]]),
+ = ]b4_parse_error_case(
[verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]],
[[yystrlen (yysymbol_name (yyarg[yyi]))]]);[
if (YYSIZEMAX - yysize < yysz)
@@ -2267,7 +2267,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
while ((*yyp = *yyformat))
{
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
- {]m4_case(b4_percent_define_get([[parse.error]]), [verbose], [[
+ {]b4_parse_error_case([verbose], [[
yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);]], [[
yyp = yystpcpy (yyp, yysymbol_name (yyarg[yyi++]));]])[
yyformat += 2;
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index 71b9f385..2bf17fd4 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -93,7 +93,7 @@ import java.text.MessageFormat;
{
]b4_identification[
][
-]m4_bmatch(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_bmatch(
[detailed\|verbose], [[
/**
* True if verbose error messages are enabled.
@@ -217,7 +217,7 @@ import java.text.MessageFormat;
*/
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);
-]m4_bmatch(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_bmatch(
[custom], [[
void yyreportSyntaxError (][Context yyctx);
]])[
@@ -958,7 +958,7 @@ b4_dollar_popdef[]dnl
* Report a syntax error.
*/
private void yyreportSyntaxError (Context yyctx)
- {]m4_bmatch(b4_percent_define_get([parse.error]),
+ {]b4_parse_error_bmatch(
[custom], [[
yylexer.yyreportSyntaxError (yyctx);]],
[detailed\|verbose], [[
@@ -1013,7 +1013,7 @@ b4_dollar_popdef[]dnl
]b4_parser_tables_define[
-]m4_bmatch(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_bmatch(
[simple\|verbose],
[[ /* Return YYSTR after stripping away unnecessary quotes and
backslashes, so that it's suitable for yyerror. The heuristic is
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 0662def4..31660c13 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -607,8 +607,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
YYSYMBOL. No bounds checking. */
static const char *yysymbol_name (int yysymbol) YY_ATTRIBUTE_UNUSED;
-]m4_bmatch(b4_percent_define_get([[parse.error]]),
- [simple\|verbose],
+]b4_parse_error_bmatch([simple\|verbose],
[[/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
@@ -1067,7 +1066,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
}
}]])[
-]m4_if(b4_percent_define_get([[parse.error]]), [simple], [],
+]b4_parse_error_case([simple], [],
[[typedef struct
{
yy_state_t *yyssp;
@@ -1185,7 +1184,7 @@ yysyntax_error_arguments (const yyparse_context_t *yyctx,
}
]])[
-]m4_case(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_case(
[custom],
[b4_locations_if([[/* The location of this context. */
static YYLTYPE *
@@ -1239,7 +1238,7 @@ yyparse_context_location (const yyparse_context_t *yyctx)
# endif
#endif
-]m4_case(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_case(
[verbose],
[[#ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
@@ -1345,7 +1344,7 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
for (yyi = 0; yyi < yycount; ++yyi)
{
YYPTRDIFF_T yysize1
- = yysize + ]m4_case(b4_percent_define_get([[parse.error]]),
+ = yysize + ]b4_parse_error_case(
[verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]],
[[yystrlen (yysymbol_name (yyarg[yyi]))]]);[
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
@@ -1372,7 +1371,7 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
- {]m4_case(b4_percent_define_get([[parse.error]]), [verbose], [[
+ {]b4_parse_error_case([verbose], [[
yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);]], [[
yyp = yystpcpy (yyp, yysymbol_name (yyarg[yyi++]));]])[
yyformat += 2;
@@ -1528,7 +1527,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
YYSTYPE yyval;]b4_locations_if([[
YYLTYPE yyloc;]])[
-]m4_bmatch(b4_percent_define_get([[parse.error]]), [detailed\|verbose],
+]b4_parse_error_bmatch([detailed\|verbose],
[[ /* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
@@ -1849,7 +1848,7 @@ yyerrlab:
if (!yyerrstatus)
{
++yynerrs;
-]m4_case(b4_percent_define_get([[parse.error]]),
+]b4_parse_error_case(
[custom],
[[ {
yyparse_context_t yyctx
@@ -2056,7 +2055,7 @@ yyreturn:
| yypushreturn -- ask for the next token. |
`-----------------------------------------*/
yypushreturn:]])[
-]m4_bmatch(b4_percent_define_get([[parse.error]]), [detailed\|verbose],
+]b4_parse_error_bmatch([detailed\|verbose],
[[ if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);]])[
return yyresult;