Hans Nieser wrote:
On Sat, 2009-05-16 at 23:06 +0200, Hans Nieser wrote:
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.

<...>

I did some more googling and it turns out that although there is an
option that I can specify in the lex file itself to use a different
prefix for symbols [1], it will actually affect the output filename as
well which seems to break the ylwrap script (it fails silently, but I am
guessing it's because of the different filename).

Another complication of compiling the lex C source directly is that I'd
also need to make yacc produce the header file and include it in the lex
source, which I guess means I have to add some explicit dependencies in
my Makefile.am (actually I'm not sure how that works at all since ylwrap
is called in a subdirectory?.. hmm)

I've now just resorted to the following, I'm not sure if it's the best
way to go but it seems to work and is hopefully still portable:

bin_PROGRAMS = foo

foo_sources = foo.c parser1_yacc.y


parser1_yacc.c: parser1_lex.c

parser1_lex.c: parser1_lex.l
        $(LEX) -o parser1_lex.c parser1_lex.l


I'm not really sure if I can mix and match explicit make rules like
this, hopefully someone can tell me if there's anything terribly wrong
with doing it this way :)

I do like this, but I don't know whether this is the best way to do it:

langdefscanner.cc: $(srcdir)/langdefscanner.ll
        $(LEX) $(LFLAGS) -o $@ $(srcdir)/langdefscanner.ll

langdefparser.cc: $(srcdir)/langdefparser.yy
        $(YACC) -p langdef_ -o $@ $(srcdir)/langdefparser.yy --defines=$*.h


and in the .ll I'm using the prefix option

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net



Reply via email to