]> git.saurik.com Git - bison.git/commitdiff
tests: more uniformity.
authorAkim Demaille <akim@lrde.epita.fr>
Fri, 22 Jun 2012 10:08:02 +0000 (12:08 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Fri, 22 Jun 2012 10:08:02 +0000 (12:08 +0200)
* tests/local.at (AT_LEX_FORMALS, AT_LEX_ARGS, AT_LEX_PRE_FORMALS)
(AT_LEX_PRE_ARGS): Rename as...
(AT_YYLEX_FORMALS, AT_YYLEX_ARGS, AT_YYLEX_PRE_FORMALS)
(AT_YYLEX_PRE_ARGS): these, for consistency.
(AT_API_PREFIX): Take %name-prefix into account.
(AT_YYLEX_PROTOTYPE): New.
Use it.
* tests/actions.at, tests/calc.at, tests/cxx-type.at: Adjust to
use them.

tests/actions.at
tests/calc.at
tests/cxx-type.at
tests/local.at

index afba3f0bd1bb341bb286b8549f418778a781e268..e5a885ddcfdea2e44a44638d84c7beee676adc47 100644 (file)
@@ -205,8 +205,8 @@ m4_ifval([$6], [%union
 }])
 AT_LALR1_CC_IF([%define global_tokens_and_yystype])
 m4_ifval([$6], [[%code provides {]], [[%code {]])
-AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])
-[static int yylex (]AT_LEX_FORMALS[);
+AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])[
+]AT_YYLEX_DECLARE[
 ]AT_LALR1_CC_IF([], [AT_YYERROR_DECLARE])
 [}
 
@@ -309,8 +309,8 @@ thing:
 /* Alias to ARGV[1]. */
 const char *source = YY_NULL;
 
