[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/11] glr: tests: more macros
From: |
Akim Demaille |
Subject: |
[PATCH 03/11] glr: tests: more macros |
Date: |
Sun, 10 Jan 2021 17:59:02 +0100 |
This will be useful to support changes in glr2.cc.
tests/glr-regression.at
(Incorrect lookahead during deterministic GLR)
(Incorrect lookahead during nondeterministc GLR):
Introduce and use PRINT_LOOKAHEAD.
---
tests/glr-regression.at | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/tests/glr-regression.at b/tests/glr-regression.at
index fdae54cf..53a6c784 100644
--- a/tests/glr-regression.at
+++ b/tests/glr-regression.at
@@ -1269,7 +1269,9 @@ AT_DATA_GRAMMAR([glr-regr13.y],
static void
print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
char const *reduction);
- #define USE(value)
+#define PRINT_LOOKAHEAD(Msg) \
+ print_lookahead (yychar, &yylval, &yylloc, Msg)
+#define USE(value)
}
%define parse.assert
@@ -1287,14 +1289,14 @@ start:
defstate_init defstate_shift 'b' change_lookahead 'a'
{
USE ($][3);
- print_lookahead (yychar, &yylval, &yylloc, "start <- defstate_init
defstate_shift 'b'");
+ PRINT_LOOKAHEAD ("start <- defstate_init defstate_shift 'b'");
}
;
defstate_init:
%empty
{
- print_lookahead (yychar, &yylval, &yylloc, "defstate_init <- empty
string");
+ PRINT_LOOKAHEAD ("defstate_init <- empty string");
}
;
@@ -1302,26 +1304,26 @@ defstate_shift:
nondefstate defstate_look 'a'
{
USE ($][3);
- print_lookahead (yychar, &yylval, &yylloc, "defstate_shift <-
nondefstate defstate_look 'a'");
+ PRINT_LOOKAHEAD ("defstate_shift <- nondefstate defstate_look 'a'");
}
;
defstate_look:
%empty
{
- print_lookahead (yychar, &yylval, &yylloc, "defstate_look <- empty
string");
+ PRINT_LOOKAHEAD ("defstate_look <- empty string");
}
;
nondefstate:
%empty
{
- print_lookahead (yychar, &yylval, &yylloc, "nondefstate <- empty
string");
+ PRINT_LOOKAHEAD ("nondefstate <- empty string");
}
| 'b'
{
USE ($][1);
- print_lookahead (yychar, &yylval, &yylloc, "nondefstate <- 'b'");
+ PRINT_LOOKAHEAD ("nondefstate <- 'b'");
}
;
@@ -1449,6 +1451,8 @@ AT_DATA_GRAMMAR([glr-regr14.y],
static void
print_lookahead (int yychr, ]AT_YYSTYPE[ *yylvalp, ]AT_YYLTYPE[ *yyllocp,
char const *reduction);
+#define PRINT_LOOKAHEAD(Msg) \
+ print_lookahead (yychar, &yylval, &yylloc, Msg)
static char merge (]AT_YYSTYPE[, ]AT_YYSTYPE[);
#define USE(value)
}
@@ -1459,7 +1463,7 @@ start:
merge 'c' stack_explosion
{
USE ($][2); USE ($][3);
- print_lookahead (yychar, &yylval, &yylloc, "start <- merge 'c'
stack_explosion");
+ PRINT_LOOKAHEAD ("start <- merge 'c' stack_explosion");
}
;
@@ -1468,12 +1472,12 @@ merge:
nonconflict1 'a' 'b' nonconflict2 %dprec 1
{
USE ($][2); USE ($][3);
- print_lookahead (yychar, &yylval, &yylloc, "merge <- nonconflict1 'a'
'b' nonconflict2");
+ PRINT_LOOKAHEAD ("merge <- nonconflict1 'a' 'b' nonconflict2");
}
| conflict defstate_look 'a' nonconflict2 'b' defstate_shift %dprec 2
{
USE ($][3); USE ($][5);
- print_lookahead (yychar, &yylval, &yylloc, "merge <- conflict
defstate_look 'a' nonconflict2 'b'"
+ PRINT_LOOKAHEAD ("merge <- conflict defstate_look 'a' nonconflict2 'b'"
" defstate_shift");
}
;
@@ -1481,33 +1485,33 @@ merge:
nonconflict1:
%empty
{
- print_lookahead (yychar, &yylval, &yylloc, "nonconflict1 <- empty
string");
+ PRINT_LOOKAHEAD ("nonconflict1 <- empty string");
}
;
nonconflict2:
%empty
{
- print_lookahead (yychar, &yylval, &yylloc, "nonconflict2 <- empty
string");
+ PRINT_LOOKAHEAD ("nonconflict2 <- empty string");
}
| 'a'
{
USE ($][1);
- print_lookahead (yychar, &yylval, &yylloc, "nonconflict2 <- 'a'");
+ PRINT_LOOKAHEAD ("nonconflict2 <- 'a'");
}
;
conflict:
%empty
{
- print_lookahead (yychar, &yylval, &yylloc, "conflict <- empty string");
+ PRINT_LOOKAHEAD ("conflict <- empty string");
}
;
defstate_look:
%empty
{
- print_lookahead (yychar, &yylval, &yylloc, "defstate_look <- empty
string");
+ PRINT_LOOKAHEAD ("defstate_look <- empty string");
}
;
@@ -1515,7 +1519,7 @@ defstate_look:
defstate_shift:
%empty
{
- print_lookahead (yychar, &yylval, &yylloc, "defstate_shift <- empty
string");
+ PRINT_LOOKAHEAD ("defstate_shift <- empty string");
}
;
--
2.30.0
- [PATCH 00/11] glr2.cc: add support for token constructors, Akim Demaille, 2021/01/10
- [PATCH 01/11] tests: fix definition for parser class name, Akim Demaille, 2021/01/10
- [PATCH 02/11] glr: tests: formatting changes, Akim Demaille, 2021/01/10
- [PATCH 03/11] glr: tests: more macros,
Akim Demaille <=
- [PATCH 04/11] glr: examples: fix locations, Akim Demaille, 2021/01/10
- [PATCH 05/11] glr2.cc: fix memory leak, Akim Demaille, 2021/01/10
- [PATCH 06/11] glr2.cc: use references to print symbols, Akim Demaille, 2021/01/10
- [PATCH 07/11] glr2.cc: example: style changes, Akim Demaille, 2021/01/10
- [PATCH 08/11] glr2.cc: rely on symbol kinds rather than token kinds, Akim Demaille, 2021/01/10
- [PATCH 09/11] glr2.cc: tests: simplify, Akim Demaille, 2021/01/10
- [PATCH 11/11] glr2.cc: add support for api.token.constructor, Akim Demaille, 2021/01/10
- [PATCH 10/11] glr2.cc: introduce the yytranslate_ member function, Akim Demaille, 2021/01/10