help-bison
[Top][All Lists]
Advanced

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

Re: bison push parser, and autoconf


From: David Fang
Subject: Re: bison push parser, and autoconf
Date: Fri, 28 Mar 2008 20:35:07 -0400 (EDT)

I have a small problem. I want to make a release of cgdb soon, and I
realized that I currently build my parser with the push parser
interface. For now, I can disable building the parser, since it isn't
in use yet.

However, in the near future, after the bison release, I might finally
start using this parser. So, I currently use AC_PROG_YACC in my
configure.init. I'm realizing that is not longer good enough.

I need something that will check for bison, and will check for the
version of bison, or for the push parser feature. Does anyone have any
suggestions for me?

I think it would be nice if we made this available to the autoconf
people, because, others are going to need this.

What I do in my autoconf tests for yacc/bison is first determine whether the found program is actually yacc or bison (bison -y often pretends to be yacc). I'll paste some relevant snippets here:

My test program is :
cat > conftest.y <<ACEOF
%token  FIRST_TOK
%token  LAST_TOK
%start top
%%
top: FIRST_TOK LAST_TOK
%%
ACEOF

# set up some common variables for testing:
ac_cv_prog_yacc_root="y.tab"
ac_compile_yacc='$CC -c $CFLAGS $CPPFLAGS $ac_cv_prog_yacc_root.c >&5'

# works for both yacc and all versions of bison I've tested
if $YACC -d -t -v conftest.y && eval "$ac_compile_yacc"
then
        # make sure y.tab.{h,c} exist, default behavior of yacc, bison -y
fi

I then define some AM_CONDITIONALS and AC_DEFINES based on:
grep YYBISON y.tab.c
grep YYBYACC y.tab.c

(Sounds like you require bison...)

The above conftest.y template can be tweaked to test for %directive support, such as %pure_parser, %destructor, %glr... This is where I test for some bison features that appear in different versions.

I extract version numbers from either $YACC --version (if YACC is bison)
or grep for the yacc skeleton version number in y.tab.c if YACC is yacc.
(I only use version numbers for reporting, not to assume anything about known features in versions.)

I haven't made my macros into a nice set yet, as they are somewhat specific to my own project uses, hacked up everytime I think of a new test, and not necessarily something everyone generally wants.


David Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
http://www.csl.cornell.edu/~fang/
        -- (2400 baud? Netscape 3.0?? lynx??? No problem!)




reply via email to

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