diff options
author | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-01-09 11:00:06 +0000 |
---|---|---|
committer | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-01-09 11:00:06 +0000 |
commit | e1cf0babff63e670e0d550b4072c22649a117fa7 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src/common/tikzparser.ym | |
parent | 49393f6f445deb37e55a81798f88242e3e99d7a0 (diff) |
Re-make trunk
git-svn-id: https://tikzit.svn.sourceforge.net/svnroot/tikzit/trunk@364 7c02a99a-9b00-45e3-bf44-6f3dd7fddb64
Diffstat (limited to 'src/common/tikzparser.ym')
-rw-r--r-- | src/common/tikzparser.ym | 178 |
1 files changed, 0 insertions, 178 deletions
diff --git a/src/common/tikzparser.ym b/src/common/tikzparser.ym deleted file mode 100644 index e55a881..0000000 --- a/src/common/tikzparser.ym +++ /dev/null @@ -1,178 +0,0 @@ -%expect 6 - -%{ -// -// tikzparser.y -// TikZiT -// -// Copyright 2010 Chris Heunen. All rights reserved. -// -// -// This file is part of TikZiT. -// -// TikZiT 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 3 of the License, or -// (at your option) any later version. -// -// TikZiT 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 TikZiT. If not, see <http://www.gnu.org/licenses/>. -// -#include <stdio.h> -#include <string.h> -#import <Foundation/Foundation.h> -#import "TikzGraphAssembler.h" -#import "GraphElementProperty.h" - -extern int yylex(void); -extern void yyerror(const char *str); - -%} - -%union { - NSPoint pt; - NSString *nsstr; -}; - -%token LATEXBEGIN -%token LATEXEND -%token TIKZPICTURE -%token PGFONLAYER -%token ANCHORCENTER -%token LEFTPARENTHESIS -%token RIGHTPARENTHESIS -%token LEFTBRACKET -%token RIGHTBRACKET -%token SEMICOLON -%token COMMA -%token EQUALS -%token DRAW -%token TO -%token NODE -%token RECTANGLE -%token PATH -%token ALTNODE -%token AT -%token REALNUMBER -%token NATURALNUMBER -%token LWORD -%token QUOTEDSTRING -%token DELIMITEDSTRING - -%type<nsstr> nodename -%type<nsstr> nodeid -%type<pt> coords -%type<nsstr> target -%type<nsstr> propsym -%type<nsstr> propsyms -%type<nsstr> val -%type<nsstr> number - -%% - -tikzpicture: LATEXBEGIN TIKZPICTURE optproperties expressions LATEXEND TIKZPICTURE; -expressions: expressions expression | ; -expression: node | edge | boundingbox | ignore; - -ignore: LATEXBEGIN PGFONLAYER DELIMITEDSTRING | LATEXEND PGFONLAYER; - -number: REALNUMBER { $$ = $<nsstr>1; } | NATURALNUMBER { $$ = $<nsstr>1; }; - -optproperties: LEFTBRACKET properties RIGHTBRACKET | ; -properties: property extraproperties; -extraproperties: COMMA property extraproperties | property extraproperties | ; - -property: - propsyms EQUALS val - { - TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler]; - GraphElementProperty *p = [[GraphElementProperty alloc] initWithPropertyValue:$<nsstr>3 forKey:$<nsstr>1]; - [[a data] addObject:p]; - [p release]; - } - | propsyms - { - TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler]; - GraphElementProperty *p = [[GraphElementProperty alloc] initWithAtomName:$<nsstr>1]; - [[a data] addObject:p]; - [p release]; - }; - -val: propsyms { $$ = $<nsstr>1; } | QUOTEDSTRING { $$ = $<nsstr>1; }; -propsyms: - propsym { $$ = $<nsstr>1; } - | propsyms propsym - { - NSString *s = [$<nsstr>1 stringByAppendingFormat:@" %@", $<nsstr>2]; - $$ = s; - }; - -propsym: - LWORD { $$ = $<nsstr>1; } - | number { $$ = $<nsstr>1; }; - - -nodecmd : NODE { [[TikzGraphAssembler currentAssembler] prepareNode]; }; - -node: - nodecmd optproperties nodename AT coords nodelabel SEMICOLON - { - TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler]; - [[a currentNode] setName:$<nsstr>3]; - [[a currentNode] setPoint:$<pt>5]; - [a finishNode]; - }; - -nodelabel: - DELIMITEDSTRING - { - Node *n = [[TikzGraphAssembler currentAssembler] currentNode]; - NSString *label = $<nsstr>1; - [n setLabel:[label substringWithRange:NSMakeRange(1, [label length]-2)]]; - } - -optanchor: | ANCHORCENTER; -nodename: LEFTPARENTHESIS nodeid optanchor RIGHTPARENTHESIS { $$ = $<nsstr>2; }; -nodeid: LWORD { $$ = $<nsstr>1; } | NATURALNUMBER { $$ = $<nsstr>1; }; - -coords: - LEFTPARENTHESIS number COMMA number RIGHTPARENTHESIS - { - $$ = NSMakePoint([$<nsstr>2 floatValue], [$<nsstr>4 floatValue]); - }; - -edgecmd : DRAW { [[TikzGraphAssembler currentAssembler] prepareEdge]; }; -edge: - edgecmd optproperties nodename TO optedgenode target SEMICOLON - { - TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler]; - [a setEdgeSource:$<nsstr>3 - target:$<nsstr>6]; - [a finishEdge]; - }; -target: nodename { $$=$<nsstr>1; } | selfloop { $$=@""; }; -selfloop: LEFTPARENTHESIS RIGHTPARENTHESIS; - -altnodecmd: ALTNODE { [[TikzGraphAssembler currentAssembler] prepareNode]; }; -optedgenode: - | altnodecmd optproperties nodelabel - { - [[TikzGraphAssembler currentAssembler] finishNode]; - } - -bbox_ignoreprops: - | LEFTBRACKET LWORD LWORD LWORD LWORD RIGHTBRACKET; - -boundingbox: - PATH bbox_ignoreprops coords RECTANGLE coords SEMICOLON - { - Graph *g = [[TikzGraphAssembler currentAssembler] graph]; - [g setBoundingBox:NSRectAroundPoints($<pt>3, $<pt>5)]; - }; - -%% |