# HG changeset patch # User John W. Eaton # Date 1406894942 14400 # Node ID d8abf813c69f0364923f560e86fa56bfc1284f2d # Parent 625e3bb65885db18b1821b8b6c2c0e46409b3c05 handle changes in bison 3.x * acinclude.m4 (OCTAVE_PROG_BISON): Also check for the proper way to declare api.prefix. * build-aux/common.mk (BISON_API_PREFIX_DECL_STYLE): New variable. * lex.ll: Conditionally define YYSTYPE. * oct-parse.in.yy (%API_PREFIX_DECL%): Allow for differences in the way api.prefix is specified in different versions of bison. * libinterp/parse-tree/module.mk (parse-tree/oct-parse.yy): Also substitute %API_PREFIX_DECL% in lex.ll. diff -r 625e3bb65885 -r d8abf813c69f build-aux/common.mk --- a/build-aux/common.mk Tue Jul 01 15:56:00 2014 -0400 +++ b/build-aux/common.mk Fri Aug 01 08:09:02 2014 -0400 @@ -46,6 +46,7 @@ YACC = @YACC@ AM_YFLAGS = -dv +BISON_API_PREFIX_DECL_STYLE = @BISON_API_PREFIX_DECL_STYLE@ BISON_PUSH_PULL_DECL_STYLE = @BISON_PUSH_PULL_DECL_STYLE@ GPERF = @GPERF@ diff -r 625e3bb65885 -r d8abf813c69f libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Tue Jul 01 15:56:00 2014 -0400 +++ b/libinterp/parse-tree/lex.ll Fri Aug 01 08:09:02 2014 -0400 @@ -96,6 +96,17 @@ #include #include +// FIXME: with bison 3.x, OCTAVE_STYPE appears in the generated +// oct-parse.h file, but there is no definition for YYSTYPE, which is +// needed by the code that is generated by flex. I can't seem to find a +// way to tell flex to use OCTAVE_STYPE instead of YYSTYPE in the code +// it generates, or to tell bison to provide the definition of YYSTYPE +// in the generated oct-parse.h file. + +#if defined (OCTAVE_STYPE_IS_DECLARED) && ! defined YYSTYPE +#define YYSTYPE OCTAVE_STYPE +#endif + #if defined (GNULIB_NAMESPACE) // Calls to the following functions appear in the generated output from // flex without the namespace tag. Redefine them so we will use them diff -r 625e3bb65885 -r d8abf813c69f libinterp/parse-tree/module.mk --- a/libinterp/parse-tree/module.mk Tue Jul 01 15:56:00 2014 -0400 +++ b/libinterp/parse-tree/module.mk Fri Aug 01 08:09:02 2014 -0400 @@ -86,15 +86,20 @@ rm -f $@-t1 parse-tree/oct-parse.yy: parse-tree/oct-parse.in.yy + case "$(BISON_API_PREFIX_DECL_STYLE)" in \ + *api*) api_prefix_decl='%define api.prefix "octave-"'; ;; \ + *name*) api_prefix_decl='%name-prefix="octave_"'; ;; \ + esac; \ case "$(BISON_PUSH_PULL_DECL_STYLE)" in \ - *quote*) quote='"' ;; \ + *quote*) quote='"' ;; \ *) quote="" ;; \ - esac; \ - case "$(BISON_PUSH_PULL_DECL_STYLE)" in \ - *dash*) decl="%define api.push-pull $${quote}both$${quote}"; ;; \ - *underscore*) decl="%define api.push_pull $${quote}both$${quote}"; ;; \ - esac; \ - $(SED) "s/%PUSH_PULL_DECL%/$$decl/" $< > $@-t + esac; \ + case "$(BISON_PUSH_PULL_DECL_STYLE)" in \ + *dash*) push_pull_decl="%define api.push-pull $${quote}both$${quote}"; ;; \ + *underscore*) push_pull_decl="%define api.push_pull $${quote}both$${quote}"; ;; \ + esac; \ + $(SED) -e "s/%PUSH_PULL_DECL%/$$push_pull_decl/" \ + -e "s/%API_PREFIX_DECL%/$$api_prefix_decl/" $< > $@-t mv $@-t $@ noinst_LTLIBRARIES += \ diff -r 625e3bb65885 -r d8abf813c69f libinterp/parse-tree/oct-parse.in.yy --- a/libinterp/parse-tree/oct-parse.in.yy Tue Jul 01 15:56:00 2014 -0400 +++ b/libinterp/parse-tree/oct-parse.in.yy Fri Aug 01 08:09:02 2014 -0400 @@ -129,10 +129,7 @@ %expect 14 -// Don't add spaces around the = here; it causes some versions of -// bison to fail to properly recognize the directive. - -%name-prefix="octave_" +%API_PREFIX_DECL% // We are using the pure parser interface and the reentrant lexer // interface but the Octave parser and lexer are NOT properly diff -r 625e3bb65885 -r d8abf813c69f m4/acinclude.m4 --- a/m4/acinclude.m4 Tue Jul 01 15:56:00 2014 -0400 +++ b/m4/acinclude.m4 Fri Aug 01 08:09:02 2014 -0400 @@ -1762,6 +1762,49 @@ esac if test $tmp_have_bison = yes; then + AC_CACHE_CHECK([syntax of bison api.prefix (or name-prefix) declaration], + [octave_cv_bison_api_prefix_decl_style], [ + style="api name" + for s in $style; do + if test $s = "api"; then + def='%define api.prefix "foo_"' + else + def='%name-prefix="foo_"' + fi + cat << EOF > conftest.yy +$def +%start input +%% +input:; +%% +EOF + $YACC conftest.yy > /dev/null 2>&1 + ac_status=$? + if test $ac_status -eq 0; then + octave_cv_bison_api_prefix_decl_style="$s" + break + fi + if test $ac_status -eq 0; then + break + fi + done + rm -f conftest.yy y.tab.h y.tab.c + ]) + fi + + AC_SUBST(BISON_API_PREFIX_DECL_STYLE, $octave_cv_bison_api_prefix_decl_style) + + if test -z "$octave_cv_bison_api_prefix_decl_style"; then + YACC= + warn_bison_api_prefix_decl_style=" + +I wasn't able to find a suitable style for declaring the api prefix +in a bison input file so I'm disabling bison. +" + OCTAVE_CONFIGURE_WARNING([warn_bison_api_prefix_decl_style]) + fi + + if test $tmp_have_bison = yes; then AC_CACHE_CHECK([syntax of bison push/pull declaration], [octave_cv_bison_push_pull_decl_style], [ style="dash underscore"