[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/7] tests: glr: run the glr regression tests with glr.cc
From: |
Akim Demaille |
Subject: |
[PATCH 7/7] tests: glr: run the glr regression tests with glr.cc |
Date: |
Sat, 5 Dec 2020 11:30:57 +0100 |
* tests/glr-regression.at: Adjust the tests to be more independent of
the language, and run them with glr.cc.
Some tests relied on yychar, yylval and yylloc being global variables:
pass arguments instead.
---
tests/glr-regression.at | 270 +++++++++++++++++++++++++---------------
1 file changed, 171 insertions(+), 99 deletions(-)
diff --git a/tests/glr-regression.at b/tests/glr-regression.at
index 64bb396a..47090bef 100644
--- a/tests/glr-regression.at
+++ b/tests/glr-regression.at
@@ -18,6 +18,19 @@
AT_BANNER([[GLR Regression Tests]])
+m4_pushdef([AT_YYPARSE_DEFINE],
+[AT_CXX_IF([[
+static int
+yyparse ()
+{
+ ]AT_NAMESPACE[::parser p;]AT_DEBUG_IF([[
+ int debug = !!getenv ("YYDEBUG");
+ p.set_debug_level (debug);]])[
+ return p.parse ();
+}
+]])])
+
+
## ---------------------------- ##
## Badly Collapsed GLR States. ##
## ---------------------------- ##
@@ -66,8 +79,17 @@ static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1)
return 0;
}
+]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
+
const char *input = YY_NULLPTR;
+]AT_YYLEX_PROTOTYPE[
+{
+ ]AT_USE_LEX_ARGS[
+ return *input++;
+}
+
int
main (int argc, const char* argv[])
{
@@ -75,14 +97,6 @@ main (int argc, const char* argv[])
input = argv[1];
return yyparse ();
}
-
-]AT_YYERROR_DEFINE[
-
-]AT_YYLEX_PROTOTYPE[
-{
- ]AT_USE_LEX_ARGS[
- return *input++;
-}
]])
AT_FULL_COMPILE([glr-regr1])
@@ -103,6 +117,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -194,13 +209,15 @@ FILE *input;
assert (strlen (buf) < sizeof buf - 1);
s = YY_CAST (char *, malloc (strlen (buf) + 1));
strcpy (s, buf);
- yylval = s;
+ ]AT_VAL[ = s;
return 'V';
}
break;
}
}
+]AT_YYPARSE_DEFINE[
+
int
main (int argc, char **argv)
{
@@ -244,6 +261,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -320,13 +338,14 @@ MergeRule (int x0, int x1)
FILE *input = YY_NULLPTR;
-int P[] = { P1, P2 };
-int O[] = { O1, O2 };
-int T[] = { T1, T2, T3, T4 };
+int P[] = { ]AT_TOKEN([P1])[, ]AT_TOKEN([P2])[ };
+int O[] = { ]AT_TOKEN([O1])[, ]AT_TOKEN([O2])[ };
+int T[] = { ]AT_TOKEN([T1])[, ]AT_TOKEN([T2])[, ]AT_TOKEN([T3])[,
]AT_TOKEN([T4])[ };
-int yylex (void)
+]AT_YYLEX_PROTOTYPE[
{
char inp[3];
+ ]AT_USE_LEX_ARGS[
assert (!feof (stdin));
if (fscanf (input, "%2s", inp) == EOF)
return 0;
@@ -336,9 +355,11 @@ int yylex (void)
case 't': return T[inp[1] - '1'];
case 'o': return O[inp[1] - '1'];
}
- return BAD_CHAR;
+ return ]AT_TOKEN([BAD_CHAR])[;
}
+]AT_YYPARSE_DEFINE[
+
int
main (int argc, char* argv[])
{
@@ -368,6 +389,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -420,6 +442,7 @@ B: 'a' { $$ = make_value ("B", "'a'"); } ;
%%
]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
]AT_YYLEX_DEFINE(["a"])[
int
@@ -463,6 +486,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -525,6 +549,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -581,6 +606,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -636,22 +662,24 @@ stack2: 'a' ;
%%
-static int
-yylex (void)
+]AT_YYLEX_PROTOTYPE[
{
- yylval.node = YY_CAST (count_node*, malloc (sizeof *yylval.node));
- if (!yylval.node)
+ ]AT_USE_LEX_ARGS[
+ ]AT_VAL[.node = YY_CAST (count_node*, malloc (sizeof *]AT_VAL[.node));
+ if (!]AT_VAL[.node)
{
fprintf (stderr, "Test inconclusive.\n");
exit (EXIT_FAILURE);
}
- yylval.node->count = 0;
- yylval.node->prev = tail;
- tail = yylval.node;
+ ]AT_VAL[.node->count = 0;
+ ]AT_VAL[.node->prev = tail;
+ tail = ]AT_VAL[.node;
return 'a';
}
]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
+
int
main (void)
{
@@ -677,6 +705,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -692,7 +721,7 @@ m4_popdef([AT_TEST])
m4_pushdef([AT_TEST],
[AT_SETUP([Incorrectly initialized location for empty right-hand side in GLR:
$1])
-AT_BISON_OPTION_PUSHDEFS([%glr-parser $1])
+AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations $1])
AT_DATA_GRAMMAR([glr-regr8.y],
[[
%code {
@@ -714,9 +743,9 @@ AT_DATA_GRAMMAR([glr-regr8.y],
PortClause : T_PORT InterfaceDeclaration T_PORT
{ printf("%d/%d - %d/%d - %d/%d\n",
- @1.first_column, @1.last_column,
- @2.first_column, @2.last_column,
- @3.first_column, @3.last_column); }
+ @1.]AT_FIRST_COLUMN[, @1.]AT_LAST_COLUMN[,
+ @2.]AT_FIRST_COLUMN[, @2.]AT_LAST_COLUMN[,
+ @3.]AT_FIRST_COLUMN[, @3.]AT_LAST_COLUMN[); }
;
InterfaceDeclaration : OptConstantWord %dprec 1
@@ -728,7 +757,7 @@ OptConstantWord : %empty
;
OptSignalWord : %empty
- { printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
+ { printf("empty: %d/%d\n", @$.]AT_FIRST_COLUMN[,
@$.]AT_LAST_COLUMN[); }
| T_SIGNAL
;
@@ -737,21 +766,22 @@ OptSignalWord : %empty
]AT_YYERROR_DEFINE[
static int lexIndex;
-int yylex (void)
+]AT_YYLEX_PROTOTYPE[
{
+ ]AT_USE_LEX_ARGS[
lexIndex += 1;
switch (lexIndex)
{
default:
abort ();
case 1:
- yylloc.first_column = 1;
- yylloc.last_column = 9;
- return T_PORT;
+ ]AT_LOC_FIRST_COLUMN[ = 1;
+ ]AT_LOC_LAST_COLUMN[ = 9;
+ return ]AT_TOKEN([T_PORT])[;
case 2:
- yylloc.first_column = 13;
- yylloc.last_column = 17;
- return T_PORT;
+ ]AT_LOC_FIRST_COLUMN[ = 13;
+ ]AT_LOC_LAST_COLUMN[ = 17;
+ return ]AT_TOKEN([T])[_PORT;
case 3:
return 0;
}
@@ -773,6 +803,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -824,14 +855,16 @@ ambig2: 'a' ;
%%
-static int
-yylex (void)
+]AT_YYLEX_PROTOTYPE[
{
+ ]AT_USE_LEX_ARGS[
tokens += 1;
return 'a';
}
]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
+
int
main (void)
{
@@ -857,6 +890,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -896,6 +930,7 @@ start:
%%
]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
]AT_YYLEX_DEFINE[
int
@@ -917,6 +952,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -958,6 +994,7 @@ start:
%%
]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
]AT_YYLEX_DEFINE(["a"])[
int
@@ -982,6 +1019,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -1074,8 +1112,9 @@ merge (YYSTYPE s1, YYSTYPE s2)
}
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([{ PARENT_RHS_AFTER, 0 }],
- [if (res == PARENT_RHS_AFTER)
+]AT_YYPARSE_DEFINE[
+]AT_YYLEX_DEFINE([{ ]AT_TOKEN([PARENT_RHS_AFTER])[, 0 }],
+ [if (res == ]AT_TOKEN([PARENT_RHS_AFTER])[)
parent_rhs_after_value = 1;])[
int
@@ -1110,6 +1149,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -1124,7 +1164,7 @@ m4_popdef([AT_TEST])
m4_pushdef([AT_TEST],
[AT_SETUP([Incorrect lookahead during deterministic GLR: $1])
-AT_BISON_OPTION_PUSHDEFS([%glr-parser $1])
+AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations $1])
AT_DATA_GRAMMAR([glr-regr13.y],
[[
/* Tests:
@@ -1138,7 +1178,9 @@ AT_DATA_GRAMMAR([glr-regr13.y],
#include <assert.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
- static void print_lookahead (char const *);
+ static void
+ print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
+ char const *reduction);
#define USE(value)
}
@@ -1155,32 +1197,32 @@ AT_DATA_GRAMMAR([glr-regr13.y],
start:
defstate_init defstate_shift 'b' change_lookahead 'a' {
USE ($][3);
- print_lookahead ("start <- defstate_init defstate_shift 'b'");
+ print_lookahead (yychar, &yylval, &yylloc, "start <- defstate_init
defstate_shift 'b'");
}
;
defstate_init:
{
- print_lookahead ("defstate_init <- empty string");
+ print_lookahead (yychar, &yylval, &yylloc, "defstate_init <- empty
string");
}
;
defstate_shift:
nondefstate defstate_look 'a' {
USE ($][3);
- print_lookahead ("defstate_shift <- nondefstate defstate_look 'a'");
+ print_lookahead (yychar, &yylval, &yylloc, "defstate_shift <- nondefstate
defstate_look 'a'");
}
;
defstate_look:
{
- print_lookahead ("defstate_look <- empty string");
+ print_lookahead (yychar, &yylval, &yylloc, "defstate_look <- empty
string");
}
;
nondefstate:
{
- print_lookahead ("nondefstate <- empty string");
+ print_lookahead (yychar, &yylval, &yylloc, "nondefstate <- empty string");
}
| 'b' {
USE ($][1);
- print_lookahead ("nondefstate <- 'b'");
+ print_lookahead (yychar, &yylval, &yylloc, "nondefstate <- 'b'");
}
;
change_lookahead:
@@ -1192,25 +1234,27 @@ change_lookahead:
%%
]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
]AT_YYLEX_DEFINE(["ab"],
- [yylval.value = YY_CAST (char, res + 'A' - 'a')])[
+ []AT_VAL[.value = YY_CAST (char, res + 'A' - 'a')])[
static void
-print_lookahead (char const *reduction)
+print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
+ char const *reduction)
{
printf ("%s:\n yychar=", reduction);
- if (yychar == YYEMPTY)
+ if (yychr == ]AT_TOKEN([YYEMPTY])[)
printf ("YYEMPTY");
- else if (yychar == YYEOF)
+ else if (yychr == ]AT_TOKEN([YYEOF])[)
printf ("YYEOF");
else
{
- printf ("'%c', yylval='", yychar);
- if (yylval.value > ' ')
- printf ("%c", yylval.value);
+ printf ("'%c', yylval='", yychr);
+ if (yylvalp->value > ' ')
+ printf ("%c", yylvalp->value);
printf ("', yylloc=(%d,%d),(%d,%d)",
- yylloc.first_line, yylloc.first_column,
- yylloc.last_line, yylloc.last_column);
+ yyllocp->]AT_FIRST_LINE[, yyllocp->]AT_FIRST_COLUMN[,
+ yyllocp->]AT_LAST_LINE[, yyllocp->]AT_LAST_COLUMN[);
}
printf ("\n");
}
@@ -1218,8 +1262,10 @@ print_lookahead (char const *reduction)
int
main (void)
{
+]AT_CXX_IF([], [[
yychar = '#'; /* Not a token in the grammar. */
yylval.value = '!';
+]])[
return yyparse ();
}
]])
@@ -1244,6 +1290,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -1256,7 +1303,7 @@ m4_popdef([AT_TEST])
m4_pushdef([AT_TEST],
[AT_SETUP([Incorrect lookahead during nondeterministic GLR: $1])
-AT_BISON_OPTION_PUSHDEFS([%glr-parser $1])
+AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations $1])
AT_DATA_GRAMMAR([glr-regr14.y],
[[
/* Tests:
@@ -1292,7 +1339,9 @@ AT_DATA_GRAMMAR([glr-regr14.y],
#include <assert.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
- static void print_lookahead (char const *);
+ static void
+ print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
+ char const *reduction);
static char merge (union YYSTYPE, union YYSTYPE);
#define USE(value)
}
@@ -1302,7 +1351,7 @@ AT_DATA_GRAMMAR([glr-regr14.y],
start:
merge 'c' stack_explosion {
USE ($][2); USE ($][3);
- print_lookahead ("start <- merge 'c' stack_explosion");
+ print_lookahead (yychar, &yylval, &yylloc, "start <- merge 'c'
stack_explosion");
}
;
@@ -1310,44 +1359,44 @@ start:
merge:
nonconflict1 'a' 'b' nonconflict2 %dprec 1 {
USE ($][2); USE ($][3);
- print_lookahead ("merge <- nonconflict1 'a' 'b' nonconflict2");
+ print_lookahead (yychar, &yylval, &yylloc, "merge <- nonconflict1 'a' 'b'
nonconflict2");
}
| conflict defstate_look 'a' nonconflict2 'b' defstate_shift %dprec 2 {
USE ($][3); USE ($][5);
- print_lookahead ("merge <- conflict defstate_look 'a' nonconflict2 'b'"
+ print_lookahead (yychar, &yylval, &yylloc, "merge <- conflict
defstate_look 'a' nonconflict2 'b'"
" defstate_shift");
}
;
nonconflict1:
{
- print_lookahead ("nonconflict1 <- empty string");
+ print_lookahead (yychar, &yylval, &yylloc, "nonconflict1 <- empty string");
}
;
nonconflict2:
{
- print_lookahead ("nonconflict2 <- empty string");
+ print_lookahead (yychar, &yylval, &yylloc, "nonconflict2 <- empty string");
}
| 'a' {
USE ($][1);
- print_lookahead ("nonconflict2 <- 'a'");
+ print_lookahead (yychar, &yylval, &yylloc, "nonconflict2 <- 'a'");
}
;
conflict:
{
- print_lookahead ("conflict <- empty string");
+ print_lookahead (yychar, &yylval, &yylloc, "conflict <- empty string");
}
;
defstate_look:
{
- print_lookahead ("defstate_look <- empty string");
+ print_lookahead (yychar, &yylval, &yylloc, "defstate_look <- empty
string");
}
;
/* yychar != YYEMPTY but lookahead need is yyfalse. */
defstate_shift:
{
- print_lookahead ("defstate_shift <- empty string");
+ print_lookahead (yychar, &yylval, &yylloc, "defstate_shift <- empty
string");
}
;
@@ -1397,49 +1446,54 @@ no_look:
%%
]AT_YYERROR_DEFINE[
-static int
-yylex (void)
+]AT_YYPARSE_DEFINE[
+]AT_YYLEX_PROTOTYPE[
{
+ ]AT_USE_LEX_ARGS[
static char const input[] = "abcdddd";
static int toknum = 0;
assert (toknum < YY_CAST (int, sizeof input));
- yylloc.first_line = yylloc.last_line = 1;
- yylloc.first_column = yylloc.last_column = toknum + 1;
- yylval.value = YY_CAST (char, input[toknum] + 'A' - 'a');
+ ]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
+ ]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = toknum + 1;
+ ]AT_VAL[.value = YY_CAST (char, input[toknum] + 'A' - 'a');
return input[toknum++];
}
+static char
+merge (union YYSTYPE s1, union YYSTYPE s2)
+{
+ return YY_CAST (char, s1.value + s2.value);
+}
+
+/* FIXME: Factor duplicate. Possibly use yy_symbol_print. */
static void
-print_lookahead (char const *reduction)
+print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
+ char const *reduction)
{
printf ("%s:\n yychar=", reduction);
- if (yychar == YYEMPTY)
+ if (yychr == ]AT_TOKEN([YYEMPTY])[)
printf ("YYEMPTY");
- else if (yychar == YYEOF)
+ else if (yychr == ]AT_TOKEN([YYEOF])[)
printf ("YYEOF");
else
{
- printf ("'%c', yylval='", yychar);
- if (yylval.value > ' ')
- printf ("%c", yylval.value);
+ printf ("'%c', yylval='", yychr);
+ if (yylvalp->value > ' ')
+ printf ("%c", yylvalp->value);
printf ("', yylloc=(%d,%d),(%d,%d)",
- yylloc.first_line, yylloc.first_column,
- yylloc.last_line, yylloc.last_column);
+ yyllocp->]AT_FIRST_LINE[, yyllocp->]AT_FIRST_COLUMN[,
+ yyllocp->]AT_LAST_LINE[, yyllocp->]AT_LAST_COLUMN[);
}
printf ("\n");
}
-static char
-merge (union YYSTYPE s1, union YYSTYPE s2)
-{
- return YY_CAST (char, s1.value + s2.value);
-}
-
int
main (void)
{
+]AT_CXX_IF([], [[
yychar = '#'; /* Not a token in the grammar. */
yylval.value = '!';
+]])[
return yyparse ();
}
]])
@@ -1466,6 +1520,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -1530,6 +1585,7 @@ ambiguity2: ;
%%
]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
]AT_YYLEX_DEFINE[
int
@@ -1556,6 +1612,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -1596,6 +1653,7 @@ alt2: ;
%%
]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
]AT_YYLEX_DEFINE(["ab"],
[if (res == 'b')
lookahead_value = 1])[
@@ -1624,6 +1682,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -1636,7 +1695,7 @@ m4_popdef([AT_TEST])
m4_pushdef([AT_TEST],
[AT_SETUP([Uninitialized location when reporting ambiguity: $1])
-AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations %define api.pure $1])
+AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations $1])
AT_DATA_GRAMMAR([glr-regr17.y],
[[
@@ -1646,7 +1705,6 @@ AT_DATA_GRAMMAR([glr-regr17.y],
%expect-rr 3
]$1[
%locations
-%define api.pure
%define parse.error verbose
%union { int dummy; }
@@ -1679,16 +1737,17 @@ empty2: ;
# include <assert.h>
]AT_YYERROR_DEFINE[
-static int
-yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
+
+]AT_YYLEX_PROTOTYPE[
{
static char const input[] = "ab";
static int toknum = 0;
+ ]AT_USE_LEX_ARGS[
assert (toknum < YY_CAST (int, sizeof input));
lvalp->dummy = 0;
- llocp->first_line = llocp->last_line = 2;
- llocp->first_column = toknum + 1;
- llocp->last_column = llocp->first_column + 1;
+ ]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 2;
+ ]AT_LOC_FIRST_COLUMN[ = toknum + 1;
+ ]AT_LOC_LAST_COLUMN[ = ]AT_LOC_FIRST_COLUMN[ + 1;
return input[toknum++];
}
@@ -1705,7 +1764,8 @@ AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
-AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.c" %define api.pure])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -1734,6 +1794,9 @@ AT_DATA_GRAMMAR([glr-regr18.y],
int type2;
int type3;
}
+]AT_CXX_IF([[
+// In C++ we need one more line for the line numbers to match.
+]])[
%%
sym1: sym2 %merge<merge> { $$ = $][1; } ;
@@ -1751,10 +1814,10 @@ sym3: %merge<merge> { $$ = 0; } ;
]])
AT_BISON_CHECK([[-o glr-regr18.c -rall glr-regr18.y]], 1, [],
-[[glr-regr18.y:28.18-24: error: result type clash on merge function 'merge':
<type2> != <type1>
-glr-regr18.y:27.18-24: note: previous declaration
-glr-regr18.y:29.13-19: error: result type clash on merge function 'merge':
<type3> != <type2>
+[[glr-regr18.y:29.18-24: error: result type clash on merge function 'merge':
<type2> != <type1>
glr-regr18.y:28.18-24: note: previous declaration
+glr-regr18.y:30.13-19: error: result type clash on merge function 'merge':
<type3> != <type2>
+glr-regr18.y:29.18-24: note: previous declaration
]])
AT_BISON_OPTION_POPDEFS
@@ -1762,6 +1825,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -1787,7 +1851,9 @@ AT_DATA_GRAMMAR([input.y],
%expect 0
%expect-rr 1
]$1[
-
+]AT_CXX_IF([[
+// In C++ we need two more lines for the line numbers in the trace to match.
+]])[
%%
start:
@@ -1871,6 +1937,7 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
@@ -1894,7 +1961,7 @@ AT_DATA_GRAMMAR([input.y],
%expect-rr 1
]$1[
-%code requires
+%code
{
#include <assert.h>
#include <stdbool.h>
@@ -1913,10 +1980,11 @@ new_args: 'n';
old_args: 'o';
%%
]AT_YYERROR_DEFINE[
+]AT_YYPARSE_DEFINE[
-int
-yylex (void)
+]AT_YYLEX_PROTOTYPE[
{
+ ]AT_USE_LEX_ARGS[
return *input++;
}
@@ -1945,5 +2013,9 @@ AT_CLEANUP
])
AT_TEST([%skeleton "glr.c"])
+AT_TEST([%skeleton "glr.cc"])
m4_popdef([AT_TEST])
+
+
+m4_popdef([AT_YYPARSE_DEFINE])
--
2.29.2
- [PATCH 0/7] tests: glr: run the glr regression tests with glr.cc, Akim Demaille, 2020/12/05
- [PATCH 1/7] glr.cc: don't "leak" yyparse, Akim Demaille, 2020/12/05
- [PATCH 2/7] tests: formatting changes, Akim Demaille, 2020/12/05
- [PATCH 3/7] tests: factor the access to token kinds, Akim Demaille, 2020/12/05
- [PATCH 4/7] tests: glr: prefer directives to warnings, Akim Demaille, 2020/12/05
- [PATCH 5/7] tests: glr: use AT_FULL_COMPILE, Akim Demaille, 2020/12/05
- [PATCH 6/7] tests: glr: prepare for more languages, Akim Demaille, 2020/12/05
- [PATCH 7/7] tests: glr: run the glr regression tests with glr.cc,
Akim Demaille <=