bison-patches
[Top][All Lists]
Advanced

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

FYI: lalr1.cc: too far on the left


From: Akim Demaille
Subject: FYI: lalr1.cc: too far on the left
Date: Thu, 20 Feb 2003 15:44:47 +0100
User-agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2

Paul, I saw you were using Boundary where I use Position.  I kept
Position for historical reason (used this name for years now), but if
in English Boundary is better, I'm fine with this.  There is (yet) no
backward compatibility issue, so...

Index: ChangeLog
from   2003-02-20  Akim Demaille  <address@hidden>

        * data/lalr1.cc (position.hh): Make sure "columns" never pushes
        before initial_columns.
        (location.hh): Use consistent variable names when defining the
        operator<<.
        Use "last" so that we subtract from Positions, not from unsigned.

Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.26
diff -u -u -r1.26 lalr1.cc
--- data/lalr1.cc 20 Feb 2003 13:36:08 -0000 1.26
+++ data/lalr1.cc 20 Feb 2003 14:42:03 -0000
@@ -923,7 +923,10 @@
     /** \brief (column related) Advance to the COLUMNS next columns. */
     inline void columns (int columns = 1)
     {
-      column += columns;
+      if (int (initial_column) < columns + int (column))
+       column += columns;
+      else
+       column = initial_column;
     }
     /** \} */
 
@@ -1068,19 +1071,20 @@
 
   /** \brief Intercept output stream redirection.
    ** \param ostr the destination output stream
-   ** \param pos a reference to the Position to redirect
+   ** \param loc a reference to the Location to redirect
    **
-   ** Don't issue twice the line number when the location is on a single line.
+   ** Avoid duplicate information.
    */
-  inline std::ostream& operator<< (std::ostream& ostr, const Location& pos)
+  inline std::ostream& operator<< (std::ostream& ostr, const Location& loc)
   {
-    ostr << pos.begin;
-    if (pos.begin.filename != pos.end.filename)
-      ostr << '-' << pos.end - 1;
-    else if (pos.begin.line != pos.end.line)
-      ostr << '-' << pos.end.line  << '.' << pos.end.column - 1;
-    else if (pos.begin.column != pos.end.column - 1)
-      ostr << '-' << pos.end.column - 1;
+    Position last = loc.end - 1;
+    ostr << loc.begin;
+    if (loc.begin.filename != last.filename)
+      ostr << '-' << last;
+    else if (loc.begin.line != last.line)
+      ostr << '-' << last.line  << '.' << last.column;
+    else if (loc.begin.column != last.column)
+      ostr << '-' << last.column;
     return ostr;
   }
 




reply via email to

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