summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@lrde.epita.fr>2012-06-28 14:20:17 +0200
committerAkim Demaille <akim@lrde.epita.fr>2012-06-28 15:01:36 +0200
commit95361618dee181507d53f47de2dd50c667b84007 (patch)
tree7191364bbd197cf0d205d4456a9f920e6844cac4
parent694af10cb7670fcbe198685d13d5db7f87a9b083 (diff)
downloadbison-95361618dee181507d53f47de2dd50c667b84007.tar.gz
tests: AT_YYERROR_DEFINE: prepare for list of ints.
* tests/local.at (AT_YYERROR_DEFINE): Don't add quotes, check their presence to detect char/int types. * tests/actions.at, tests/conflicts.at, tests/glr-regression.at, * tests/push.at, tests/regression.at: Adjust.
-rw-r--r--tests/actions.at18
-rw-r--r--tests/conflicts.at2
-rw-r--r--tests/glr-regression.at16
-rw-r--r--tests/local.at11
-rw-r--r--tests/push.at2
-rw-r--r--tests/regression.at6
6 files changed, 30 insertions, 25 deletions
diff --git a/tests/actions.at b/tests/actions.at
index 3f47928a..417e0188 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -51,7 +51,7 @@ exp: { putchar ('0'); }
;
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE(123456789)[
+]AT_YYLEX_DEFINE(["123456789"])[
int
main (void)
{
@@ -116,7 +116,7 @@ sum_of_the_five_previous_values:
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([])[
+]AT_YYLEX_DEFINE[
int
main (void)
{
@@ -151,7 +151,7 @@ sum: { printf ("%d\n", $0.val + $-1.val + $-2.val); } ;
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE()[
+]AT_YYLEX_DEFINE[
int
main (void)
{
@@ -636,7 +636,7 @@ start: 'a' 'b' 'c' 'd' 'e' { $$ = 'S'; USE(($1, $2, $3, $4, $5)); } ;
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([abcd], [[yylval = res]])[
+]AT_YYLEX_DEFINE(["abcd"], [[yylval = res]])[
int
main (void)
@@ -748,7 +748,7 @@ start:
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([abcdef])[
+]AT_YYLEX_DEFINE(["abcdef"])[
int
main (void)
@@ -966,7 +966,7 @@ start:
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([abd], [yylval = res])[
+]AT_YYLEX_DEFINE(["abd"], [yylval = res])[
int
main (void)
{
@@ -1066,7 +1066,7 @@ start: { USE($$); } ;
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([])[
+]AT_YYLEX_DEFINE[
int
main (void)
{
@@ -1121,7 +1121,7 @@ start:
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([])[
+]AT_YYLEX_DEFINE[
int
main (void)
{
@@ -1381,7 +1381,7 @@ accept: /*empty*/ {
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([a])[
+]AT_YYLEX_DEFINE(["a"])[
int
main (void)
{
diff --git a/tests/conflicts.at b/tests/conflicts.at
index cafa3338..a46acc5a 100644
--- a/tests/conflicts.at
+++ b/tests/conflicts.at
@@ -491,7 +491,7 @@ reduce-nonassoc: %prec 'a';
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([aaa])[
+]AT_YYLEX_DEFINE(["aaa"])[
int
main (void)
diff --git a/tests/glr-regression.at b/tests/glr-regression.at
index 91dedb89..f0641779 100644
--- a/tests/glr-regression.at
+++ b/tests/glr-regression.at
@@ -383,7 +383,7 @@ B: 'a' { $$ = make_value ("B", "'a'"); } ;
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([a])[
+]AT_YYLEX_DEFINE(["a"])[
int
main (void)
@@ -466,7 +466,7 @@ start:
;
%%
-]AT_YYLEX_DEFINE(a)[
+]AT_YYLEX_DEFINE(["a"])[
]AT_YYERROR_DEFINE[
int
main (void)
@@ -519,7 +519,7 @@ start: 'a' | 'a' ;
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE(a)[
+]AT_YYLEX_DEFINE(["a"])[
int
main (void)
{
@@ -834,7 +834,7 @@ start:
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE()[
+]AT_YYLEX_DEFINE[
int
main (void)
@@ -889,7 +889,7 @@ start:
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([a])[
+]AT_YYLEX_DEFINE(["a"])[
int
main (void)
@@ -1449,7 +1449,7 @@ ambiguity2: ;
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE()[
+]AT_YYLEX_DEFINE[
int
main (void)
@@ -1663,7 +1663,7 @@ sym3: %merge<merge> { $$ = 0; } ;
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE()[
+]AT_YYLEX_DEFINE[
int
main (void)
{
@@ -1709,7 +1709,7 @@ start:
b: 'b';
d: /* nada. */;
%%
-]AT_YYLEX_DEFINE([abc])[
+]AT_YYLEX_DEFINE(["abc"])[
]AT_YYERROR_DEFINE[
int
main (void)
diff --git a/tests/local.at b/tests/local.at
index 5a5bbdd0..1baf6616 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -291,8 +291,11 @@ $2])
# AT_YYLEX_PROTOTYPE
# AT_YYLEX_DECLARE_EXTERN
# AT_YYLEX_DECLARE
-# AT_YYLEX_DEFINE(INPUT-STRING, [ACTION])
-# ---------------------------------------
+# AT_YYLEX_DEFINE([INPUT], [ACTION])
+# ----------------------------------
+# INPUT can be empty, or in double quotes, or a list (in braces).
+# ACTION may compute yylval for instance, using "res" as token type,
+# and "toknum" as the number of calls to yylex (starting at 0).
m4_define([AT_YYLEX_PROTOTYPE],
[int AT_NAME_PREFIX[]lex (]AT_YYLEX_FORMALS[)[]dnl
])
@@ -310,7 +313,9 @@ m4_define([AT_YYLEX_DEFINE],
static
]AT_YYLEX_PROTOTYPE[
{
- static char const input[] = "$1";
+ ]m4_bmatch([$1], [^\(".*"\)?$],
+ [[static char const input[] = ]m4_default([$1], [""])],
+ [[static int const input[] = ]$1])[;
static size_t toknum = 0;
int res;
]AT_USE_LEX_ARGS[;
diff --git a/tests/push.at b/tests/push.at
index 057807dd..d2c09263 100644
--- a/tests/push.at
+++ b/tests/push.at
@@ -101,7 +101,7 @@ start: ;
%%
]AT_YYERROR_DEFINE[
-]m4_if([$1], [[both]], [AT_YYLEX_DEFINE([])])[
+]m4_if([$1], [[both]], [AT_YYLEX_DEFINE])[
int
main (void)
diff --git a/tests/regression.at b/tests/regression.at
index ac7d55ee..a5e0c14d 100644
--- a/tests/regression.at
+++ b/tests/regression.at
@@ -1312,7 +1312,7 @@ syntax_error:
/* Induce two syntax error messages (which requires full error
recovery by shifting 3 tokens) in order to detect any loss of the
reallocated buffer. */
-]AT_YYLEX_DEFINE([abc])[
+]AT_YYLEX_DEFINE(["abc"])[
int
main (void)
{
@@ -1419,7 +1419,7 @@ syntax_error2:
]AT_YYERROR_DEFINE[
/* Induce two syntax error messages (which requires full error
recovery by shifting 3 tokens). */
-]AT_YYLEX_DEFINE([abc])[
+]AT_YYLEX_DEFINE(["abc"])[
int
main (void)
{
@@ -1569,7 +1569,7 @@ A: /*empty*/ | 'a' ;
%%
]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE([$1])[
+]AT_YYLEX_DEFINE(["$1"])[
int
main (void)
{