]> git.saurik.com Git - bison.git/commitdiff
Merge remote-tracking branch 'origin/maint'
authorAkim Demaille <akim@lrde.epita.fr>
Mon, 25 Jun 2012 07:26:48 +0000 (09:26 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Mon, 25 Jun 2012 07:46:34 +0000 (09:46 +0200)
* origin/maint:
  tests: more uniformity.
  tests: handle locations in a more generic way.
  tests: handle locations in the generic yyerror functions.
  tests: fix AT_CHECK_CALC.
  tests: improve infrastructure
  tests: factor.
  skeletons: minor style changes
  tests: AT_LANG.
  c skeletons: factor the declaration of yylloc and yylval.
  news: condemn YYPARSE_PARAM and YYLEX_PARAM.
  maint: regen.

Conflicts:
tests/calc.at
tests/local.at
tests/regression.at

12 files changed:
1  2 
NEWS
data/c.m4
data/glr.c
data/yacc.c
doc/bison.texinfo
src/output.c
tests/actions.at
tests/calc.at
tests/java.at
tests/local.at
tests/output.at
tests/regression.at

diff --cc NEWS
Simple merge
diff --cc data/c.m4
Simple merge
diff --cc data/glr.c
Simple merge
diff --cc data/yacc.c
Simple merge
index 3f24b9ac7f70d71f96b9273b1141e5fb6613225d,4f2e1c6244078769a4b0f0bc05b541462df7de6c..d1223bdce72568a15def45aa941b8be72d562cd2
@@@ -6265,18 -6011,18 +6265,18 @@@ For instance
  @end example
  
  @noindent
- results in the following signature:
+ results in the following signatures:
  
  @example
 -int yylex   (int *nastiness);
 -int yyparse (int *nastiness, int *randomness);
 +int yylex   (scanner_mode *mode, environment_type *env);
 +int yyparse (parser_mode *mode, environment_type *env);
  @end example
  
 -If @code{%define api.pure} is added:
 +If @samp{%define api.pure} is added:
  
  @example
 -int yylex   (YYSTYPE *lvalp, int *nastiness);
 -int yyparse (int *nastiness, int *randomness);
 +int yylex   (YYSTYPE *lvalp, scanner_mode *mode, environment_type *env);
 +int yyparse (parser_mode *mode, environment_type *env);
  @end example
  
  @noindent
diff --cc src/output.c
index e8cff20e25812d573e23ea8b9db02364b57c815e,e0d6ed3ab4316ef7eb9f8653e55afe029f2dea86..6ff6a9b835ccb3ab4dfec925df81f62037719704
@@@ -581,13 -496,32 +581,13 @@@ output_skeleton (void
    pid_t pid;
  
    /* Compute the names of the package data dir and skeleton files.  */
 -  char const m4sugar[] = "m4sugar/m4sugar.m4";
 -  char const m4bison[] = "bison.m4";
 -  char *full_m4sugar;
 -  char *full_m4bison;
 -  char *full_skeleton;
 -  char const *p;
 -  char const *m4 = (p = getenv ("M4")) ? p : M4;
 -  char const *pkgdatadir = compute_pkgdatadir ();
 -  size_t skeleton_size = strlen (skeleton) + 1;
 -  size_t pkgdatadirlen = strlen (pkgdatadir);
 -  while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
 -    pkgdatadirlen--;
 -  full_skeleton = xmalloc (pkgdatadirlen + 1
 -                         + (skeleton_size < sizeof m4sugar
 -                            ? sizeof m4sugar : skeleton_size));
 -  memcpy (full_skeleton, pkgdatadir, pkgdatadirlen);
 -  full_skeleton[pkgdatadirlen] = '/';
 -  strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
 -  full_m4sugar = xstrdup (full_skeleton);
 -  strcpy (full_skeleton + pkgdatadirlen + 1, m4bison);
 -  full_m4bison = xstrdup (full_skeleton);
 -  if (mbschr (skeleton, '/'))
 -    strcpy (full_skeleton, skeleton);
 -  else
 -    strcpy (full_skeleton + pkgdatadirlen + 1, skeleton);
 +  char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
 +  char const *datadir = pkgdatadir ();
 +  char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL);
 +  char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL);
 +  char *skel = (IS_PATH_WITH_DIR (skeleton)
-               ? xstrdup (skeleton)
-               : xconcatenated_filename (datadir, skeleton, NULL));
++                ? xstrdup (skeleton)
++                : xconcatenated_filename (datadir, skeleton, NULL));
  
    /* Test whether m4sugar.m4 is readable, to check for proper
       installation.  A faulty installation can cause deadlock, so a
Simple merge
diff --cc tests/calc.at
index 5c6c4cc11f539d17f370eaba459b0556643f1d92,836c3a3312ed31c268063f329777c7cc1e4105f3..0a9f9e11cfe48d55e3610bf35f3b16ed442df375
@@@ -206,9 -205,9 +205,9 @@@ read_signed_integer (]AT_YYLEX_FORMALS[
    /* 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;
 +      return ]AT_TOKEN_PREFIX[NUM;
      }
  
    /* Return end-of-file.  */
