]> git.saurik.com Git - bison.git/blobdiff - data/lalr1.cc
c++: use YYRHSLOC.
[bison.git] / data / lalr1.cc
index b0b075ca74313bb635800d7a0bc237c791fe2363..8094cccffd08a4decc34aa29e2919ce0511f6ea4 100644 (file)
@@ -124,10 +124,10 @@ m4_define([b4_parser_class_name],
 b4_defines_if([],
               [b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
 
-b4_locations_if(
-[# Backward compatibility.
-m4_define([b4_location_constructors])
-m4_include(b4_pkgdatadir/[location.cc])])
+b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
+  [# Backward compatibility.
+  m4_define([b4_location_constructors])
+  m4_include(b4_pkgdatadir/[location.cc])])])
 m4_include(b4_pkgdatadir/[stack.hh])
 b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
 
@@ -149,8 +149,9 @@ dnl FIXME: This is wrong, we want computed header guards.
 #include <stdexcept>
 #include <string>
 #include <iostream>
-]b4_locations_if([#include "location.hh"])[
 #include "stack.hh"
+]b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
+                                          [[#include "location.hh"]])])[
 
 ]b4_variant_if([b4_namespace_open
 b4_variant_define
@@ -179,19 +180,20 @@ b4_namespace_close])[
    If N is 0, then set CURRENT to the empty location which ends
    the previous symbol: RHS[0] (always defined).  */
 
+#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
 #ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N)                        \
-do {                                                            \
-  if (N)                                                        \
-    {                                                           \
-      (Current).begin = (Rhs)[1].location.begin;                \
-      (Current).end   = (Rhs)[N].location.end;                 \
-    }                                                           \
-  else                                                          \
-    {                                                           \
-      (Current).begin = (Current).end = (Rhs)[0].location.end; \
-    }                                                           \
-} while (false)
+# define YYLLOC_DEFAULT(Current, Rhs, N)                               \
+ do                                                                    \
+   if (N)                                                              \
+     {                                                                 \
+       (Current).begin = YYRHSLOC (Rhs, 1).begin;                      \
+       (Current).end   = YYRHSLOC (Rhs, N).end;                        \
+     }                                                                 \
+   else                                                                \
+     {                                                                 \
+       (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;        \
+     }                                                                 \
+ while (false)
 #endif]])[
 
 ]b4_namespace_open[