From 718147147b832f5b5beebda9007b221d622d6bc4 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 28 Aug 2013 12:33:02 +0100 Subject: Make tikzparser.ym compatible with bison 2.3 --- tikzit/INSTALL | 2 +- tikzit/src/Makefile.am | 6 ++--- tikzit/src/common/TikzGraphAssembler.m | 1 + tikzit/src/common/tikzlexer.lm | 1 + tikzit/src/common/tikzparser.ym | 25 +++++-------------- tikzit/src/common/tikzparserdefs.h | 44 ++++++++++++++++++++++++++++++++++ 6 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 tikzit/src/common/tikzparserdefs.h (limited to 'tikzit') diff --git a/tikzit/INSTALL b/tikzit/INSTALL index 9576d37..b938f14 100644 --- a/tikzit/INSTALL +++ b/tikzit/INSTALL @@ -23,7 +23,7 @@ To install, just run: To build from subversion (and for development) you will additionally need: flex >= 2.5.34 - bison >= 2.4 + bison >= 2.3 autoconf >= 2.60 automake >= 1.10 diff --git a/tikzit/src/Makefile.am b/tikzit/src/Makefile.am index c679afa..2f9ac95 100644 --- a/tikzit/src/Makefile.am +++ b/tikzit/src/Makefile.am @@ -14,7 +14,7 @@ AM_OBJCFLAGS = @FOUNDATION_OBJCFLAGS@ \ LIBS = @FOUNDATION_LIBS@ \ @GTK_LIBS@ AM_YFLAGS = -d -PARSERFILES = common/tikzlexer.m common/tikzparser.m common/tikzparser.h +PARSERFILES = common/tikzlexer.m common/tikzlexer.h common/tikzparser.m common/tikzparser.h ICONFILES = ../draw-ellipse.png \ ../draw-path.png \ ../select-rectangular.png \ @@ -126,10 +126,10 @@ endif common/tikzlexer.m: common/tikzlexer.lm $(AM_V_GEN)$(LEX) -o $@ $^ +common/tikzlexer.h: common/tikzlexer.m common/tikzparser.m: common/tikzparser.ym - $(AM_V_GEN)$(YACC) --output=$@ $^ - + $(AM_V_GEN)$(YACC) --defines=common/tikzparser.h --output-file=$@ $^ common/tikzparser.h: common/tikzparser.m gtk/icondata.m: $(ICONFILES) diff --git a/tikzit/src/common/TikzGraphAssembler.m b/tikzit/src/common/TikzGraphAssembler.m index 60b96ee..380b71c 100644 --- a/tikzit/src/common/TikzGraphAssembler.m +++ b/tikzit/src/common/TikzGraphAssembler.m @@ -22,6 +22,7 @@ // #import "TikzGraphAssembler.h" +#import "tikzparserdefs.h" #import "tikzparser.h" #import "TikzGraphAssembler+Parser.h" #import "tikzlexer.h" diff --git a/tikzit/src/common/tikzlexer.lm b/tikzit/src/common/tikzlexer.lm index fe7ab0d..96690d2 100644 --- a/tikzit/src/common/tikzlexer.lm +++ b/tikzit/src/common/tikzlexer.lm @@ -20,6 +20,7 @@ */ #import +#import "tikzparserdefs.h" #import "tikzparser.h" #define YY_USER_ACTION \ diff --git a/tikzit/src/common/tikzparser.ym b/tikzit/src/common/tikzparser.ym index bf33aa9..a6dc1ee 100644 --- a/tikzit/src/common/tikzparser.ym +++ b/tikzit/src/common/tikzparser.ym @@ -18,16 +18,18 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +#import "tikzparserdefs.h" %} /* we use features added to bison 2.4 */ -%require "2.4" +%require "2.3" %error-verbose /* enable maintaining locations for better error messages */ %locations /* the name of the header file */ -%defines "common/tikzparser.h" +/*%defines "common/tikzparser.h"*/ /* make it re-entrant (no global variables) */ %pure-parser /* We use a pure (re-entrant) lexer. This means yylex @@ -37,21 +39,6 @@ that lexer state as an argument */ %parse-param {void *scanner} -/* things required to use the parser (will go in the header); - in particular, declarations/imports for types in the %union - must go here */ -%code requires { -#import -@class TikzGraphAssembler; -@class GraphElementData; -@class GraphElementProperty; -@class Node; -struct noderef { - Node *node; - NSString *anchor; -}; -} - /* possible data types for semantic values */ %union { NSPoint pt; @@ -62,7 +49,7 @@ struct noderef { struct noderef noderef; } -%code { +%{ #import "GraphElementData.h" #import "GraphElementProperty.h" #import "Node.h" @@ -78,7 +65,7 @@ struct noderef { void yyerror(YYLTYPE *yylloc, void *scanner, const char *str) { [assembler reportError:str atLocation:yylloc]; } -} +%} /* yyloc is set up with first_column = last_column = 1 by default; however, it makes more sense to think of us being "before the diff --git a/tikzit/src/common/tikzparserdefs.h b/tikzit/src/common/tikzparserdefs.h new file mode 100644 index 0000000..587bcd6 --- /dev/null +++ b/tikzit/src/common/tikzparserdefs.h @@ -0,0 +1,44 @@ +/* + * Copyright 2013 Alex Merry + * + * 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 of + * the License, 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 . + */ + +/* + * This file sets up some defs (particularly struct noderef) needed for + * the tikz parser and its users. + * + * It is needed because we wish to support bison 2.3, which is the + * version shipped with OSX. bison 2.4 onwards allows us to put this + * stuff in a "%code requires" block, where it will be put in the + * generated header file by bison. + * + * All the types used by the %union directive in tikzparser.ym should + * be declared, defined or imported here. + */ + +// Foundation has NSPoint and NSString +#import + +@class TikzGraphAssembler; +@class GraphElementData; +@class GraphElementProperty; +@class Node; + +struct noderef { + Node *node; + NSString *anchor; +}; + +// vi:ft=objc:noet:ts=4:sts=4:sw=4 -- cgit v1.2.3