]> git.saurik.com Git - bison.git/commitdiff
Merge remote-tracking branch 'origin/maint'
authorAkim Demaille <akim@lrde.epita.fr>
Sun, 1 Apr 2012 10:56:55 +0000 (12:56 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Sun, 1 Apr 2012 11:14:34 +0000 (13:14 +0200)
* origin/maint:
  bump to 2012 in skeletons.
  build: remove ancient Autoconf tests.
  doc: c++: complete the location documentation.
  c++: locations: provide convenience constructors.
  c++: locations: remove useless "inline".
  glr: do not use locations when they are not requested
  c++: use nullptr for C++11.
  build: simplify and improve the compiler warnings for tests.
  gnulib: update.
  maint: formatting changes.
  NEWS: update.
  Java: Fix syntax error handling without error token.
  tests: beware of -pedantic on large #line numbers.
  tests: when using the C++ compiler, use its flags too.

Conflicts:
data/glr.c
data/glr.cc
data/lalr1.cc
data/location.cc
data/yacc.c
tests/Makefile.am

19 files changed:
NEWS
configure.ac
data/c++.m4
data/c.m4
data/glr.c
data/lalr1.cc
data/lalr1.java
data/location.cc
data/yacc.c
doc/bison.texinfo
gnulib
lib/libiberty.h
m4/subpipe.m4 [deleted file]
src/system.h
tests/actions.at
tests/atlocal.in
tests/calc.at
tests/java.at
tests/regression.at

diff --git a/NEWS b/NEWS
index 293e2dfda6a20e13191d58702d220fa313f77bcb..bb96c36e238ba91e2d10b7243db4652c4cb20e1a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -71,12 +71,43 @@ Bison News
 
 * Changes in version 2.5.1 (????-??-??):
 
-** Some portability problems in the test suite have been fixed.
+** Several portability problems in the test suite have been fixed:
 
-** Minor improvements have been made to the manual.
+  This includes warnings with some compilers, unexpected behavior of
+  tools such as diff, warning messages from the test suite itself,
+  etc.
+
+  __attribute__ is not longer disabled when __STRICT_ANSI__ is defined
+  (i.e., when -std is passed to GCC).
+
+** Warnings during the build procedure have been eliminated.
+
+** Many minor improvements have been made to the manual:
+
+  The layout for grammar has changed to a more compact scheme.  Named
+  references are motivated.  The description of the automaton
+  description file is updated.
 
 ** YYBACKUP works as expected.
 
+** liby is no longer asking for "rpl_fprintf" on some platforms.
+
+** Several Java fixes:
+
+  The Java parser no longer throws ArrayIndexOutOfBoundsException if
+  the first token leads to a syntax error.  Some minor clean ups.
+
+** C++11 compatibility:
+
+  C and C++ parsers use nullptr instead of 0 when __cplusplus is
+  201103L or higher.
+
+** C++ locations:
+
+  The position and location constructors (and their initialize
+  methods) accept new arguments for line and column.  Several issues
+  in the documentation were fixed.
+
 * Changes in version 2.5 (2011-05-14):
 
 ** Grammar symbol names can now contain non-initial dashes:
index 622da5da4a8efb4e01a3b50893ce474738b2a1c8..abe2a530dcdceb38c8a8e08eb02e288a119737ac 100644 (file)
@@ -55,6 +55,7 @@ AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
 
 # Checks for the compiler.
 AC_PROG_CC_STDC
+AC_PROG_CXX
 
 # Gnulib (early checks).
 gl_EARLY
@@ -67,31 +68,36 @@ AC_ARG_ENABLE([gcc-warnings],
  esac],
               [enable_gcc_warnings=no])
 if test "$enable_gcc_warnings" = yes; then
+  warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
+    -Wcast-qual -Wformat -Wpointer-arith -Wwrite-strings'
+  warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes
+    -Wshadow -Wstrict-prototypes'
+  warn_cxx='-Wnoexcept -Wzero-as-null-pointer-constant'
+  AC_LANG_PUSH([C])
+  for i in $warn_common $warn_c;
+  do
+    gl_WARN_ADD([$i], [WARN_CFLAGS])
+  done
   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
-  AC_SUBST([WERROR_CFLAGS])
-  gl_WARN_ADD([-Wall])
-  gl_WARN_ADD([-Wextra -Wno-sign-compare])
-  gl_WARN_ADD([-Wcast-align])
-  gl_WARN_ADD([-Wcast-qual])
-  gl_WARN_ADD([-Wformat])
-  gl_WARN_ADD([-Wpointer-arith])
-  gl_WARN_ADD([-Wwrite-strings])
-  AC_SUBST([WARN_CXXFLAGS], [$WARN_CFLAGS])
-  # The following warnings are not suitable for C++.
-  gl_WARN_ADD([-Wbad-function-cast])
-  gl_WARN_ADD([-Wmissing-declarations])
-  gl_WARN_ADD([-Wmissing-prototypes])
-  gl_WARN_ADD([-Wshadow])
-  gl_WARN_ADD([-Wstrict-prototypes])
-  AC_SUBST([WARN_CFLAGS])
   # Warnings for the test suite only.
   gl_WARN_ADD([-Wundef], [WARN_CFLAGS_TEST])
   gl_WARN_ADD([-pedantic], [WARN_CFLAGS_TEST])
-  AC_SUBST([WARN_CXXFLAGS_TEST], ["$WARN_CXXFLAGS $WARN_CFLAGS_TEST"])
-  AC_SUBST([WARN_CFLAGS_TEST], ["$WARN_CFLAGS $WARN_CFLAGS_TEST"])
+  AC_LANG_POP([C])
+
+  AC_LANG_PUSH([C++])
+  for i in $warn_common $warn_cxx;
+  do
+    gl_WARN_ADD([$i], [WARN_CXXFLAGS])
+  done
+  gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
+  # Warnings for the test suite only.
+  gl_WARN_ADD([-Wundef], [WARN_CXXFLAGS_TEST])
+  gl_WARN_ADD([-pedantic], [WARN_CXXFLAGS_TEST])
+  AC_LANG_POP([C++])
 fi
 
 BISON_TEST_FOR_WORKING_C_COMPILER
