changeset 19980:a941a65c7cb8

handle bison syntax changes in TeX parser * oct-tex-parser.in.yy: Rename from oct-tex-parser.yy. Substitute %API_PREFIX_DECL%. * build-aux/common.mk (subst-bison-api-decls): New macro. * libinterp/parse-tree/module.mk (oct-parse.yy): Use it. * libinterp/corefcn/module.mk (oct-tex-parser.yy): New rule. * libinterp/Makefile.am: Ensure that oct-tex-parser.yy is built early. Search for tests in generated .yy file, not .in.yy file. * oct-tex-lexer.in.ll: Define YYSTPE if needed.
author John W. Eaton <jwe@octave.org>
date Thu, 19 Feb 2015 18:05:07 -0500
parents 904912f18357
children 4cecd33915ef
files build-aux/common.mk libinterp/Makefile.am libinterp/corefcn/module.mk libinterp/corefcn/oct-tex-lexer.in.ll libinterp/corefcn/oct-tex-parser.in.yy libinterp/corefcn/oct-tex-parser.yy libinterp/parse-tree/module.mk
diffstat 6 files changed, 62 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/build-aux/common.mk
+++ b/build-aux/common.mk
@@ -729,6 +729,38 @@
 $(simple_move_if_change_rule)
 endef
 
+define subst-bison-api-decls
+  case "$(BISON_API_PREFIX_DECL_STYLE)" in \
+    *api*) \
+      case "$(BISON_API_PREFIX_DECL_STYLE)" in \
+       *brace*) \
+         api_prefix_decl='%define api.prefix {$(1)}'; ;; \
+       *) \
+         api_prefix_decl='%define api.prefix "$(1)"'; ;; \
+       esac; \
+      ;; \
+    *name*) \
+      case "$(BISON_API_PREFIX_DECL_STYLE)" in \
+        *brace*) \
+          api_prefix_decl='%name-prefix {$(1)}'; ;; \
+        *) \
+          api_prefix_decl='%name-prefix="$(1)"'; ;; \
+      esac; \
+    ;; \
+  esac; \
+  case "$(BISON_PUSH_PULL_DECL_STYLE)" in \
+    *quote*) quote='"' ;; \
+    *) quote="" ;; \
+  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 $@
+endef
+
 define test-file-commands
 ( echo "## DO NOT EDIT!  Generated automatically from $(<F) by Make."; $(GREP) '^%!' $< ) > $@-t
 mv $@-t $@
--- a/libinterp/Makefile.am
+++ b/libinterp/Makefile.am
@@ -63,13 +63,22 @@
   builtin-defun-decls.h \
   builtins.cc
 
+ULT_PARSER_SRC := \
+  corefcn/oct-tex-lexer.in.ll \
+  corefcn/oct-tex-parser.in.yy \
+  parse-tree/oct-parse.in.yy
+
+GENERATED_PARSER_FILES := \
+  corefcn/oct-tex-lexer.ll \
+  corefcn/oct-tex-parser.yy \
+  parse-tree/oct-parse.yy
+
 BUILT_DISTFILES = \
-  corefcn/oct-tex-lexer.ll \
+  $(GENERATED_PARSER_FILES) \
   corefcn/oct-tex-parser.h \
   corefcn/oct-tex-symbols.cc \
   parse-tree/oct-gperf.h \
-  parse-tree/oct-parse.h \
-  parse-tree/oct-parse.yy
+  parse-tree/oct-parse.h
 
 ## Files that are created during build process and installed,
 ## BUT not distributed in tarball.
@@ -203,7 +212,7 @@
 ## Section for defining and creating DEF_FILES
 
 ULT_DIST_SRC := \
-  $(filter-out corefcn/oct-tex-lexer.ll parse-tree/oct-parse.yy, $(DIST_SRC)) corefcn/oct-tex-lexer.in.ll parse-tree/oct-parse.in.yy
+  $(filter-out $(GENERATED_PARSER_FILES), $(DIST_SRC)) $(ULT_PARSER_SRC)
 
 SRC_DEF_FILES := $(shell $(srcdir)/find-defun-files.sh "$(srcdir)" $(ULT_DIST_SRC))
 
--- a/libinterp/corefcn/module.mk
+++ b/libinterp/corefcn/module.mk
@@ -5,6 +5,7 @@
   corefcn/mxarray.in.h \
   corefcn/oct-errno.in.cc \
   corefcn/oct-tex-lexer.in.ll \
+  corefcn/oct-tex-parser.in.yy \
   corefcn/oct-tex-symbols.in
 
 ## Options functions for Fortran packages like LSODE, DASPK.
@@ -330,6 +331,8 @@
 corefcn/oct-tex-lexer.cc: LEX_OUTPUT_ROOT := lex.octave_tex_
 corefcn/oct-tex-parser.h: corefcn/oct-tex-parser.yy
 
+corefcn/oct-tex-parser.yy: corefcn/oct-tex-parser.in.yy
+	$(call subst-bison-api-decls,octave_tex_)
 
 noinst_LTLIBRARIES += \
   corefcn/libcorefcn.la \
--- a/libinterp/corefcn/oct-tex-lexer.in.ll
+++ b/libinterp/corefcn/oct-tex-lexer.in.ll
@@ -47,6 +47,17 @@
 #include "txt-eng.h"
 #include "oct-tex-parser.h"
 
+// FIXME: with bison 3.x, OCTAVE_TEX_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_TEX_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_TEX_STYPE_IS_DECLARED) && ! defined YYSTYPE
+#define YYSTYPE OCTAVE_TEX_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
rename from libinterp/corefcn/oct-tex-parser.yy
rename to libinterp/corefcn/oct-tex-parser.in.yy
--- a/libinterp/corefcn/oct-tex-parser.yy
+++ b/libinterp/corefcn/oct-tex-parser.in.yy
@@ -45,7 +45,8 @@
 #define scanner parser.get_scanner ()
 %}
 
-%name-prefix="octave_tex_"
+%API_PREFIX_DECL%
+
 %define api.pure
 %parse-param { text_parser_tex& parser }
 %lex-param { void *scanner }
--- a/libinterp/parse-tree/module.mk
+++ b/libinterp/parse-tree/module.mk
@@ -90,35 +90,7 @@
 	rm -f $@-t1
 
 parse-tree/oct-parse.yy: parse-tree/oct-parse.in.yy
-	case "$(BISON_API_PREFIX_DECL_STYLE)" in \
-	  *api*) \
-	    case "$(BISON_API_PREFIX_DECL_STYLE)" in \
-	     *brace*) \
-	       api_prefix_decl='%define api.prefix {octave_}'; ;; \
-	     *) \
-	       api_prefix_decl='%define api.prefix "octave_"'; ;; \
-             esac; \
-            ;; \
-	  *name*) \
-	    case "$(BISON_API_PREFIX_DECL_STYLE)" in \
-	      *brace*) \
-	        api_prefix_decl='%name-prefix {octave_}'; ;; \
-	      *) \
-	        api_prefix_decl='%name-prefix="octave_"'; ;; \
-            esac; \
-          ;; \
-	esac; \
-	case "$(BISON_PUSH_PULL_DECL_STYLE)" in \
-	  *quote*) quote='"' ;; \
-	  *) quote="" ;; \
-	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 $@
+	$(call subst-bison-api-decls,octave_)
 
 noinst_LTLIBRARIES += \
   parse-tree/libparse-tree.la \