[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8844: Flex header files
From: |
Stefano Lattarini |
Subject: |
bug#8844: Flex header files |
Date: |
Sun, 26 Aug 2012 19:31:51 +0200 |
retitle 8844 Flex header files
retitle 9933 Flex header files
close 8844
close 9933
thanks
Replying to two old bug reports:
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8844>
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9933>
===========================================================================
> On Monday 13 June 2011, Pippijn van Steenhoven wrote:
>
>> Hi,
>>
>> in some of my projects, I use (reentrant) flex with the header-file
>> option. This causes flex to generate a .h file in addition to the usual
>> lex.yy.c file. However, ylwrap doesn't know about this. What would be the
>> correct way to use flex with header files?
>>
> I see two ways out, not mutually exclusive:
>
> 1. Introduce a new automake option `no-ylwrap', instructing automake not
> to use ylwrap to process Yacc and Lex files; this should assume that
> bison and flex can be used, so that we know no problem with concurrent
> make will arise (we can use the `--output' option for both tools).
> Then you can manually add some rules about the header on your
> Makefile.am, without ylwrap getting in your way.
>
> 2. Improve ylwrap and automake Lex support to recognize the `--header'
> Lex option, similarly to what is done for the `-d' Yacc option, and
> emit code handling the header creation, dependencies, etc.
>
> Regards,
> Stefano
>
==========================================================================
On Tuesday 01 November 2011, Bruce Korb wrote:
>
> The bison accepts the option, --header-file=whatever.h
> "ylwrap" is a wrapper script meant to canonicalize the invocation
> of yacc and bison. True enough, if you use --header-file you
> had better be using bison, but here is the problem:
>
> I am working on a project that will only build in a GNU tools environment.
> Therefore, I know that the .l -> .c transformation tool is flex, not
> POSIX lex. The code I am working with presumes that it can use this:
> AM_LFLAGS = @LEX_FL@ --header-file=$(LEX_HEADER) -DYY_NO_INPUT=1
> So ylwrap fires off the flex program and it runs just fine, the tiny
> problem is that it also removes the temporary directory before I can
> salvage the generated header. This is inconvenient.
>
==========================================================================
These issues have been fixed thanks to the recent work done by Akim Demaille
on ylwrap. I've checking in the test case below to ensure we won't regress
on this use case. And I'm finally closing these bug reports.
Thanks,
Stefano
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
>From 9557b2f89263c8ffe00106430fca8758f6118438 Mon Sep 17 00:00:00 2001
Message-Id: <address@hidden>
From: Stefano Lattarini <address@hidden>
Date: Sun, 26 Aug 2012 19:25:02 +0200
Subject: [PATCH] coverage: bugs #8844 and #9933 (already fixed by Akim's work
on ylwrap)
* t/flex-header.sh: New test, show that automake bug#8844 and have already
been fixed by the recent-ish improvements to ylwrap (merged with commit
v1.12.2-27-gec5cb49 of 2012-07-16, "Merge branch 'yacc-work' into maint").
* t/list-of-tests.mk: Update.
Signed-off-by: Stefano Lattarini <address@hidden>
---
t/lex-header.sh | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
t/list-of-tests.mk | 1 +
2 files changed, 86 insertions(+)
create mode 100755 t/lex-header.sh
diff --git a/t/lex-header.sh b/t/lex-header.sh
new file mode 100755
index 0000000..06c8561
--- /dev/null
+++ b/t/lex-header.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Automake lex support can work with flex '--header' option (see
+# bugs #8844 and #9933).
+
+required='cc flex'
+. ./defs || exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = lexer.l main.c mylex.h
+foo_LFLAGS = --header-file=mylex.h
+BUILT_SOURCES = mylex.h
+# Recover from removal of header.
+mylex.h: foo-lexer.c
+ test -f $@ || rm -f foo-lexer.c
+ test -f $@ || $(MAKE) $(AM_MAKEFLAGS) foo-lexer.c
+END
+
+cat > lexer.l << 'END'
+%option noyywrap
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"GOOD" return EOF;
+.
+%%
+END
+
+cat > main.c <<'END'
+#include "mylex.h"
+int main (void)
+{
+ /* We don't use a 'while' loop here (like a real lexer would do)
+ to avoid possible hangs. */
+ if (yylex () == EOF)
+ return 0;
+ else
+ return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# Program should build and run.
+$MAKE
+if ! cross_compiling; then
+ echo GOOD | ./foo
+ echo BAD | ./foo && exit 1
+ : For shells with busted 'set -e'.
+fi
+
+# Recovering from header removal.
+rm -f mylexer.h
+$MAKE
+
+# Sanity check on distribution.
+yl_distcheck
+
+:
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index f72a6fa..ff4448e 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -566,6 +566,7 @@ t/lex5.sh \
t/lexcpp.sh \
t/lexvpath.sh \
t/lex-subobj-nodep.sh \
+t/lex-header.sh \
t/lex-lib.sh \
t/lex-lib-external.sh \
t/lex-libobj.sh \
--
1.7.12
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#8844: Flex header files,
Stefano Lattarini <=