+BISON_TEST_FOR_WORKING_CXX_COMPILER
 
 AC_ARG_ENABLE([yacc],
   [AC_HELP_STRING([--disable-yacc],
@@ -133,7 +139,6 @@ gl_INIT
 # Checks for library functions.
 AC_CHECK_FUNCS_ONCE([setlocale])
 AM_WITH_DMALLOC
-BISON_PREREQ_SUBPIPE
 BISON_PREREQ_TIMEVAR
 
 # Gettext.
@@ -157,13 +162,9 @@ AC_CONFIG_TESTDIR(tests)
 AC_CONFIG_FILES([tests/atlocal])
 AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
 AC_CHECK_PROGS([VALGRIND], [valgrind])
-AC_PROG_CXX
-BISON_TEST_FOR_WORKING_CXX_COMPILER
 AM_MISSING_PROG([AUTOM4TE], [autom4te])
 # Needed by tests/atlocal.in.
 AC_SUBST([GCC])
-AC_SUBST([O0CFLAGS],   [`echo $CFLAGS   | sed 's/-O[[0-9]] *//'`])
-AC_SUBST([O0CXXFLAGS], [`echo $CXXFLAGS | sed 's/-O[[0-9]] *//'`])
 
 gt_JAVACOMP([1.3], [1.4])
 gt_JAVAEXEC
index 00db21d3baf629f4ab6cf2832625bd4903fe06d1..f1468c708086ebe6bdad5cab3c4728acbeb1ea95 100644 (file)
@@ -99,6 +99,8 @@ m4_map_sep([     b4_token_enum], [,
 ])
 
 
+
+
 ## ----------------- ##
 ## Semantic Values.  ##
 ## ----------------- ##
index 41f56956458812dcea8f66574cec10e02709c910..14db807b2b72e84463d742e5610f9ea9f757fdf1 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -171,16 +171,31 @@ m4_define([b4_table_value_equals],
        [[YYID (0)]],
        [[((]$2[) == (]$3[))]])])
 
+
 ## ---------##
 ## Values.  ##
 ## ---------##
 
-# b4_null
----------
-# Return a null pointer constant.  NULL infringes on the user name
-# space in C, so use 0 rather than NULL.
-m4_define([b4_null], [0])
 
+# b4_null_define
+# --------------
+# Portability issues: define a YY_NULL appropriate for the current
+# language (C, C++98, or C++11).
+m4_define([b4_null_define],
+[# ifndef YY_NULL
+#  if defined __cplusplus && 201103L <= __cplusplus
+#   define YY_NULL nullptr
+#  else
+#   define YY_NULL 0
+#  endif
+# endif[]dnl
+])
+
+
+# b4_null
+# -------
+# Return a null pointer constant.
+m4_define([b4_null], [YY_NULL])
 
 # b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
 # -------------------------------------------------------------
index b92586882203c1f620848cc8ee692c55a8e864ab..37f40aee4ff240bc27a87d847567a01ad43fb6a5 100644 (file)
@@ -93,13 +93,27 @@ m4_define([b4_lpure_args],
 [b4_pure_if([b4_locations_if([, &yylloc])])[]b4_user_args])
 
 
+
 # b4_pure_formals
 # ---------------
-# Arguments passed to yyerror: user formals plus yylocp.
+# Arguments passed to yyerror: user formals plus yylocp with leading comma.
 m4_define([b4_pure_formals],
 [b4_pure_if([b4_locations_if([, YYLTYPE *yylocp])])[]b4_user_formals])
 
 
+# b4_locuser_formals(LOC = yylocp)
+# --------------------------------
+m4_define([b4_locuser_formals],
+[b4_locations_if([, YYLTYPE *m4_default([$1], [yylocp])])[]b4_user_formals])
+
+
+# b4_locuser_args(LOC = yylocp)
+# -----------------------------
+m4_define([b4_locuser_args],
+[b4_locations_if([, m4_default([$1], [yylocp])])[]b4_user_args])
+
+
+
 ## ----------------- ##
 ## Semantic Values.  ##
 ## ----------------- ##
@@ -179,6 +193,8 @@ m4_if(b4_prefix, [yy], [],
 /* Copy the first part of user declarations.  */
 ]b4_user_pre_prologue
 
+b4_null_define
+
 dnl # b4_shared_declarations
 dnl # ----------------------
 dnl # Declaration that might either go into the header (if --defines)
@@ -318,8 +334,7 @@ b4_percent_code_get[]dnl
 #ifndef __attribute__
 /* This feature is available in gcc versions 2.5 and later.  */
 # if (! defined __GNUC__ || __GNUC__ < 2 \
-      || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) \
-      || (defined __STRICT_ANSI__ && __STRICT_ANSI__))
+      || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
 #  define __attribute__(Spec) /* empty */
 # endif
 #endif
@@ -534,8 +549,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
     if (yydebug)                                                        \
       {                                                                 \
         YYFPRINTF (stderr, "%s ", Title);                               \
-        yy_symbol_print (stderr, Type,                                  \
-                         Value]b4_locations_if([, Location])[]b4_user_args[); \
+      yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[);        \
         YYFPRINTF (stderr, "\n");                                       \
       }                                                                 \
   } while (YYID (0))
@@ -769,7 +783,7 @@ static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
 static void
 yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
 {
-  if (yymsg != NULL)
+  if (yymsg != YY_NULL)
     yyerror (]b4_yyerror_args[yymsg);
   YYLONGJMP (yystackp->yyexception_buffer, 1);
 }
@@ -844,13 +858,11 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
  *  yyerr for YYERROR, yyabort for YYABORT.  */
 /*ARGSUSED*/ static YYRESULTTAG
 yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
-              YYSTYPE* yyvalp,
-              YYLTYPE* YYOPTIONAL_LOC (yylocp),
-              yyGLRStack* yystackp
-              ]b4_user_formals[)
+              yyGLRStack* yystackp,
+              YYSTYPE* yyvalp]b4_locuser_formals[)
 {
   yybool yynormal __attribute__ ((__unused__)) =
-    (yystackp->yysplitPoint == NULL);
+    (yystackp->yysplitPoint == YY_NULL);
   int yylow;
 ]b4_parse_param_use([yyvalp], [yylocp])dnl
 [# undef yyerrok
@@ -876,9 +888,9 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
   if (yyrhslen == 0)
     *yyvalp = yyval_default;
   else
-    *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;
+    *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;]b4_locations_if([[
   YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen);
-]b4_locations_if([[  yystackp->yyerror_range[1].yystate.yyloc = *yylocp;
+  yystackp->yyerror_range[1].yystate.yyloc = *yylocp;
 ]])[
   switch (yyn)
     {
@@ -926,7 +938,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
 {
   if (yys->yyresolved)
     yydestruct (yymsg, yystos[yys->yylrState],
-                &yys->yysemantics.yysval]b4_locations_if([, &yys->yyloc])[]b4_user_args[);
+                &yys->yysemantics.yysval]b4_locuser_args([&yys->yyloc])[);
   else
     {
 #if YYDEBUG
@@ -937,7 +949,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
           else
             YYFPRINTF (stderr, "%s incomplete ", yymsg);
           yy_symbol_print (stderr, yystos[yys->yylrState],
-                           NULL]b4_locations_if([, &yys->yyloc])[]b4_user_args[);
+                           YY_NULL]b4_locuser_args([&yys->yyloc])[);
           YYFPRINTF (stderr, "\n");
         }
 #endif
@@ -1068,8 +1080,8 @@ yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
   if (yystackp->yytops.yylookaheadNeeds[yyk])
     {
       yynewOption->yyrawchar = yychar;
-      yynewOption->yyval = yylval;
-      yynewOption->yyloc = yylloc;
+      yynewOption->yyval = yylval;]b4_locations_if([
+      yynewOption->yyloc = yylloc;])[
     }
   else
     yynewOption->yyrawchar = YYEMPTY;
@@ -1090,7 +1102,7 @@ yyinitStateSet (yyGLRStateSet* yyset)
   yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
   if (! yyset->yystates)
     return yyfalse;
-  yyset->yystates[0] = NULL;
+  yyset->yystates[0] = YY_NULL;
   yyset->yylookaheadNeeds =
     (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
   if (! yyset->yylookaheadNeeds)
@@ -1120,8 +1132,8 @@ yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
   if (!yystackp->yyitems)
     return yyfalse;
   yystackp->yynextFree = yystackp->yyitems;
-  yystackp->yysplitPoint = NULL;
-  yystackp->yylastDeleted = NULL;
+  yystackp->yysplitPoint = YY_NULL;
+  yystackp->yylastDeleted = YY_NULL;
   return yyinitStateSet (&yystackp->yytops);
 }
 
@@ -1160,10 +1172,10 @@ yyexpandGLRStack (yyGLRStack* yystackp)
         {
           yyGLRState* yys0 = &yyp0->yystate;
           yyGLRState* yys1 = &yyp1->yystate;
-          if (yys0->yypred != NULL)
+          if (yys0->yypred != YY_NULL)
             yys1->yypred =
               YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
-          if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != NULL)
+          if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULL)
             yys1->yysemantics.yyfirstVal =
               YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
         }
