automake
[Top][All Lists]
Advanced

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

Problems with linking multiple lex/yacc parsers into one executable


From: Hans Nieser
Subject: Problems with linking multiple lex/yacc parsers into one executable
Date: Sat, 16 May 2009 23:06:57 +0200

Hi list,

I recently started using lex/yacc and I'm having some trouble figuring
out how to make it possible to link two parsers into the same executable
using automake.

For this to work without depending on a non-portable command-line flag
of flex (for specifying a symbol prefix for the generated code, so that
the symbols in the two parsers don't clash) I needed to #define all the
symbols that yacc emits manually, as suggested on
http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/Yacc-and-Lex.html
 .
(Actually, I had to add a bunch more #define's for some symbols
flex/bison emitted that weren't listed there)

I could only make *that* work however by including the C source that lex
generates in the yacc source directly (as opposed to compiling both into
objects seperately and then linking them), because lex emits some
symbols already before emitting the user code section (which would've
contained my #defines). This seems to be what gdb is doing as well.

The above solution worked pretty well with my handcrafted Makefile that
I used for testing, but now I want to make this work in my project that
uses automake and I kind of got stuck.. If I put something like the
following in my Makefile.am:


bin_PROGRAMS = foo

foo_SOURCES = foo.c parser1_lex.l parser1_yacc.y ...


.. then (as expected) automake will attempt to not only generate the lex
C source code (parser1_lex.c) but also compile it which in my particular
case shouldn't be done as I only need to include it in the yacc source.

I've skimmed through the automake documentation but I can't figure out
how to make it work so it will skip actually compiling the lex-generated
source. Me being a complete automake newbie isn't helping either :/

Can anyone tell me how I should best go about solving this? Should I
just depend on flex (I'm not really sure if flex is ubiquitous enough
for that to be a reasonable solution) and pass it different --prefix
flags for different .l files somehow?





reply via email to

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