@@@ -295,10 -291,10 +291,10 @@@ static int power (int base, int exponen
                       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([], [
 +]AT_SKEL_CC_IF([AT_LOCATION_IF([AT_LOCATION_TYPE_IF([], [
  /* The lalr1.cc skeleton, for backward compatibility, defines
     a constructor for position that initializes the filename.  The
     glr.cc skeleton does not (and in fact cannot: location/position
diff --cc tests/java.at
Simple merge
diff --cc tests/local.at
index f43ffde8aeaa79ecdd5ce00aa0cfe8dd5fb28613,b0e4ee1ac995f3868f71537bd8d2154f6cb038a1..649e994339b56d7cc1eddfb04a6e499269fc44a4
@@@ -135,15 -138,12 +138,15 @@@ 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])])
 +m4_pushdef([AT_TOKEN_PREFIX],
 +[m4_bmatch([$3], [%define api.tokens.prefix ".*"],
 +           [m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])])
  # yyerror receives the location if %location & %pure & (%glr or %parse-param).
  m4_pushdef([AT_YYERROR_ARG_LOC_IF],
  [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
@@@ -165,16 -165,16 +168,16 @@@ 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])])
 +            [YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
-  m4_pushdef([AT_LEX_ARGS],
+  m4_pushdef([AT_YYLEX_ARGS],
 -          [lvalp[]AT_LOCATION_IF([, llocp])])
 +            [lvalp[]AT_LOCATION_IF([, llocp])])
   m4_pushdef([AT_USE_LEX_ARGS],
 -          [(void) lvalp;AT_LOCATION_IF([(void) llocp])])
 +            [(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)]])
@@@ -322,21 -338,46 +343,44 @@@ m4_define([AT_YYERROR_DECLARE]
  ])
  
  m4_define([AT_YYERROR_DEFINE],
- [AT_SKEL_JAVA_IF([[public void yyerror (String msg)
- {
-   System.err.println (msg);
- }]], [AT_SKEL_CC_IF([[void
- yy::parser::error (]AT_LOCATION_IF([[const yy::location &, ]])[std::string const &msg)
- {
-   std::cerr << msg << std::endl;
- }]], [[#include <stdio.h>
- static void
- ]AT_API_PREFIX[error (char const *msg)
+ [m4_case(AT_LANG,
+ [c], [[#include <stdio.h>
+ /* A C error reporting function.  */
+ static
+ ]AT_YYERROR_PROTOTYPE[
  {
+ ]AT_YYERROR_SEES_LOC_IF([[
+   fprintf (stderr, "%d.%d",
+            ]AT_LOC_FIRST_LINE[, ]AT_LOC_FIRST_COLUMN[);
+   if (]AT_LOC_FIRST_LINE[ != ]AT_LOC_LAST_LINE[)
+     fprintf (stderr, "-%d.%d",
+              ]AT_LOC_LAST_LINE[,  ]AT_LOC_LAST_COLUMN[ - 1);
+   else if (]AT_LOC_FIRST_COLUMN[ != ]AT_LOC_LAST_COLUMN[ - 1)
+     fprintf (stderr, "-%d",
+              ]AT_LOC_LAST_COLUMN[ - 1);
+   fprintf (stderr, ": ");]])[
    fprintf (stderr, "%s\n", msg);
 -]AT_NAME_PREFIX[::parser::error (const location_type& l, const std::string& m)
 -{
 -  (void) l;
 -  std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
+ }]],
+ [c++], [[/* A C++ error reporting function.  */
+ void
 -  {
++]AT_NAME_PREFIX[::parser::error (]AT_LOCATION_IF([[const location_type& l, ]])[const std::string& m)
++{  std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
+ }]],
+ [java], [AT_LOCATION_IF([[public void yyerror (Calc.Location l, String s)
 -  }]])])dnl
++{
+     if (l == null)
+       System.err.println (s);
+     else
+       System.err.println (l + ": " + s);
+   }
+ ]], [[
+   public void yyerror (String s)
+   {
+     System.err.println (s);
 +}]])])dnl
  ])
  
  ## --------------- ##
  ## Running Bison.  ##
  ## --------------- ##