@@ -1171,18 +1183,18 @@ yyexpandGLRStack (yyGLRStack* yystackp)
         {
           yySemanticOption* yyv0 = &yyp0->yyoption;
           yySemanticOption* yyv1 = &yyp1->yyoption;
-          if (yyv0->yystate != NULL)
+          if (yyv0->yystate != YY_NULL)
             yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate);
-          if (yyv0->yynext != NULL)
+          if (yyv0->yynext != YY_NULL)
             yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption);
         }
     }
-  if (yystackp->yysplitPoint != NULL)
+  if (yystackp->yysplitPoint != YY_NULL)
     yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems,
                                  yystackp->yysplitPoint, yystate);
 
   for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1)
-    if (yystackp->yytops.yystates[yyn] != NULL)
+    if (yystackp->yytops.yystates[yyn] != YY_NULL)
       yystackp->yytops.yystates[yyn] =
         YYRELOC (yystackp->yyitems, yynewItems,
                  yystackp->yytops.yystates[yyn], yystate);
@@ -1206,7 +1218,7 @@ yyfreeGLRStack (yyGLRStack* yystackp)
 static inline void
 yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
 {
-  if (yystackp->yysplitPoint != NULL && yystackp->yysplitPoint > yys)
+  if (yystackp->yysplitPoint != YY_NULL && yystackp->yysplitPoint > yys)
     yystackp->yysplitPoint = yys;
 }
 
@@ -1214,9 +1226,9 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
 static inline void
 yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
 {
-  if (yystackp->yytops.yystates[yyk] != NULL)
+  if (yystackp->yytops.yystates[yyk] != YY_NULL)
     yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
-  yystackp->yytops.yystates[yyk] = NULL;
+  yystackp->yytops.yystates[yyk] = YY_NULL;
 }
 
 /** Undelete the last stack in *YYSTACKP that was marked as deleted.  Can
@@ -1225,12 +1237,12 @@ yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
 static void
 yyundeleteLastStack (yyGLRStack* yystackp)
 {
-  if (yystackp->yylastDeleted == NULL || yystackp->yytops.yysize != 0)
+  if (yystackp->yylastDeleted == YY_NULL || yystackp->yytops.yysize != 0)
     return;
   yystackp->yytops.yystates[0] = yystackp->yylastDeleted;
   yystackp->yytops.yysize = 1;
   YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
-  yystackp->yylastDeleted = NULL;
+  yystackp->yylastDeleted = YY_NULL;
 }
 
 static inline void
@@ -1240,7 +1252,7 @@ yyremoveDeletes (yyGLRStack* yystackp)
   yyi = yyj = 0;
   while (yyj < yystackp->yytops.yysize)
     {
-      if (yystackp->yytops.yystates[yyi] == NULL)
+      if (yystackp->yytops.yystates[yyi] == YY_NULL)
         {
           if (yyi == yyj)
             {
@@ -1275,7 +1287,7 @@ yyremoveDeletes (yyGLRStack* yystackp)
 static inline void
 yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
             size_t yyposn,
-            YYSTYPE* yyvalp, YYLTYPE* yylocp)
+            YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
 {
   yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
 
@@ -1283,8 +1295,8 @@ yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
   yynewState->yyposn = yyposn;
   yynewState->yyresolved = yytrue;
   yynewState->yypred = yystackp->yytops.yystates[yyk];
-  yynewState->yysemantics.yysval = *yyvalp;
-  yynewState->yyloc = *yylocp;
+  yynewState->yysemantics.yysval = *yyvalp;]b4_locations_if([
+  yynewState->yyloc = *yylocp;])[
   yystackp->yytops.yystates[yyk] = yynewState;
 
   YY_RESERVE_GLRSTACK (yystackp);
@@ -1303,7 +1315,7 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
   yynewState->yyposn = yyposn;
   yynewState->yyresolved = yyfalse;
   yynewState->yypred = yystackp->yytops.yystates[yyk];
-  yynewState->yysemantics.yyfirstVal = NULL;
+  yynewState->yysemantics.yyfirstVal = YY_NULL;
   yystackp->yytops.yystates[yyk] = yynewState;
 
   /* Invokes YY_RESERVE_GLRSTACK.  */
@@ -1359,11 +1371,11 @@ yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
  *  for userAction.  */
 static inline YYRESULTTAG
 yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
-            YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
+            YYSTYPE* yyvalp]b4_locuser_formals[)
 {
   int yynrhs = yyrhsLength (yyrule);
 
-  if (yystackp->yysplitPoint == NULL)
+  if (yystackp->yysplitPoint == YY_NULL)
     {
       /* Standard special case: single stack.  */
       yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
@@ -1372,8 +1384,8 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
       yystackp->yyspaceLeft += yynrhs;
       yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
       YY_REDUCE_PRINT ((1, yyrhs, yyk, yyrule]b4_user_args[));
-      return yyuserAction (yyrule, yynrhs, yyrhs,
-                           yyvalp, yylocp, yystackp]b4_user_args[);
+      return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
+                           yyvalp]b4_locuser_args[);
     }
   else
     {
@@ -1394,7 +1406,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
       yystackp->yytops.yystates[yyk] = yys;
       YY_REDUCE_PRINT ((0, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
       return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
-                           yyvalp, yylocp, yystackp]b4_user_args[);
+                           yystackp, yyvalp]b4_locuser_args[);
     }
 }
 
