From 702a3875c5c7c5c937e55d50039ccb0c7bced754 Mon Sep 17 00:00:00 2001 From: Johan Paulsson Date: Thu, 24 Jan 2013 16:30:02 +0000 Subject: Anchor support for the parser and osx gui --- tikzit/src/common/tikzparser.ym | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'tikzit/src/common/tikzparser.ym') diff --git a/tikzit/src/common/tikzparser.ym b/tikzit/src/common/tikzparser.ym index 57f0600..532b6c8 100644 --- a/tikzit/src/common/tikzparser.ym +++ b/tikzit/src/common/tikzparser.ym @@ -39,17 +39,19 @@ extern void yyerror(const char *str); NSString *nsstr; }; +%error-verbose + %token LATEXBEGIN %token LATEXEND %token TIKZPICTURE %token PGFONLAYER -%token ANCHORCENTER %token LEFTPARENTHESIS %token RIGHTPARENTHESIS %token LEFTBRACKET %token RIGHTBRACKET %token SEMICOLON %token COMMA +%token FULLSTOP %token EQUALS %token DRAW %token TO @@ -65,9 +67,10 @@ extern void yyerror(const char *str); %token DELIMITEDSTRING %type nodename +%type anchor +%type optanchor %type nodeid %type coords -%type target %type propsym %type propsyms %type val @@ -119,6 +122,8 @@ propsym: nodecmd : NODE { [[TikzGraphAssembler currentAssembler] prepareNode]; }; +nodename: LEFTPARENTHESIS nodeid RIGHTPARENTHESIS { $$ = $2; }; + node: nodecmd optproperties nodename AT coords nodelabel SEMICOLON { @@ -135,8 +140,17 @@ nodelabel: [n setLabel:$1]; } -optanchor: | ANCHORCENTER; -nodename: LEFTPARENTHESIS nodeid optanchor RIGHTPARENTHESIS { $$ = $2; }; +anchor: LWORD { $$ = $1; } | NATURALNUMBER { $$ = $1; }; + +optanchor: { $$ = @""; } | FULLSTOP anchor { $$ = $2; }; + +source: LEFTPARENTHESIS nodeid optanchor RIGHTPARENTHESIS + { + TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler]; + [a setEdgeSource:$2 + anchor:$3]; + }; + nodeid: LWORD { $$ = $1; } | NATURALNUMBER { $$ = $1; }; coords: @@ -147,14 +161,23 @@ coords: edgecmd : DRAW { [[TikzGraphAssembler currentAssembler] prepareEdge]; }; edge: - edgecmd optproperties nodename TO optedgenode target SEMICOLON + edgecmd optproperties source TO optedgenode target SEMICOLON { TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler]; - [a setEdgeSource:$3 - target:$6]; [a finishEdge]; }; -target: nodename { $$=$1; } | selfloop { $$=@""; }; +target: LEFTPARENTHESIS nodeid optanchor RIGHTPARENTHESIS + { + TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler]; + [a setEdgeTarget:$2 + anchor:$3]; + } + | selfloop + { + TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler]; + [a setEdgeTarget:@"" + anchor:@""]; + }; selfloop: LEFTPARENTHESIS RIGHTPARENTHESIS; altnodecmd: ALTNODE { [[TikzGraphAssembler currentAssembler] prepareNode]; }; -- cgit v1.2.3