[Top][All Lists]

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

Re: Problems with linking multiple lex/yacc parsers into one executable

From: Lorenzo Bettini
Subject: Re: Problems with linking multiple lex/yacc parsers into one executable
Date: Sun, 17 May 2009 09:09:52 +0200
User-agent: Thunderbird (X11/20090409)

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 (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: $(srcdir)/langdefscanner.ll
        $(LEX) $(LFLAGS) -o $@ $(srcdir)/langdefscanner.ll $(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)

reply via email to

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