Subject: Re: bug#19020: flex support

From: Stefano Lattarini <[email-masked]>
Date: Fri, 19 Dec 2014 20:53:55 +0100

retitle 19020 improve support for flex in C++ mode
tags 19020 + moreinfo
thanks

Reference: http://debbugs.gnu.org/19020

On 11/11/2014 11:51 AM, brahim sahbi wrote:
> Hello,
Hi, sorry for the delay.

> I am trying to use flex with these options
> AM_LFLAGS = --header-file=lang.h --yyclass=Lang --c++
> My problem is that the file generated by lex is lex.yy.cc and not lex.yy.c.
> So this command in the generated Makefile:
> .lpp.cpp:
>      $(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@
> -- $(LEXCOMPILE)
>
> turns my lang.lpp to lang.cppc
>
> I have looked in the ylwrap by launching it with $(SHELL) -x and had this
> printed
> ++ printf '%s\n' lex.yy.cc
> ++ sed 's|lex\.yy\.c|lang.cpp|g;'
> + to=lang.cppc
>
> Am I doing it worng or is this a bug?
>
This is sadly a limitation, in that we must assume that the output generated
by lex and flex when a '-o' option is not given is 'yy.lex.c' (this would
not be needed if we could assume the '-o' option works, but that assumption
is not portable enough yet).  The --c++ option of flex seem to break this
expectation of the ylwrap script.  I *think* it can be worked around by
explicitly adding "-o lex.yy.c" to your AM_LFLAGS.  Can you verify that
solves your problem?

Thanks,
   Stefano