-static int
-yylex (]AT_LEX_FORMALS[)
+static
+]AT_YYLEX_PROTOTYPE[
 {
   static unsigned int counter = 0;
 
index 34d2e4884e2bc77d3425dc67c1704d2de3aa4c1f..836c3a3312ed31c268063f329777c7cc1e4105f3 100644 (file)
@@ -110,15 +110,15 @@ main (int argc, const char **argv)
 m4_pushdef([AT_CALC_LEX],
 [[#include <ctype.h>
 
-int ]AT_NAME_PREFIX[lex (]AT_LEX_FORMALS[);
-static int get_char (]AT_LEX_FORMALS[);
-static void unget_char (]AT_LEX_PRE_FORMALS[ int c);
+]AT_YYLEX_DECLARE_EXTERN[
+static int get_char (]AT_YYLEX_FORMALS[);
+static void unget_char (]AT_YYLEX_PRE_FORMALS[ int c);
 
 ]AT_LOCATION_IF([
 static YYLTYPE last_yylloc;
 ])[
 static int
-get_char (]AT_LEX_FORMALS[)
+get_char (]AT_YYLEX_FORMALS[)
 {
   int res = getc (input);
   ]AT_USE_LEX_ARGS[;
@@ -136,7 +136,7 @@ get_char (]AT_LEX_FORMALS[)
 }
 
 static void
-unget_char (]AT_LEX_PRE_FORMALS[ int c)
+unget_char (]AT_YYLEX_PRE_FORMALS[ int c)
 {
   ]AT_USE_LEX_ARGS[;
 ]AT_LOCATION_IF([
@@ -147,26 +147,26 @@ unget_char (]AT_LEX_PRE_FORMALS[ int c)
 }
 
 static int
-read_signed_integer (]AT_LEX_FORMALS[)
+read_signed_integer (]AT_YYLEX_FORMALS[)
 {
-  int c = get_char (]AT_LEX_ARGS[);
+  int c = get_char (]AT_YYLEX_ARGS[);
   int sign = 1;
   int n = 0;
 
   ]AT_USE_LEX_ARGS[;
   if (c == '-')
     {
-      c = get_char (]AT_LEX_ARGS[);
+      c = get_char (]AT_YYLEX_ARGS[);
       sign = -1;
     }
 
   while (isdigit (c))
     {
       n = 10 * n + (c - '0');
-      c = get_char (]AT_LEX_ARGS[);
+      c = get_char (]AT_YYLEX_ARGS[);
     }
 
-  unget_char (]AT_LEX_PRE_ARGS[ c);
+  unget_char (]AT_YYLEX_PRE_ARGS[ c);
 
   return sign * n;
 }
@@ -178,8 +178,7 @@ read_signed_integer (]AT_LEX_FORMALS[)
 | blanks and tabs, returns 0 for EOF.                            |
 `---------------------------------------------------------------*/
 
-int
-]AT_NAME_PREFIX[lex (]AT_LEX_FORMALS[)
+]AT_YYLEX_PROTOTYPE[
 {
   static int init = 1;
   int c;
@@ -201,13 +200,13 @@ int
       AT_LOC_FIRST_LINE   = AT_LOC_LAST_LINE;
 ])[
     }
-  while ((c = get_char (]AT_LEX_ARGS[)) == ' ' || c == '\t');
+  while ((c = get_char (]AT_YYLEX_ARGS[)) == ' ' || c == '\t');
 
   /* process numbers   */
   if (c == '.' || isdigit (c))
     {
-      unget_char (]AT_LEX_PRE_ARGS[ c);
-      ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
+      unget_char (]AT_YYLEX_PRE_ARGS[ c);
+      ]AT_VAL[.ival = read_signed_integer (]AT_YYLEX_ARGS[);
       return NUM;
     }
 
@@ -288,14 +287,11 @@ FILE *input;
 static int power (int base, int exponent);
 
 ]AT_SKEL_CC_IF(,
-[/* yyerror receives the location if:
-   - %location & %pure & %glr
-   - %location & %pure & %yacc & %parse-param. */
-static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
+[static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
                      AT_PARAM_IF([semantic_value *result, int *count, ])
                      const char *s
                      );])[
-int yylex (]AT_LEX_FORMALS[);
+]AT_YYLEX_DECLARE_EXTERN[
 }
 
 ]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [
index e6fd8a85d0dca779f24f777fd42280e30efcf5f8..e172033a7a8fdfa520cdc8fbefc129ce050eb89d 100644 (file)
@@ -135,8 +135,7 @@ main (int argc, char **argv)
 
 ]AT_YYERROR_DEFINE[
 
-int
-yylex (]AT_LEX_FORMALS[)
+]AT_YYLEX_PROTOTYPE[
 {
   char buffer[256];
   int c;
index 02093938c226e1c46ef425e9eb037abc525b2c03..b0e4ee1ac995f3868f71537bd8d2154f6cb038a1 100644 (file)
@@ -138,11 +138,11 @@ m4_pushdef([AT_GLR_OR_PARAM_IF],
 [m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
 m4_pushdef([AT_NAME_PREFIX],
 [m4_bmatch([$3], [%name-prefix ".*"],
-           [m4_bregexp([$3], [name-prefix "\([^""]*\)"], [\1])],
+           [m4_bregexp([$3], [%name-prefix "\([^""]*\)"], [\1])],
            [yy])])
 m4_pushdef([AT_API_PREFIX],
-[m4_bmatch([$3], [%define api\.prefix ".*"],
-           [m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],
+[m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"],
+           [m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])],
            [yy])])
 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
 m4_pushdef([AT_YYERROR_ARG_LOC_IF],
@@ -165,24 +165,24 @@ m4_pushdef([AT_PURE_LEX_IF],
 AT_PURE_LEX_IF(
 [m4_pushdef([AT_LOC], [(*llocp)])
  m4_pushdef([AT_VAL], [(*lvalp)])
- m4_pushdef([AT_LEX_FORMALS],
+ m4_pushdef([AT_YYLEX_FORMALS],
            [YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
- m4_pushdef([AT_LEX_ARGS],
+ m4_pushdef([AT_YYLEX_ARGS],
            [lvalp[]AT_LOCATION_IF([, llocp])])
  m4_pushdef([AT_USE_LEX_ARGS],
            [(void) lvalp;AT_LOCATION_IF([(void) llocp])])
- m4_pushdef([AT_LEX_PRE_FORMALS],
-           [AT_LEX_FORMALS, ])
- m4_pushdef([AT_LEX_PRE_ARGS],
-           [AT_LEX_ARGS, ])
+ m4_pushdef([AT_YYLEX_PRE_FORMALS],
+           [AT_YYLEX_FORMALS, ])
+ m4_pushdef([AT_YYLEX_PRE_ARGS],
+           [AT_YYLEX_ARGS, ])
 ],
 [m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
  m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
- m4_pushdef([AT_LEX_FORMALS],     [void])
- m4_pushdef([AT_LEX_ARGS],        [])
+ m4_pushdef([AT_YYLEX_FORMALS],     [void])
+ m4_pushdef([AT_YYLEX_ARGS],        [])
  m4_pushdef([AT_USE_LEX_ARGS],    [])
- m4_pushdef([AT_LEX_PRE_FORMALS], [])
- m4_pushdef([AT_LEX_PRE_ARGS],    [])
+ m4_pushdef([AT_YYLEX_PRE_FORMALS], [])
+ m4_pushdef([AT_YYLEX_PRE_ARGS],    [])
 ])
 
 # Handle the different types of location components.
@@ -199,11 +199,11 @@ AT_SKEL_CC_IF(
 # AT_BISON_OPTION_POPDEFS
 # -----------------------
 m4_define([AT_BISON_OPTION_POPDEFS],
-[m4_popdef([AT_LEX_PRE_ARGS])
-m4_popdef([AT_LEX_PRE_FORMALS])
+[m4_popdef([AT_YYLEX_PRE_ARGS])
+m4_popdef([AT_YYLEX_PRE_FORMALS])
 m4_popdef([AT_USE_LEX_ARGS])
-m4_popdef([AT_LEX_ARGS])
-m4_popdef([AT_LEX_FORMALS])
+m4_popdef([AT_YYLEX_ARGS])
+m4_popdef([AT_YYLEX_FORMALS])
 m4_popdef([AT_VAL])
 m4_popdef([AT_LOC])
 m4_popdef([AT_PURE_LEX_IF])
@@ -276,12 +276,17 @@ m4_define([AT_DATA_GRAMMAR],
 $2])
 ])
 
+# AT_YYLEX_PROTOTYPE
 # AT_YYLEX_DECLARE_EXTERN
 # AT_YYLEX_DECLARE
 # AT_YYLEX_DEFINE(INPUT-STRING, [ACTION])
 # ---------------------------------------
+m4_define([AT_YYLEX_PROTOTYPE],
+[int AT_API_PREFIX[]lex (]AT_YYLEX_FORMALS[)[]dnl
+])
+
 m4_define([AT_YYLEX_DECLARE_EXTERN],
-[int AT_API_PREFIX[]lex (]AT_LEX_FORMALS[);dnl
+[AT_YYLEX_PROTOTYPE;dnl
 ])
 
 m4_define([AT_YYLEX_DECLARE],
@@ -290,8 +295,8 @@ m4_define([AT_YYLEX_DECLARE],
 
 m4_define([AT_YYLEX_DEFINE],
 [[#include <stdlib.h> /* abort */
-static int
-]AT_API_PREFIX[lex (]AT_LEX_FORMALS[)
+static
+]AT_YYLEX_PROTOTYPE[
 {
   static char const input[] = "$1";
   static size_t toknum = 0;
@@ -312,9 +317,14 @@ static int
 # AT_YYERROR_DEFINE
 # -------------------------
 # Must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS pair.
+m4_define([AT_YYERROR_FORMALS],
+[m4_case(AT_LANG,
+[c], [AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])[const char *msg]])[]dnl
+])
+
 m4_define([AT_YYERROR_PROTOTYPE],
 [m4_case(AT_LANG,
-[c], [[void ]AT_API_PREFIX[error (]AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])[const char *msg)]])[]dnl
+[c], [[void ]AT_API_PREFIX[error (]AT_YYERROR_FORMALS[)]])[]dnl
 ])
 
 m4_define([AT_YYERROR_DECLARE_EXTERN],