Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ support for custom error messages #28

Merged
merged 5 commits into from Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions data/skeletons/glr.c
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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);]],
Expand Down Expand Up @@ -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)
Expand All @@ -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], [[
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, please, remove this space.

yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);]], [[
yyp = yystpcpy (yyp, yysymbol_name (yyarg[yyi++]));]])[
yyformat += 2;
Expand Down