bison-patches
[Top][All Lists]
Advanced

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

[FYI] c++-skeleton-location-bug.patch


From: Robert Anisko
Subject: [FYI] c++-skeleton-location-bug.patch
Date: Mon, 4 Mar 2002 17:48:34 +0100 (CET)

Index: ChangeLog
===================================================================
RCS file: /cvsroot/bison/bison/ChangeLog,v
retrieving revision 1.578
diff -u -r1.578 ChangeLog
--- ChangeLog   4 Mar 2002 16:23:35 -0000       1.578
+++ ChangeLog   4 Mar 2002 16:37:13 -0000
@@ -1,3 +1,9 @@
+2002-03-04  Robert Anisko  <address@hidden>
+
+       * data/bison.c++: Unmerge value as yylval and value as yyval.  Unmerge
+       location as yylloc and location as yyloc.  Use YYLLOC_DEFAULT, and
+       provide a default implementation.
+
 2002-03-04  Akim Demaille  <address@hidden>
 
        * tests/input.at (Invalid $n, Invalid @n): Add the ending `;'.
Index: data/bison.c++
===================================================================
RCS file: /cvsroot/bison/bison/data/bison.c++,v
retrieving revision 1.12
diff -u -r1.12 bison.c++
--- data/bison.c++      28 Feb 2002 14:56:33 -0000      1.12
+++ data/bison.c++      4 Mar 2002 16:37:13 -0000
@@ -88,6 +88,12 @@
 # define YYSTYPE yystype
 #endif
 
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+   Current.last_line = Rhs[[N]].last_line; \
+   Current.last_column = Rhs[[N]].last_column;
+#endif
+
 m4_if(b4_locations_flag, [0], [],
 [#ifndef YYLTYPE
 typedef struct yyltype
@@ -210,10 +216,14 @@
     /* Message.  */
     std::string message;
 
-    /* @$ and $$.  */
+    /* Semantic value and location of lookahead token.  */
     SemanticType value;
     LocationType location;
 
+    /* @$ and $$.  */
+    SemanticType yyval;
+    LocationType yyloc;
+
     /* Initial location.  */
     LocationType initlocation_;
   };
@@ -358,13 +368,13 @@
   len_ = r2_[[n_]];
   if (len_)
     {
-      value = semantic_stack_[[1 - len_]];
-      location = location_stack_[[1 - len_]];
+      yyval = semantic_stack_[[1 - len_]];
+      yyloc = location_stack_[[1 - len_]];
     }
   else
     {
-      value = semantic_stack_[[0]];
-      location = location_stack_[[0]];
+      yyval = semantic_stack_[[0]];
+      yyloc = location_stack_[[0]];
     }
 
 #if YYDEBUG
@@ -378,9 +388,15 @@
     }
 #endif
 
+  if (len_)
+    {
+      Slice< LocationType, LocationStack > slice (location_stack_, len_);
+      YYLLOC_DEFAULT (yyloc, slice, len_);
+    }
+
+  std::cout << "Reduced location is :" << yyloc << std::endl;
+
   {
-    SemanticType& yyval (value);
-    LocationType& yyloc (location);
     SemanticStack& yyvsp (semantic_stack_);
     LocationStack& yylsp (location_stack_);
 
@@ -405,8 +421,8 @@
     }
 #endif
 
-  semantic_stack_.push (value);
-  location_stack_.push (location);
+  semantic_stack_.push (yyval);
+  location_stack_.push (yyloc);
 
   /* Shift the result of the reduction.  */
   n_ = r1_[[n_]];
@@ -698,14 +714,14 @@
     T&
     operator [[]] (int index)
     {
-      return seq_[[seq_.size () - 1 + index]];
+      return seq_[[height () - 1 + index]];
     }
 
     inline
     const T&
     operator [[]] (int index) const
     {
-      return seq_[[seq_.size () - 1 + index]];
+      return seq_[[height () - 1 + index]];
     }
 
     inline
@@ -743,6 +759,30 @@
   private:
 
     S seq_;
+  };
+
+  template < class T, class S = Stack< T > >
+  class Slice
+  {
+  public:
+
+    Slice (const S& stack,
+          unsigned range) : stack_ (stack),
+                            range_ (range)
+    {
+    }
+
+    inline
+    const T&
+    operator [[]] (unsigned index) const
+    {
+      return stack_[[index - range_]];
+    }
+
+  private:
+
+    const S& stack_;
+    unsigned range_;
   };
 }
 



reply via email to

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