@@ -1415,14 +1427,13 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
 {
   size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
 
-  if (yyforceEval || yystackp->yysplitPoint == NULL)
+  if (yyforceEval || yystackp->yysplitPoint == YY_NULL)
     {
       YYRESULTTAG yyflag;
-      YYSTYPE yysval;
-      YYLTYPE yyloc;
+      YYSTYPE yysval;]b4_locations_if([
+      YYLTYPE yyloc;])[
 
-      yyflag = yydoAction (yystackp, yyk, yyrule, &yysval,
-                           &yyloc]b4_user_args[);
+      yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
       if (yyflag == yyerr && yystackp->yysplitPoint != NULL)
         {
           YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
@@ -1434,7 +1445,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
       yyglrShift (yystackp, yyk,
                   yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState,
                                  yylhsNonterm (yyrule)),
-                  yyposn, &yysval, &yyloc);
+                  yyposn, &yysval]b4_locations_if([, &yyloc])[);
     }
   else
     {
@@ -1456,7 +1467,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
                   "Now in state %d.\n",
                   (unsigned long int) yyk, yyrule - 1, yynewLRState));
       for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
-        if (yyi != yyk && yystackp->yytops.yystates[yyi] != NULL)
+        if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL)
           {
             yyGLRState* yyp, *yysplit = yystackp->yysplitPoint;
             yyp = yystackp->yytops.yystates[yyi];
@@ -1483,7 +1494,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
 static size_t
 yysplitStack (yyGLRStack* yystackp, size_t yyk)
 {
-  if (yystackp->yysplitPoint == NULL)
+  if (yystackp->yysplitPoint == YY_NULL)
     {
       YYASSERT (yyk == 0);
       yystackp->yysplitPoint = yystackp->yytops.yystates[yyk];
@@ -1493,7 +1504,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
       yyGLRState** yynewStates;
       yybool* yynewLookaheadNeeds;
 
-      yynewStates = NULL;
+      yynewStates = YY_NULL;
 
       if (yystackp->yytops.yycapacity
           > (YYSIZEMAX / (2 * sizeof yynewStates[0])))
@@ -1504,7 +1515,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
         (yyGLRState**) YYREALLOC (yystackp->yytops.yystates,
                                   (yystackp->yytops.yycapacity
                                    * sizeof yynewStates[0]));
-      if (yynewStates == NULL)
+      if (yynewStates == YY_NULL)
         yyMemoryExhausted (yystackp);
       yystackp->yytops.yystates = yynewStates;
 
@@ -1512,7 +1523,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
         (yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
                              (yystackp->yytops.yycapacity
                               * sizeof yynewLookaheadNeeds[0]));
-      if (yynewLookaheadNeeds == NULL)
+      if (yynewLookaheadNeeds == YY_NULL)
         yyMemoryExhausted (yystackp);
       yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
     }
@@ -1578,9 +1589,9 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
           yyz1 = yys1->yysemantics.yyfirstVal;
           while (YYID (yytrue))
             {
-              if (yyz1 == *yyz0p || yyz1 == NULL)
+              if (yyz1 == *yyz0p || yyz1 == YY_NULL)
                 break;
-              else if (*yyz0p == NULL)
+              else if (*yyz0p == YY_NULL)
                 {
                   *yyz0p = yyz1;
                   break;
@@ -1654,13 +1665,13 @@ yyresolveStates (yyGLRState* yys, int yyn,
  *  semantic values if invoked).  */
 static YYRESULTTAG
 yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
-                 YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
+                 YYSTYPE* yyvalp]b4_locuser_formals[)
 {
   yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
   int yynrhs;
   int yychar_current;
-  YYSTYPE yylval_current;
-  YYLTYPE yylloc_current;
+  YYSTYPE yylval_current;]b4_locations_if([
+  YYLTYPE yylloc_current;])[
   YYRESULTTAG yyflag;
 
   yynrhs = yyrhsLength (yyopt->yyrule);
@@ -1678,17 +1689,17 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
     /* Set default location.  */
     yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
   yychar_current = yychar;
-  yylval_current = yylval;
-  yylloc_current = yylloc;
+  yylval_current = yylval;]b4_locations_if([
+  yylloc_current = yylloc;])[
   yychar = yyopt->yyrawchar;
-  yylval = yyopt->yyval;
-  yylloc = yyopt->yyloc;
+  yylval = yyopt->yyval;]b4_locations_if([
+  yylloc = yyopt->yyloc;])[
   yyflag = yyuserAction (yyopt->yyrule, yynrhs,
                            yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
-                           yyvalp, yylocp, yystackp]b4_user_args[);
+                         yystackp, yyvalp]b4_locuser_args[);
   yychar = yychar_current;
-  yylval = yylval_current;
-  yylloc = yylloc_current;
+  yylval = yylval_current;]b4_locations_if([
+  yylloc = yylloc_current;])[
   return yyflag;
 }
 
@@ -1704,7 +1715,7 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
 
   for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
     yystates[yyi] = yys;
-  if (yys == NULL)
+  if (yys == YY_NULL)
     {
       yyleftmost_state.yyposn = 0;
       yystates[0] = &yyleftmost_state;
@@ -1779,7 +1790,7 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
           YYSTYPE yylval_current;
           YYLTYPE yylloc_current;
           yyoption = yys1->yysemantics.yyfirstVal;
-          YYASSERT (yyoption != NULL);
+          YYASSERT (yyoption != YY_NULL);
           yynrhs = yyrhsLength (yyoption->yyrule);
           if (yynrhs > 0)
             {
@@ -1829,16 +1840,14 @@ static YYRESULTTAG
 yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
 {
   yySemanticOption* yyoptionList = yys->yysemantics.yyfirstVal;
-  yySemanticOption* yybest;
+  yySemanticOption* yybest = yyoptionList;
   yySemanticOption** yypp;
-  yybool yymerge;
+  yybool yymerge = yyfalse;
   YYSTYPE yysval;
-  YYRESULTTAG yyflag;
-  YYLTYPE *yylocp = &yys->yyloc;
+  YYRESULTTAG yyflag;]b4_locations_if([
+  YYLTYPE *yylocp = &yys->yyloc;])[
 
-  yybest = yyoptionList;
-  yymerge = yyfalse;
-  for (yypp = &yyoptionList->yynext; *yypp != NULL; )
+  for (yypp = &yyoptionList->yynext; *yypp != YY_NULL; )
     {
       yySemanticOption* yyp = *yypp;
 
@@ -1878,22 +1887,20 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
     {
       yySemanticOption* yyp;
       int yyprec = yydprec[yybest->yyrule];
-      yyflag = yyresolveAction (yybest, yystackp, &yysval,
-                                yylocp]b4_user_args[);
+      yyflag = yyresolveAction (yybest, yystackp, &yysval]b4_locuser_args[);
       if (yyflag == yyok)
-        for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext)
+        for (yyp = yybest->yynext; yyp != YY_NULL; yyp = yyp->yynext)
           {
             if (yyprec == yydprec[yyp->yyrule])
               {
-                YYSTYPE yysval_other;
-                YYLTYPE yydummy;
-                yyflag = yyresolveAction (yyp, yystackp, &yysval_other,
-                                          &yydummy]b4_user_args[);
+                YYSTYPE yysval_other;]b4_locations_if([
+                YYLTYPE yydummy;])[
+                yyflag = yyresolveAction (yyp, yystackp, &yysval_other]b4_locuser_args([&yydummy])[);
                 if (yyflag != yyok)
                   {
                     yydestruct ("Cleanup: discarding incompletely merged value for",
                                 yystos[yys->yylrState],
-                                &yysval]b4_locations_if([, yylocp])[]b4_user_args[);
+                                &yysval]b4_locuser_args[);
                     break;
                   }
                 yyuserMerge (yymerger[yyp->yyrule], &yysval, &yysval_other);
@@ -1901,7 +1908,7 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
           }
     }
   else
-    yyflag = yyresolveAction (yybest, yystackp, &yysval, yylocp]b4_user_args[);
+    yyflag = yyresolveAction (yybest, yystackp, &yysval]b4_locuser_args([yylocp])[);
 
   if (yyflag == yyok)
     {
@@ -1909,14 +1916,14 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
       yys->yysemantics.yysval = yysval;
     }
   else
-    yys->yysemantics.yyfirstVal = NULL;
+    yys->yysemantics.yyfirstVal = YY_NULL;
   return yyflag;
 }
 
 static YYRESULTTAG
 yyresolveStack (yyGLRStack* yystackp]b4_user_formals[)
 {
-  if (yystackp->yysplitPoint != NULL)
+  if (yystackp->yysplitPoint != YY_NULL)
     {
       yyGLRState* yys;
       int yyn;
@@ -1936,10 +1943,10 @@ yycompressStack (yyGLRStack* yystackp)
 {
   yyGLRState* yyp, *yyq, *yyr;
 
-  if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == NULL)
+  if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == YY_NULL)
     return;
 
-  for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL;
+  for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = YY_NULL;
        yyp != yystackp->yysplitPoint;
        yyr = yyp, yyp = yyq, yyq = yyp->yypred)
     yyp->yypred = yyr;
@@ -1947,10 +1954,10 @@ yycompressStack (yyGLRStack* yystackp)
   yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
   yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
   yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
-  yystackp->yysplitPoint = NULL;
-  yystackp->yylastDeleted = NULL;
+  yystackp->yysplitPoint = YY_NULL;
+  yystackp->yylastDeleted = YY_NULL;
 
-  while (yyr != NULL)
+  while (yyr != YY_NULL)
     {
       yystackp->yynextFree->yystate = *yyr;
       yyr = yyr->yypred;
@@ -1965,7 +1972,7 @@ static YYRESULTTAG
 yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
                    size_t yyposn]b4_pure_formals[)
 {
-  while (yystackp->yytops.yystates[yyk] != NULL)
+  while (yystackp->yytops.yystates[yyk] != YY_NULL)
     {
       yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
       YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
@@ -2086,14 +2093,14 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
   yyerror (]b4_lyyerror_args[YY_("syntax error"));
 #else
   yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
-  size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken));
+  size_t yysize0 = yytnamerr (YY_NULL, yytokenName (yytoken));
   size_t yysize = yysize0;
   size_t yysize1;
   yybool yysize_overflow = yyfalse;
-  char* yymsg = NULL;
+  char* yymsg = YY_NULL;
   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
   /* Internationalized format string. */
-  const char *yyformat = 0;
+  const char *yyformat = YY_NULL;
   /* Arguments of yyformat. */
   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
   /* Number of reported tokens (one for the "unexpected", one per
@@ -2148,7 +2155,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
                     break;
                   }
                 yyarg[yycount++] = yytokenName (yyx);
-                yysize1 = yysize + yytnamerr (NULL, yytokenName (yyx));
+                yysize1 = yysize + yytnamerr (YY_NULL, yytokenName (yyx));
                 yysize_overflow |= yysize1 < yysize;
                 yysize = yysize1;
               }
@@ -2222,7 +2229,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
       {
         yySymbol yytoken;
         if (yychar == YYEOF)
-          yyFail (yystackp][]b4_lpure_args[, NULL);
+          yyFail (yystackp][]b4_lpure_args[, YY_NULL);
         if (yychar != YYEMPTY)
           {]b4_locations_if([[
             /* We throw away the lookahead, but the error range
@@ -2234,7 +2241,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
             YYLLOC_DEFAULT ((yys->yyloc), yyerror_range, 2);]])[
             yytoken = YYTRANSLATE (yychar);
             yydestruct ("Error: discarding",
-                        yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
+                        yytoken, &yylval]b4_locuser_args([&yylloc])[);
           }
         YYDPRINTF ((stderr, "Reading a token: "));
         yychar = YYLEX;
@@ -2263,10 +2270,10 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
 
   /* Reduce to one stack.  */
   for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
-    if (yystackp->yytops.yystates[yyk] != NULL)
+    if (yystackp->yytops.yystates[yyk] != YY_NULL)
       break;
   if (yyk >= yystackp->yytops.yysize)
-    yyFail (yystackp][]b4_lpure_args[, NULL);
+    yyFail (yystackp][]b4_lpure_args[, YY_NULL);
   for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
     yymarkStackDeleted (yystackp, yyk);
   yyremoveDeletes (yystackp);
@@ -2274,7 +2281,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
 
   /* Now pop stack until we find a state that shifts the error token.  */
   yystackp->yyerrState = 3;
-  while (yystackp->yytops.yystates[0] != NULL)
+  while (yystackp->yytops.yystates[0] != YY_NULL)
     {
       yyGLRState *yys = yystackp->yytops.yystates[0];
       yyj = yypact[yys->yylrState];
@@ -2284,27 +2291,28 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
           if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
               && yyisShiftAction (yytable[yyj]))
             {
-              /* Shift the error token having adjusted its location.  */
-              YYLTYPE yyerrloc;]b4_locations_if([[
+              /* Shift the error token.  */]b4_locations_if([[
+              /* First adjust its location.*/
+              YYLTYPE yyerrloc;
               yystackp->yyerror_range[2].yystate.yyloc = yylloc;
               YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[
               YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
                                &yylval, &yyerrloc);
               yyglrShift (yystackp, 0, yytable[yyj],
-                          yys->yyposn, &yylval, &yyerrloc);
+                          yys->yyposn, &yylval]b4_locations_if([, &yyerrloc])[);
               yys = yystackp->yytops.yystates[0];
               break;
             }
-        }
-]b4_locations_if([[      yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
-      if (yys->yypred != NULL)
+        }]b4_locations_if([[
+      yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
+      if (yys->yypred != YY_NULL)
         yydestroyGLRState ("Error: popping", yys]b4_user_args[);
       yystackp->yytops.yystates[0] = yys->yypred;
       yystackp->yynextFree -= 1;
       yystackp->yyspaceLeft += 1;
     }
-  if (yystackp->yytops.yystates[0] == NULL)
-    yyFail (yystackp][]b4_lpure_args[, NULL);
+  if (yystackp->yytops.yystates[0] == YY_NULL)
+    yyFail (yystackp][]b4_lpure_args[, YY_NULL);
 }
 
 #define YYCHK1(YYE)                                                          \
@@ -2361,7 +2369,7 @@ m4_popdef([b4_at_dollar])])dnl
     case 2: goto yyexhaustedlab;
     default: goto yybuglab;
     }
-  yyglrShift (&yystack, 0, 0, 0, &yylval, &yylloc);
+  yyglrShift (&yystack, 0, 0, 0, &yylval]b4_locations_if([, &yylloc])[);
   yyposn = 0;
 
   while (YYID (yytrue))
@@ -2419,7 +2427,7 @@ m4_popdef([b4_at_dollar])])dnl
                   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
                   yychar = YYEMPTY;
                   yyposn += 1;
-                  yyglrShift (&yystack, 0, yyaction, yyposn, &yylval, &yylloc);
+                  yyglrShift (&yystack, 0, yyaction, yyposn, &yylval]b4_locations_if([, &yylloc])[);
                   if (0 < yystack.yyerrState)
                     yystack.yyerrState -= 1;
                 }
@@ -2495,7 +2503,7 @@ m4_popdef([b4_at_dollar])])dnl
               YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yys));
               YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
               yyglrShift (&yystack, yys, yyaction, yyposn,
-                          &yylval, &yylloc);
+                          &yylval]b4_locations_if([, &yylloc])[);
               YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
                           (unsigned long int) yys,
                           yystack.yytops.yystates[yys]->yylrState));
