bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] tests: AT_YYERROR_DEFINE: prepare for list of ints.


From: Akim Demaille
Subject: [PATCH 1/2] tests: AT_YYERROR_DEFINE: prepare for list of ints.
Date: Thu, 28 Jun 2012 15:06:05 +0200

* 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.
---
 tests/actions.at        | 18 +++++++++---------
 tests/conflicts.at      |  2 +-
 tests/glr-regression.at | 16 ++++++++--------
 tests/local.at          | 11 ++++++++---
 tests/push.at           |  2 +-
 tests/regression.at     |  6 +++---
 6 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/tests/actions.at b/tests/actions.at
index 3f47928..417e018 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 cafa333..a46acc5 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 91dedb8..f064177 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 5a5bbdd..1baf661 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 057807d..d2c0926 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 ac7d55e..a5e0c14 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)
 {
-- 
1.7.11.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]