bison-patches
[Top][All Lists]
Advanced

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

Using "%define location_type" c++ skeleton should exclude default locati


From: Chris Morley
Subject: Using "%define location_type" c++ skeleton should exclude default location
Date: Tue, 23 Mar 2010 08:14:18 -0000

Hi All,

I use Bison to generate a C++ parser using the lalr1 skeleton. I also use a custom location class.

I just upgraded a project from using v2.3.1 to v2.4.2 and as I am on Windows <windows.h> defines a max macro which breaks std::max now used in the 2.4.2 location.hh.

In itself not much of a problem but it made me realise that the default "location.hh" & forward decls of class location & position are included in the src.hpp regardless of a manual "%define location_type" in the yy file. IMO these should really be omitted if a custom location class is in use...

I never used m4 before but modified the lalr1.cc in v2.4.2 as follows to achieve this. It is not pretty as I couldn't determine how to tell if the user has defined "location_type" rather than the default - thus is a dependency between this lalr1.cc & the c++.m4

I don't use GLR, but it seems that the glr.cc has the same code (line 236+).

Chris Morley

--- >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ---


--- C:\cygwin\usr\share\bison\lalr1.cc  2010-03-23 07:58:56.000000000 -0000
+++ C:\cygwin\usr\src\bison-2.4.2\data\lalr1.cc 2010-02-25 04:56:42.000000000 -0000
@@ -45,21 +45,18 @@
]b4_percent_code_get([[requires]])[

#include <string>
#include <iostream>
#include "stack.hh"

-]m4_if( b4_percent_define_get(location_type), location, [
]b4_namespace_open[
  class position;
  class location;
]b4_namespace_close[

#include "location.hh"
-]
-, /*default location not included*/)[

/* Enabling traces.  */
#ifndef YYDEBUG
# define YYDEBUG ]b4_debug_flag[
#endif








reply via email to

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