@@@ -531,31 -581,29 +584,29 @@@ m4_define([AT_LANG_COMPILE]
  # OUTPUT-OTHER.c, OUTPUT-OTHER.cc, or OUTPUT-OTHER.java to OUTPUT or
  # OUTPUT.java along with it.  Relies on AT_SKEL_CC_IF and
  # AT_SKEL_JAVA_IF.
- m4_define([AT_FULL_COMPILE], [
-   AT_SKEL_JAVA_IF([
-     AT_BISON_CHECK([-o $1.java $1.y])
-     AT_JAVA_COMPILE([$1.java],
+ m4_define([AT_FULL_COMPILE],
+ [m4_case(AT_LANG,
+ [java],
+   [AT_BISON_CHECK([-o $1.java $1.y])
+    AT_LANG_COMPILE([$1],
 -                   m4_join([ ],
 -                           [$1.java],
 -                           m4_ifval($2, [[$1-$2.java]]),
 +                    m4_join([ ],
 +                            [$1.java],
 +                            m4_ifval($2, [[$1-$2.java]]),
-                             m4_ifval($3, [[$1-$3.java]])))
-   ], [
-     AT_SKEL_CC_IF([
-       AT_BISON_CHECK([-o $1.cc $1.y])
-       AT_COMPILE_CXX([$1],
+                            m4_ifval($3, [[$1-$3.java]])))],
+ [c++],
+   [AT_BISON_CHECK([-o $1.cc $1.y])
+    AT_LANG_COMPILE([$1],
 -                   m4_join([ ],
 -                           [$1.cc],
 -                           m4_ifval($2, [[$1-$2.cc]]),
 +                     m4_join([ ],
 +                             [$1.cc],
 +                             m4_ifval($2, [[$1-$2.cc]]),
-                              m4_ifval($3, [[$1-$3.cc]])))
-     ], [
-       AT_BISON_CHECK([-o $1.c $1.y])
-       AT_COMPILE([$1],
+                            m4_ifval($3, [[$1-$3.cc]])))],
+ [c],
+   [AT_BISON_CHECK([-o $1.c $1.y])
+    AT_LANG_COMPILE([$1],
 -                   m4_join([ ],
 -                           [$1.c],
 -                           m4_ifval($2, [[$1-$2.c]]),
 +                  m4_join([ ],
 +                          [$1.c],
 +                          m4_ifval($2, [[$1-$2.c]]),
-                           m4_ifval($3, [[$1-$3.c]])))
-     ])
-   ])
+                            m4_ifval($3, [[$1-$3.c]])))])
  ])
  
  
diff --cc tests/output.at
Simple merge
Simple merge