@@ -2535,8 +2543,7 @@ m4_popdef([b4_at_dollar])])dnl
  yyreturn:
   if (yychar != YYEMPTY)
     yydestruct ("Cleanup: discarding lookahead",
-                YYTRANSLATE (yychar),
-                &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
+                YYTRANSLATE (yychar), &yylval]b4_locuser_args([&yylloc])[);
 
   /* If the stack is well-formed, pop the stack until it is empty,
      destroying its entries as we go.  But free the stack regardless
@@ -2555,7 +2562,7 @@ m4_popdef([b4_at_dollar])])dnl
                   {
                     yyGLRState *yys = yystates[yyk];
 ]b4_locations_if([[                 yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
-)[                  if (yys->yypred != NULL)
+)[                  if (yys->yypred != YY_NULL)
                       yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
                     yystates[yyk] = yys->yypred;
                     yystack.yynextFree -= 1;
@@ -2592,7 +2599,7 @@ yy_yypstack (yyGLRState* yys)
 static void
 yypstates (yyGLRState* yyst)
 {
-  if (yyst == NULL)
+  if (yyst == YY_NULL)
     YYFPRINTF (stderr, "<null>");
   else
     yy_yypstack (yyst);
@@ -2606,7 +2613,7 @@ yypstack (yyGLRStack* yystackp, size_t yyk)
 }
 
 #define YYINDEX(YYX)                                                         \
-    ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems)
+    ((YYX) == YY_NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems)
 
 
 static void
index 4179deafdf691119f2a6c00f07cf63b673da0740..d67c9548cf603db81d34573863e75f2cae79f907 100644 (file)
@@ -157,6 +157,8 @@ dnl FIXME: This is wrong, we want computed header guards.
 b4_variant_define
 b4_namespace_close])[
 
+]b4_null_define[
+
 /* Enabling traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG ]b4_parse_trace_if([1], [0])[
@@ -1056,7 +1058,7 @@ b4_error_verbose_if([state_type yystate, int yytoken],
           }
       }
 
-    char const* yyformat = 0;
+    char const* yyformat = YY_NULL;
     switch (yycount)
       {
 #define YYCASE_(N, S)                         \
index 57ff9932f93086a152d23edc34287424747df61f..a40d6c272a6ee2374acf437b9c6f83c1a4698825 100644 (file)
@@ -686,7 +686,7 @@ m4_popdef([b4_at_dollar])])dnl
               }
 
             /* Pop the current state because it cannot handle the error token.  */
