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

Add user argument to some macros, moved from ruby/ruby to ruby/lrama #40

Merged
merged 2 commits into from
Jun 11, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ jobs:
- run: mkdir -p tool/lrama
working-directory: ../ruby
- name: Copy Lrama to ruby/tool
run: cp -r exe lib ../ruby/tool/lrama
# TODO: Consider how to manage changes on ruby/ruby master and ruby/lrama
# run: cp -r exe lib template ../ruby/tool/lrama
run: cp -r exe lib template ../ruby/tool/lrama
working-directory:
- run: tree tool/lrama
working-directory: ../ruby
Expand Down
56 changes: 0 additions & 56 deletions spec/integration/ruby_spec.rb

This file was deleted.

66 changes: 34 additions & 32 deletions template/bison/yacc.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
#if YYDEBUG && !defined(yydebug)
extern int yydebug;
#endif
<%-# b4_percent_code_get([[requires]]). %code is not supported -%>
Expand Down Expand Up @@ -731,7 +731,7 @@ do { \

/* Temporary convenience wrapper in case some people defined the
undocumented and private YY_LOCATION_PRINT macros. */
# define YYLOCATION_PRINT(File, Loc) YY_LOCATION_PRINT(File, *(Loc))
# define YYLOCATION_PRINT(File, Loc<%= output.user_args %>) YY_LOCATION_PRINT(File, *(Loc)<%= output.user_args %>)

# elif defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL

Expand Down Expand Up @@ -767,11 +767,11 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)

/* Temporary convenience wrapper in case some people defined the
undocumented and private YY_LOCATION_PRINT macros. */
# define YY_LOCATION_PRINT(File, Loc) YYLOCATION_PRINT(File, &(Loc))
# define YY_LOCATION_PRINT(File, Loc<%= output.user_args %>) YYLOCATION_PRINT(File, &(Loc)<%= output.user_args %>)

# else

# define YYLOCATION_PRINT(File, Loc) ((void) 0)
# define YYLOCATION_PRINT(File, Loc<%= output.user_args %>) ((void) 0)
/* Temporary convenience wrapper in case some people defined the
undocumented and private YY_LOCATION_PRINT macros. */
# define YY_LOCATION_PRINT YYLOCATION_PRINT
Expand All @@ -780,13 +780,13 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
# endif /* !defined YYLOCATION_PRINT */


# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location<%= output.user_args %>) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Kind, Value, Location, p); \
Kind, Value, Location<%= output.user_args %>); \
YYFPRINTF (stderr, "\n"); \
} \
} while (0)
Expand Down Expand Up @@ -828,9 +828,9 @@ yy_symbol_print (FILE *yyo,
YYFPRINTF (yyo, "%s %s (",
yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));

YYLOCATION_PRINT (yyo, yylocationp);
YYLOCATION_PRINT (yyo, yylocationp<%= output.user_args %>);
YYFPRINTF (yyo, ": ");
yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp, p);
yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp<%= output.user_args %>);
YYFPRINTF (yyo, ")");
}

