Bison and M4

pendell@hotmail.com
Thu, 04 Oct 2007 04:34:10 -0700

          From comp.compilers

Related articles
Bison and M4 pendell@hotmail.com (2007-10-04)
| List of all articles for this month |

From: pendell@hotmail.com
Newsgroups: comp.compilers
Date: Thu, 04 Oct 2007 04:34:10 -0700
Organization: Compilers Central
Keywords: yacc, question, comment
Posted-Date: 04 Oct 2007 22:15:59 EDT

I've already asked this on comp.lang.c++, and I'll try here as
well...


So I've just installed Fedora core 7 fresh from my machine. It comes
with G++, and bison installed directly.


So I try to make a program that uses bison. C++ chokes with the
error:


dimensions_dat.cc:1: error: expected constructor, destructor, or type
conversion before '(' token


Looking at the first line of dimensions_dat.cc, I find the following:


b4_copyright(Skeleton parser CASA Grammar Parsing with Bison,
1984, 1989, 1990, 2000, 2001, 2002)


Commenting this line out, the error goes away.


So just comment it out and go merrily on my way, right? Nope! There
are several uses of macros very like this one, in very hard-to-reach
places in the code. Far better just to get the macros working in the
first place.


Macros -- right. Looking around, I found that these are m4 macros
(used with the m4 preprocessor) define in /usr/share/bison/c.m4 .


I think what is *supposed* to happen is that c++ is supposed to run
the m4 processor first before doing anything else. These macros are
replaced by standard code, which is then properly compiled.


However, for some reason m4 is not replacing the macro calls. Either
it doesn't know where the macros are, or the macros are mis-defined
and being rejected. Since these are standard Bison definitions which
I have not touched, I find that highly unlikely.


Suggestions? Insight? If you don't know, where would I ask to find
out?
[Your installation of bison is screwed up. As you suspect, the M4
stuff is supposed to be expanded for you. I'd suggest reinstalling
it from source at http://www.gnu.org/software/bison/ -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.