bison-patches
[Top][All Lists]
Advanced

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

FYI: lalr1.cc: filename are pointers


From: Akim Demaille
Subject: FYI: lalr1.cc: filename are pointers
Date: Tue, 21 Dec 2004 13:26:45 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

Patch in two bits, because I checked it in in two parts :(


2004-12-21  Akim Demaille  <address@hidden>

        Don't impose std::string for filenames.

        * data/lalr1.cc (b4_filename_type): New.
        (position::filename): Use it.
        (parser.hh): Move the inclusion of stack.hh and location.hh below
        the user code, so that needed headers for the filename type can be
        included first.
        Forward declare them before the user code.
        * tests/Makefile.am (check-local, installcheck-local): Pass
        TESTSUITEFLAGS to the TESTSUITE.

Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.75
diff -u -u -r1.75 lalr1.cc
--- data/lalr1.cc 20 Dec 2004 13:56:38 -0000 1.75
+++ data/lalr1.cc 21 Dec 2004 11:01:33 -0000
@@ -46,6 +46,7 @@
 [(address@hidden([$1 - $2])@}m4_ifval([$3], [.$3]))])
 
 m4_define_default([b4_location_type], [location])
+m4_define_default([b4_filename_type], [std::string])
 
 # b4_lhs_location()
 # -----------------
@@ -118,9 +119,6 @@
 #ifndef PARSER_HEADER_H
 # define PARSER_HEADER_H
 
-#include "stack.hh"
-#include "location.hh"
-
 #include <string>
 #include <iostream>
 
@@ -135,6 +133,9 @@
 ]/* Line __line__ of lalr1.cc.  */
 b4_syncline(address@hidden@], address@hidden@])[
 
+#include "stack.hh"
+#include "location.hh"
+
 /* Enabling traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG ]b4_debug[
@@ -1168,7 +1169,7 @@
   public:
     /// Construct a position.
     position () :
-      filename (),
+      filename (0),
       line (initial_line),
       column (initial_column)
     {
@@ -1200,7 +1201,7 @@
 
   public:
     /// File name to which this position refers.
-    std::string filename;
+    ]b4_filename_type[* filename;
     /// Current line number.
     unsigned int line;
     /// Current column number.
@@ -1244,8 +1245,8 @@
   inline std::ostream&
   operator<< (std::ostream& ostr, const position& pos)
   {
-    if (!pos.filename.empty ())
-      ostr << pos.filename << ':';
+    if (pos.filename)
+      ostr << *pos.filename << ':';
     return ostr << pos.line << '.' << pos.column;
   }
 
@@ -1347,7 +1348,9 @@
   {
     position last = loc.end - 1;
     ostr << loc.begin;
-    if (loc.begin.filename != last.filename)
+    if (last.filename
+       && (!loc.begin.filename
+           || *loc.begin.filename != *last.filename))
       ostr << '-' << last;
     else if (loc.begin.line != last.line)
       ostr << '-' << last.line  << '.' << last.column;



Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.76
diff -u -u -r1.76 lalr1.cc
--- data/lalr1.cc 21 Dec 2004 12:03:47 -0000 1.76
+++ data/lalr1.cc 21 Dec 2004 12:25:20 -0000
@@ -125,6 +125,12 @@
 /* Using locations.  */
 #define YYLSP_NEEDED ]b4_locations_flag[
 
+namespace yy
+{
+  class position;
+  class location;
+}
+
 ]b4_token_defines(b4_tokens)[
 
 /* Copy the first part of user declarations.  */
Index: tests/Makefile.am
===================================================================
RCS file: /cvsroot/bison/bison/tests/Makefile.am,v
retrieving revision 1.34
diff -u -u -r1.34 Makefile.am
--- tests/Makefile.am 24 Dec 2003 08:30:45 -0000 1.34
+++ tests/Makefile.am 21 Dec 2004 12:25:20 -0000
@@ -1,7 +1,7 @@
 ## Process this file with automake to create Makefile.in.
 
 ## Makefile for Bison testsuite.
-## Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001, 2002, 2003, 2004 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
@@ -65,13 +65,13 @@
        test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
 
 check-local: atconfig atlocal $(TESTSUITE)
-       $(SHELL) $(TESTSUITE)
+       $(SHELL) $(TESTSUITE) $(TESTSUITEFLAGS)
 
 check_SCRIPTS = bison
 
 # Run the test suite on the *installed* tree.
 installcheck-local:
-       $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
+       $(SHELL) $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
 
 # Be real mean with it.
 .PHONY: maintainer-check-g++




reply via email to

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