-            if (yystack.height == 1)
+            if (yystack.height == 0)
               return false;
 
             ]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
index 174ce6ef47470cba742f5720328abfed0cfe6755..e750779c0fc8de053cf6c4e9ea3dd51d3ee664ba 100644 (file)
@@ -36,6 +36,8 @@ b4_copyright([Positions for Bison parsers in C++])[
 # include <string>
 # include <algorithm>
 
+]b4_null_define[
+
 ]b4_namespace_open[
   /// Abstract a position.
   class position
@@ -43,7 +45,7 @@ b4_copyright([Positions for Bison parsers in C++])[
   public:
 ]m4_ifdef([b4_location_constructors], [[
     /// Construct a position.
-    explicit position (]b4_percent_define_get([[filename_type]])[* f = 0,
+    explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULL,
                        unsigned int l = ]b4_location_initial_line[u,
                        unsigned int c = ]b4_location_initial_column[u)
       : filename (f)
@@ -54,25 +56,26 @@ b4_copyright([Positions for Bison parsers in C++])[
 
 ]])[
     /// Initialization.
-    inline void initialize (]b4_percent_define_get([[filename_type]])[* fn)
+    void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL,
+                     unsigned int l = ]b4_location_initial_line[u,
+                     unsigned int c = ]b4_location_initial_column[u)
     {
       filename = fn;
-      line = ]b4_location_initial_line[u;
-      column = ]b4_location_initial_column[u;
+      line = l;
+      column = c;
     }
 
     /** \name Line and Column related manipulators
      ** \{ */
     /// (line related) Advance to the COUNT next lines.
-    /// Set current column to initial value.
-    inline void lines (int count = 1)
+    void lines (int count = 1)
     {
       column = ]b4_location_initial_column[u;
       line += count;
     }
 
     /// (column related) Advance to the COUNT next columns.
-    inline void columns (int count = 1)
+    void columns (int count = 1)
     {
       column = std::max (]b4_location_initial_column[u, column + count);
     }
@@ -195,9 +198,11 @@ b4_copyright([Locations for Bison parsers in C++])[
 
 ])[
     /// Initialization.
-    inline void initialize (]b4_percent_define_get([[filename_type]])[* fn)
+    void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULL,
+                     unsigned int l = ]b4_location_initial_line[u,
+                     unsigned int c = ]b4_location_initial_column[u)
     {
-      begin.initialize (fn);
+      begin.initialize (f, l, c);
       end = begin;
     }
 
@@ -205,19 +210,19 @@ b4_copyright([Locations for Bison parsers in C++])[
      ** \{ */
   public:
     /// Reset initial location to final location.
-    inline void step ()
+    void step ()
     {
       begin = end;
     }
 
     /// Extend the current location to the COUNT next columns.
-    inline void columns (unsigned int count = 1)
+    void columns (unsigned int count = 1)
     {
       end += count;
     }
 
     /// Extend the current location to the COUNT next lines.
-    inline void lines (unsigned int count = 1)
+    void lines (unsigned int count = 1)
     {
       end.lines (count);
     }
index 19b5331db0acd06bff6d2023190a15cbb65cd9a7..a8dce4a7acdf32c7a1fe9e3c7d84955c5cf3d49e 100644 (file)
@@ -268,6 +268,8 @@ m4_if(b4_prefix, [yy], [],
 /* Copy the first part of user declarations.  */
 ]b4_user_pre_prologue[
 
+]b4_null_define[
+
 /* Enabling traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG ]b4_parse_trace_if([1], [0])[
index 21883b3baedde630da9eeaa70779c8b61ef72162..45125c191607849f707008f3ea24409621e9e4bb 100644 (file)
@@ -320,6 +320,11 @@ C++ Parsers
 * C++ Scanner Interface::       Exchanges between yylex and parse
 * A Complete C++ Example::      Demonstrating their use
 
+C++ Location Values
+
+* C++ position::                One point in the source file
+* C++ location::                Two points in the source file
+
 A Complete C++ Example
 
 * Calc++ --- C++ Calculator::   The specifications
@@ -9324,55 +9329,98 @@ define a @code{position}, a single point in a file, and a @code{location}, a
 range composed of a pair of @code{position}s (possibly spanning several
 files).
 
-@deftypemethod {position} {std::string*} file
+@tindex uint
+In this section @code{uint} is an abbreviation for @code{unsigned int}: in
+genuine code only the latter is used.
+
+@menu
+* C++ position::         One point in the source file
+* C++ location::         Two points in the source file
+@end menu
+
+@node C++ position
+@subsubsection C++ @code{position}
+
+@deftypeop {Constructor} {position} {} position (std::string* @var{file} = 0, uint @var{line} = 1, uint @var{col} = 1)
+Create a @code{position} denoting a given point.  Note that @code{file} is
+not reclaimed when the @code{position} is destroyed: memory managed must be
+handled elsewhere.
+@end deftypeop
+
+@deftypemethod {position} {void} initialize (std::string* @var{file} = 0, uint @var{line} = 1, uint @var{col} = 1)
+Reset the position to the given values.
+@end deftypemethod
+
+@deftypeivar {position} {std::string*} file
 The name of the file.  It will always be handled as a pointer, the
 parser will never duplicate nor deallocate it.  As an experimental
 feature you may change it to @samp{@var{type}*} using @samp{%define
 filename_type "@var{type}"}.
-@end deftypemethod
+@end deftypeivar
 
-@deftypemethod {position} {unsigned int} line
+@deftypeivar {position} {uint} line
 The line, starting at 1.
-@end deftypemethod
+@end deftypeivar
 
-@deftypemethod {position} {unsigned int} lines (int @var{height} = 1)
+@deftypemethod {position} {uint} lines (int @var{height} = 1)
 Advance by @var{height} lines, resetting the column number.
 @end deftypemethod
 
-@deftypemethod {position} {unsigned int} column
-The column, starting at 0.
-@end deftypemethod
+@deftypeivar {position} {uint} column
+The column, starting at 1.
+@end deftypeivar
 
-@deftypemethod {position} {unsigned int} columns (int @var{width} = 1)
+@deftypemethod {position} {uint} columns (int @var{width} = 1)
 Advance by @var{width} columns, without changing the line number.
 @end deftypemethod
 
-@deftypemethod {position} {position&} operator+= (position& @var{pos}, int @var{width})
-@deftypemethodx {position} {position} operator+ (const position& @var{pos}, int @var{width})
-@deftypemethodx {position} {position&} operator-= (const position& @var{pos}, int @var{width})
-@deftypemethodx {position} {position} operator- (position& @var{pos}, int @var{width})
+@deftypemethod {position} {position&} operator+= (int @var{width})
+@deftypemethodx {position} {position} operator+ (int @var{width})
+@deftypemethodx {position} {position&} operator-= (int @var{width})
+@deftypemethodx {position} {position} operator- (int @var{width})
 Various forms of syntactic sugar for @code{columns}.
 @end deftypemethod
 
-@deftypemethod {position} {position} operator<< (std::ostream @var{o}, const position& @var{p})
+@deftypemethod {position} {bool} operator== (const position& @var{that})
+@deftypemethodx {position} {bool} operator!= (const position& @var{that})
+Whether @code{*this} and @code{that} denote equal/different positions.
+@end deftypemethod
+
+@deftypefun {std::ostream&} operator<< (std::ostream& @var{o}, const position& @var{p})
 Report @var{p} on @var{o} like this:
 @samp{@var{file}:@var{line}.@var{column}}, or
 @samp{@var{line}.@var{column}} if @var{file} is null.
+@end deftypefun
+
+@node C++ location
+@subsubsection C++ @code{location}
+
+@deftypeop {Constructor} {location} {} location (const position& @var{begin}, const position& @var{end})
+Create a @code{Location} from the endpoints of the range.
+@end deftypeop
+
+@deftypeop {Constructor} {location} {} location (const position& @var{pos} = position())
+@deftypeopx {Constructor} {location} {} location (std::string* @var{file}, uint @var{line}, uint @var{col})
+Create a @code{Location} denoting an empty range located at a given point.
+@end deftypeop
+
+@deftypemethod {location} {void} initialize (std::string* @var{file} = 0, uint @var{line} = 1, uint @var{col} = 1)
+Reset the location to an empty range at the given values.
 @end deftypemethod
 
-@deftypemethod {location} {position} begin
-@deftypemethodx {location} {position} end
+@deftypeivar {location} {position} begin
+@deftypeivarx {location} {position} end
 The first, inclusive, position of the range, and the first beyond.
-@end deftypemethod
+@end deftypeivar
 
-@deftypemethod {location} {unsigned int} columns (int @var{width} = 1)
-@deftypemethodx {location} {unsigned int} lines (int @var{height} = 1)
+@deftypemethod {location} {uint} columns (int @var{width} = 1)
+@deftypemethodx {location} {uint} lines (int @var{height} = 1)
 Advance the @code{end} position.
 @end deftypemethod
 
-@deftypemethod {location} {location} operator+ (const location& @var{begin}, const location& @var{end})
-@deftypemethodx {location} {location} operator+ (const location& @var{begin}, int @var{width})
-@deftypemethodx {location} {location} operator+= (const location& @var{loc}, int @var{width})
+@deftypemethod {location} {location} operator+ (const location& @var{end})
+@deftypemethodx {location} {location} operator+ (int @var{width})
+@deftypemethodx {location} {location} operator+= (int @var{width})
 Various forms of syntactic sugar.
 @end deftypemethod
 
@@ -9380,6 +9428,16 @@ Various forms of syntactic sugar.
 Move @code{begin} onto @code{end}.
 @end deftypemethod
 
+@deftypemethod {location} {bool} operator== (const location& @var{that})
+@deftypemethodx {location} {bool} operator!= (const location& @var{that})
+Whether @code{*this} and @code{that} denote equal/different ranges of
+positions.
+@end deftypemethod
+
+@deftypefun {std::ostream&} operator<< (std::ostream& @var{o}, const location& @var{p})
+Report @var{p} on @var{o}, taking care of special cases such as: no
+@code{filename} defined, or equal filename/line or column.
+@end deftypefun
 
 @node C++ Parser Interface
 @subsection C++ Parser Interface
diff --git a/gnulib b/gnulib
index cbf7a84bcf8194d6687244fb0e0701539aeeee21..0e9d9267fa36c5493b36c0a2b2e422da101ee4b4 160000 (submodule)
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit cbf7a84bcf8194d6687244fb0e0701539aeeee21
+Subproject commit 0e9d9267fa36c5493b36c0a2b2e422da101ee4b4
index fdcae40b26945dfc0754eb1309c68b4efee5aa93..ad7b358ff52d7955292472d136cd49da6c253971 100644 (file)
@@ -24,7 +24,7 @@
 # define BISON_LIBIBERTY_H_ 1
 
 # ifndef __attribute__
-#  if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
+#  if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
 #   define __attribute__(x)
 #  endif
 # endif
diff --git a/m4/subpipe.m4 b/m4/subpipe.m4
deleted file mode 100644 (file)
index 0079c04..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# -*- Autoconf -*-
-# Checks required to run `subpipe'.
-#
-# Copyright (C) 2002-2003, 2005, 2009-2012 Free Software Foundation,
-# Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Written by Paul Eggert <eggert@twinsun.com>.
-
-AC_DEFUN([BISON_PREREQ_SUBPIPE],
-[
- AC_TYPE_PID_T
- AC_HEADER_SYS_WAIT
- AC_CHECK_FUNCS(dup2 waitpid)
- AC_FUNC_FORK
-])
index f0a76ceb7eea1da964bcdec9de085c9f99ef50cd..0d69e93e32a98c5f360ce1d90c52a88030b01001 100644 (file)
@@ -97,7 +97,7 @@ typedef size_t uintptr_t;
 #ifndef __attribute__
 /* This feature is available in gcc versions 2.5 and later.  */
 # if (! defined __GNUC__ || __GNUC__ < 2 \
-      || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
+       || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
 #  define __attribute__(Spec) /* empty */
 # endif
 #endif
index b49d94320ce90f0d98c5404fd6b32fd557afd0f7..7f8250293582791abb48408a07bfdc36f0a5ecd0 100644 (file)
@@ -345,7 +345,7 @@ thing:
 ;
 %%
 /* Alias to ARGV[1]. */
-const char *source = 0;
+const char *source = YY_NULL;
 
 static int
 yylex (]AT_LEX_FORMALS[)
index 0b888d16c553c1e968865434e6737cb5af6f68cb..7e4f2e28b5c44dc0dc18e93fb531f173b12c3f64 100644 (file)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# We need a C compiler.
+# We need `config.h'.
+CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
+
+## ------------------- ##
+## C/C++ Compilation.  ##
+## ------------------- ##
+
 : ${CC='@CC@'}
+: ${CXX='@CXX@'}
+
+# Is the compiler GCC?
+GCC='@GCC@'
 
 # We want no optimization.
-CFLAGS='@O0CFLAGS@ @WARN_CFLAGS_TEST@ @WERROR_CFLAGS@'
+  O0CFLAGS=`echo '@CFLAGS@'   | sed 's/-O[0-9] *//'`
+O0CXXFLAGS=`echo '@CXXFLAGS@' | sed 's/-O[0-9] *//'`
 
 # Sometimes a test group needs to ignore gcc warnings, so it locally
 # sets CFLAGS to this.
-NO_WERROR_CFLAGS='@O0CFLAGS@ @WARN_CFLAGS_TEST@'
-
-# We need `config.h'.
-CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
+  NO_WERROR_CFLAGS="$O0CFLAGS   @WARN_CFLAGS@   @WARN_CFLAGS_TEST@"
+NO_WERROR_CXXFLAGS="$O0CXXFLAGS @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@"
 
-# Is the compiler GCC?
-GCC='@GCC@'
-
-# The C++ compiler.
-: ${CXX='@CXX@'}
+# But most of the time, we want -Werror.
+  CFLAGS="$NO_WERROR_CFLAGS   @WERROR_CFLAGS@"
+CXXFLAGS="$NO_WERROR_CXXFLAGS @WERROR_CXXFLAGS@"
 
 # If 'exit 77'; skip all C++ tests; otherwise ':'.
 BISON_CXX_WORKS='@BISON_CXX_WORKS@'
 
-# We want no optimization with C++, too.
-CXXFLAGS='@O0CXXFLAGS@ @WARN_CXXFLAGS_TEST@ @WERROR_CFLAGS@'
+# Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known.
+if "$at_arg_compile_c_with_cxx"; then
+  CC=$CXX
+  O0CFLAGS=$O0CXXFLAGS
+  NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS
+  CFLAGS=$CXXFLAGS
+fi
+
+
+## ------- ##
+## Other.  ##
+## ------- ##
 
 # Are special link options needed?
 LDFLAGS='@LDFLAGS@'
index 28e6c50e8a08d02b54d1cdae54f7e57a13d02476..477c92d3759f5fe90bb5784c645498db6c796156 100644 (file)
@@ -241,7 +241,7 @@ int yylex (]AT_LEX_FORMALS[);
    are stored in a union, from which objects with constructors are
    excluded in C++). */
 %initial-action {
-  @$.initialize (0);
+  @$.initialize ();
 }
 ])])])[
 
index b3e79e9c2aef8fa9a474f4294d0362f3898682ce..b6ea163610618df73a408b1926350c637140c996 100644 (file)
@@ -781,3 +781,69 @@ AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Position']], [1], [ignore])
 AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Location']], [1], [ignore])
 
 AT_CLEANUP
+
+
+# ----------------------------------------------- #
+# Java syntax error handling without error token. #
+# ----------------------------------------------- #
+
+AT_SETUP([Java syntax error handling without error token])
+
+AT_DATA([[YYParser.y]], [[%language "Java"
+
+%lex-param { String s }
+
+%code imports {
+  import java.io.IOException;
+}
+
+%code lexer {
+  String Input;
+  int Position;
+
+  public YYLexer (String s)
+  {
+    Input    = s;
+    Position = 0;
+  }
+
+  public void yyerror (String s)
+  {
+    System.err.println (s);
+  }
+
+  public Object getLVal ()
+  {
+    return null;
+  }
+
+  public int yylex () throws IOException
+  {
+    if (Position >= Input.length ())
+      return EOF;
+    else
+      return Input.charAt (Position++);
+  }
+}
+
+%code {
+  public static void main (String args []) throws IOException
+  {
+    YYParser p = new YYParser (args [0]);
+    p.parse ();
+  }
+}
+%%
+input:
+  'a' 'a'
+;
+]])
+AT_BISON_CHECK([[YYParser.y]])
+AT_JAVA_COMPILE([[YYParser.java]])
+AT_JAVA_PARSER_CHECK([[YYParser aa]], [[0]], [[]], [[]])
+AT_JAVA_PARSER_CHECK([[YYParser ab]], [[0]], [[]], [[syntax error
+]])
+AT_JAVA_PARSER_CHECK([[YYParser ba]], [[0]], [[]], [[syntax error
+]])
+
+AT_CLEANUP
index 9aaedde0e8353274c9b7316d273db3f43ac6b8e4..41a2939d182ec0d7d001f47f04397992159b389f 100644 (file)
@@ -760,7 +760,7 @@ static const yytype_uint8 yyrline[] =
 static const char *const yytname[] =
 {
   "$end", "error", "$undefined", "\"if\"", "\"const\"", "\"then\"",
-  "\"else\"", "$accept", "statement", "struct_stat", "if", "else", 0
+  "\"else\"", "$accept", "statement", "struct_stat", "if", "else", YY_NULL
 };
 static const yytype_uint16 yytoknum[] =
 {