Expand All @@ -840,7 +840,7 @@ yy_symbol_print (FILE *yyo,
`------------------------------------------------------------------*/

static void
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop<%= output.user_formals %>)
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
Expand All @@ -851,10 +851,10 @@ yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
YYFPRINTF (stderr, "\n");
}

# define YY_STACK_PRINT(Bottom, Top) \
# define YY_STACK_PRINT(Bottom, Top<%= output.user_args %>) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
yy_stack_print ((Bottom), (Top)<%= output.user_args %>); \
} while (0)


Expand All @@ -878,25 +878,27 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp,
yy_symbol_print (stderr,
YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
&yyvsp[(yyi + 1) - (yynrhs)],
&(yylsp[(yyi + 1) - (yynrhs)]), p);
&(yylsp[(yyi + 1) - (yynrhs)])<%= output.user_args %>);
YYFPRINTF (stderr, "\n");
}
}

# define YY_REDUCE_PRINT(Rule) \
# define YY_REDUCE_PRINT(Rule<%= output.user_args %>) \
do { \
if (yydebug) \
yy_reduce_print (yyssp, yyvsp, yylsp, Rule, p); \
yy_reduce_print (yyssp, yyvsp, yylsp, Rule<%= output.user_args %>); \
} while (0)

/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
#ifndef yydebug
int yydebug;
#endif
#else /* !YYDEBUG */
# define YYDPRINTF(Args) ((void) 0)
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location<%= output.user_args %>)
# define YY_STACK_PRINT(Bottom, Top<%= output.user_args %>)
# define YY_REDUCE_PRINT(Rule<%= output.user_args %>)
#endif /* !YYDEBUG */


Expand Down Expand Up @@ -1110,7 +1112,7 @@ yy_syntax_error_arguments (const yypcontext_t *yyctx,
required number of bytes is too large to store. */
static int
yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
const yypcontext_t *yyctx)
const yypcontext_t *yyctx<%= output.user_formals %>)
{
enum { YYARGS_MAX = 5 };
/* Internationalized format string. */
Expand Down Expand Up @@ -1200,7 +1202,7 @@ yydestruct (const char *yymsg,
<%= output.parse_param_use("yyvaluep", "yylocationp") %>
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp<%= output.user_args %>);

YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YY_USE (yykind);
Expand All @@ -1227,11 +1229,11 @@ int yychar;
/* The semantic value of the lookahead symbol. */
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YY_INITIAL_VALUE (static const YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);

/* Location data for the lookahead symbol. */
static YYLTYPE yyloc_default
static const YYLTYPE yyloc_default
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
= { 1, 1, 1, 1 }
# endif
Expand Down Expand Up @@ -1322,7 +1324,7 @@ YYLTYPE yylloc = yyloc_default;
YY_IGNORE_USELESS_CAST_BEGIN
*yyssp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
YY_STACK_PRINT (yyss, yyssp);
YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);

if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
Expand Down Expand Up @@ -1440,7 +1442,7 @@ YYLTYPE yylloc = yyloc_default;
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc<%= output.user_args %>);
}

/* If the proper action on seeing token YYTOKEN is to reduce or to
Expand All @@ -1463,7 +1465,7 @@ YYLTYPE yylloc = yyloc_default;
yyerrstatus--;

/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc<%= output.user_args %>);
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
Expand Down Expand Up @@ -1505,7 +1507,7 @@ YYLTYPE yylloc = yyloc_default;
/* Default location. */
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
yyerror_range[1] = yyloc;
YY_REDUCE_PRINT (yyn);
YY_REDUCE_PRINT (yyn<%= output.user_args %>);
switch (yyn)
{
<%= output.user_actions -%>
Expand All @@ -1523,7 +1525,7 @@ YYLTYPE yylloc = yyloc_default;
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc<%= output.user_args %>);

YYPOPSTACK (yylen);
yylen = 0;
Expand Down Expand Up @@ -1561,7 +1563,7 @@ YYLTYPE yylloc = yyloc_default;
= {yyssp, yytoken, &yylloc};
char const *yymsgp = YY_("syntax error");
int yysyntax_error_status;
yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx<%= output.user_args %>);
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == -1)
Expand All @@ -1573,7 +1575,7 @@ YYLTYPE yylloc = yyloc_default;
if (yymsg)
{
yysyntax_error_status
= yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
= yysyntax_error (&yymsg_alloc, &yymsg, &yyctx<%= output.user_args %>);
yymsgp = yymsg;
}
else
Expand Down Expand Up @@ -1628,7 +1630,7 @@ YYLTYPE yylloc = yyloc_default;
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
yystate = *yyssp;
goto yyerrlab1;

Expand Down Expand Up @@ -1663,7 +1665,7 @@ YYLTYPE yylloc = yyloc_default;
YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp<%= output.user_args %>);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
}

YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Expand All @@ -1675,7 +1677,7 @@ YYLTYPE yylloc = yyloc_default;
YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);

/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp<%= output.user_args %>);

yystate = yyn;
goto yynewstate;
Expand Down Expand Up @@ -1721,7 +1723,7 @@ YYLTYPE yylloc = yyloc_default;
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
Expand Down