summaryrefslogtreecommitdiff
path: root/tikzit/src/common/tikzparser.ym
diff options
context:
space:
mode:
Diffstat (limited to 'tikzit/src/common/tikzparser.ym')
-rw-r--r--tikzit/src/common/tikzparser.ym39
1 files changed, 31 insertions, 8 deletions
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<nsstr> nodename
+%type<nsstr> anchor
+%type<nsstr> optanchor
%type<nsstr> nodeid
%type<pt> coords
-%type<nsstr> target
%type<nsstr> propsym
%type<nsstr> propsyms
%type<nsstr> val
@@ -119,6 +122,8 @@ propsym:
nodecmd : NODE { [[TikzGraphAssembler currentAssembler] prepareNode]; };
+nodename: LEFTPARENTHESIS nodeid RIGHTPARENTHESIS { $$ = $<nsstr>2; };
+
node:
nodecmd optproperties nodename AT coords nodelabel SEMICOLON
{
@@ -135,8 +140,17 @@ nodelabel:
[n setLabel:$<nsstr>1];
}
-optanchor: | ANCHORCENTER;
-nodename: LEFTPARENTHESIS nodeid optanchor RIGHTPARENTHESIS { $$ = $<nsstr>2; };
+anchor: LWORD { $$ = $<nsstr>1; } | NATURALNUMBER { $$ = $<nsstr>1; };
+
+optanchor: { $$ = @""; } | FULLSTOP anchor { $$ = $<nsstr>2; };
+
+source: LEFTPARENTHESIS nodeid optanchor RIGHTPARENTHESIS
+ {
+ TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler];
+ [a setEdgeSource:$<nsstr>2
+ anchor:$<nsstr>3];
+ };
+
nodeid: LWORD { $$ = $<nsstr>1; } | NATURALNUMBER { $$ = $<nsstr>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:$<nsstr>3
- target:$<nsstr>6];
[a finishEdge];
};
-target: nodename { $$=$<nsstr>1; } | selfloop { $$=@""; };
+target: LEFTPARENTHESIS nodeid optanchor RIGHTPARENTHESIS
+ {
+ TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler];
+ [a setEdgeTarget:$<nsstr>2
+ anchor:$<nsstr>3];
+ }
+ | selfloop
+ {
+ TikzGraphAssembler *a = [TikzGraphAssembler currentAssembler];
+ [a setEdgeTarget:@""
+ anchor:@""];
+ };
selfloop: LEFTPARENTHESIS RIGHTPARENTHESIS;
altnodecmd: ALTNODE { [[TikzGraphAssembler currentAssembler] prepareNode]; };