changeset 16174:39096b290a2f

check syntax used to enable bison push/pull parser * acinclude.m4 (OCTAVE_PROG_BISON): Check for syntax used to enable push/pull parser. * common.mk (BISON_PUSH_PULL_DECL_STYLE): New variable. * libinterp/Makefile.am (BUILT_DISTFILES): Include oct-parse.yy in the list. (EXTRA_DIST): Include oct-pase.in.yy in the list. (ULT_DIST_SRC): New variable. (SRC_DEF_FILES, TST_FILES_SRC): Use $(ULT_DIST_SRC) instead of $(DIST_SRC). * find-defun-files.sh: Transform .in.yy instead of .yy. * libinterp/parse-tree/module.mk (parse-tree/oct-parse.yy): New target and rule to substitute push-pull decl. * oct-parse.in.yy: Rename from oct-parse.yy Substitute %PUSH_PULL_DECL%.
author John W. Eaton <jwe@octave.org>
date Sat, 02 Mar 2013 12:26:42 -0500
parents 40a9a4e0d12a
children 6f83158c714c
files build-aux/common.mk libinterp/Makefile.am libinterp/find-defun-files.sh libinterp/parse-tree/module.mk libinterp/parse-tree/oct-parse.in.yy libinterp/parse-tree/oct-parse.yy m4/acinclude.m4
diffstat 6 files changed, 80 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/build-aux/common.mk
+++ b/build-aux/common.mk
@@ -44,6 +44,7 @@
 
 YACC = @YACC@
 AM_YFLAGS = -dv
+BISON_PUSH_PULL_DECL_STYLE = @BISON_PUSH_PULL_DECL_STYLE@
 
 GPERF = @GPERF@
 
--- a/libinterp/Makefile.am
+++ b/libinterp/Makefile.am
@@ -65,7 +65,8 @@
 
 BUILT_DISTFILES = \
   parse-tree/oct-gperf.h \
-  parse-tree/oct-parse.h
+  parse-tree/oct-parse.h \
+  parse-tree/oct-parse.yy
 
 ## Files that are created during build process and installed,
 ## BUT not distributed in tarball.
@@ -97,6 +98,7 @@
   mkdefs \
   mkops \
   oct-conf.in.h \
+  oct-parse.in.yy \
   version.in.h \
   $(BUILT_DISTFILES)
 
@@ -196,7 +198,11 @@
   $(LIBOCTINTERP_LINK_OPTS)
 
 ## Section for defining and creating DEF_FILES
-SRC_DEF_FILES := $(shell $(srcdir)/find-defun-files.sh "$(srcdir)" $(DIST_SRC))
+
+ULT_DIST_SRC := \
+  $(filter-out parse-tree/oct-parse.yy, $(DIST_SRC)) parse-tree/oct-parse.in.yy
+
+SRC_DEF_FILES := $(shell $(srcdir)/find-defun-files.sh "$(srcdir)" $(ULT_DIST_SRC))
 
 DLDFCN_DEF_FILES = $(DLDFCN_SRC:.cc=.df)
 
@@ -236,7 +242,7 @@
 
 ## Rules to build test files
 
-TST_FILES_SRC := $(shell $(top_srcdir)/build-aux/find-files-with-tests.sh "$(srcdir)" $(DIST_SRC) $(DLDFCN_SRC))
+TST_FILES_SRC := $(shell $(top_srcdir)/build-aux/find-files-with-tests.sh "$(srcdir)" $(ULT_DIST_SRC) $(DLDFCN_SRC))
 
 TST_FILES := $(addsuffix -tst,$(TST_FILES_SRC))
 
--- a/libinterp/find-defun-files.sh
+++ b/libinterp/find-defun-files.sh
@@ -21,6 +21,6 @@
     file="$srcdir/$arg"
   fi
   if [ "`$EGREP -l "$DEFUN_PATTERN" $file`" ]; then
-    echo "$file" | $SED "s,\\$srcdir/,," | $SED 's/\.cc$/.df/; s/\.ll$/.df/; s/\.yy$/.df/';
+    echo "$file" | $SED "s,\\$srcdir/,," | $SED 's/\.cc$/.df/; s/\.ll$/.df/; s/\.in.yy$/.df/';
   fi
 done
--- a/libinterp/parse-tree/module.mk
+++ b/libinterp/parse-tree/module.mk
@@ -92,6 +92,18 @@
 	mv $@-t $@
 	rm -f $@-t1
 
+parse-tree/oct-parse.yy: parse-tree/oct-parse.in.yy
+	case "$(BISON_PUSH_PULL_DECL_STYLE)" in \
+          *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
+	mv $@-t $@
+
 noinst_LTLIBRARIES += parse-tree/libparse-tree.la
 
 parse_tree_libparse_tree_la_SOURCES = $(PARSE_TREE_SRC)
rename from libinterp/parse-tree/oct-parse.yy
rename to libinterp/parse-tree/oct-parse.in.yy
--- a/libinterp/parse-tree/oct-parse.yy
+++ b/libinterp/parse-tree/oct-parse.in.yy
@@ -166,7 +166,7 @@
 // object) relevant global values before and after the nested call.
 
 %define api.pure
-%define api.push-pull both
+%PUSH_PULL_DECL%
 %parse-param { octave_parser *curr_parser }
 %lex-param { void *scanner }
 
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -1405,6 +1405,62 @@
   AC_PROG_YACC
   case "$YACC" in
     bison*)
+    AC_CACHE_CHECK([syntax of bison push/pull declaration],
+                   [octave_cv_bison_push_pull_decl_style], [
+      style="dash underscore"
+      quote="noquote quote"
+      for s in $style; do
+        for q in $quote; do
+          if test $s = "dash"; then
+            def="%define api.push-pull"
+          else
+            def="%define api.push_pull"
+          fi
+          if test $q = "quote"; then
+            def="$def \"both\""
+          else
+            def="$def both"
+          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
+            if test $q = noquote; then
+              q=
+            fi
+            octave_cv_bison_push_pull_decl_style="$s $q"
+            break
+          fi
+        done
+        if test $ac_status -eq 0; then
+          break
+        fi
+      done
+      rm -f conftest.yy y.tab.h
+      ])
+    ;;
+  esac
+
+  AC_SUBST(BISON_PUSH_PULL_DECL_STYLE, $octave_cv_bison_push_pull_decl_style)
+
+  if test -z "$octave_cv_bison_push_pull_decl_style"; then
+    YACC=
+    warn_bison_push_pull_decl_style="
+
+I wasn't able to find a suitable style for declaring a push-pull
+parser in a bison input file so I'm disabling bison.
+"
+    OCTAVE_CONFIGURE_WARNING([warn_bison_push_pull_decl_style])
+  fi
+
+  case "$YACC" in
+    bison*)
     ;;
     *)
       YACC='$(top_srcdir)/build-aux/missing bison'