summaryrefslogtreecommitdiff
path: root/tikzit/src/common/tikzparser.ym
diff options
context:
space:
mode:
authorAlex Merry <dev@randomguy3.me.uk>2013-03-23 03:30:19 +0000
committerAlex Merry <dev@randomguy3.me.uk>2013-03-23 03:38:55 +0000
commit8cde489ab6c4169fb03d810447c18eea0d0eaa14 (patch)
treead3fcdc71f1819963198ae8a52fc5f2b2818cd20 /tikzit/src/common/tikzparser.ym
parente68a44b882e5d6dbbab769f7ef20355ec53a9278 (diff)
Make the parser/lexer reentrant
No more locking! Also, the interface for TikzGraphAssembler is much simpler. Changes to OSX code are completely untested.
Diffstat (limited to 'tikzit/src/common/tikzparser.ym')
-rw-r--r--tikzit/src/common/tikzparser.ym30
1 files changed, 16 insertions, 14 deletions
diff --git a/tikzit/src/common/tikzparser.ym b/tikzit/src/common/tikzparser.ym
index 074ec2d..1183f12 100644
--- a/tikzit/src/common/tikzparser.ym
+++ b/tikzit/src/common/tikzparser.ym
@@ -1,5 +1,3 @@
-%error-verbose
-
%{
/*
* Copyright 2010 Chris Heunen
@@ -21,18 +19,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#import "TikzGraphAssembler+Parser.h"
#import "Edge.h"
-extern char* yystr;
-extern int yylineno;
-extern int tokenpos;
-extern int yylex(void);
-extern void yyerror(const char *str);
-
%}
%code requires {
+#import "TikzGraphAssembler+Parser.h"
#import "GraphElementData.h"
#import "GraphElementProperty.h"
#import "Node.h"
@@ -42,6 +34,12 @@ struct noderef {
};
}
+%defines "common/tikzparser.h"
+%pure-parser
+%parse-param {TikzGraphAssembler *assembler}
+%error-verbose
+
+
%union {
NSPoint pt;
NSString *nsstr;
@@ -51,6 +49,10 @@ struct noderef {
struct noderef noderef;
};
+%{
+#import "tikzlexer.h"
+%}
+
%token BEGIN_TIKZPICTURE_CMD "\\begin{tikzpicture}"
%token END_TIKZPICTURE_CMD "\\end{tikzpicture}"
@@ -127,14 +129,14 @@ node: "\\node" optproperties nodename "at" COORD DELIMITEDSTRING ";"
[node setName:$3];
[node setPoint:$5];
[node setLabel:$6];
- [[TikzGraphAssembler currentAssembler] addNodeToMap:node];
- [[[TikzGraphAssembler currentAssembler] graph] addNode:node];
+ [assembler addNodeToMap:node];
+ [[assembler graph] addNode:node];
};
optanchor: { $$ = nil; } | "." REFSTRING { $$ = $2; };
noderef: "(" REFSTRING optanchor ")"
{
- $$.node = [[TikzGraphAssembler currentAssembler] nodeWithName:$2];
+ $$.node = [assembler nodeWithName:$2];
$$.anchor = $3;
};
optnoderef:
@@ -163,7 +165,7 @@ edge: "\\draw" optproperties noderef "to" optedgenode optnoderef ";"
[edge setTargetAnchor:$3.anchor];
}
[edge setAttributesFromData];
- [[[TikzGraphAssembler currentAssembler] graph] addEdge:edge];
+ [[assembler graph] addEdge:edge];
};
ignoreprop: val | val "=" val;
@@ -172,7 +174,7 @@ optignoreprops: "[" ignoreprops "]";
boundingbox:
"\\path" optignoreprops COORD "rectangle" COORD ";"
{
- [[[TikzGraphAssembler currentAssembler] graph] setBoundingBox:NSRectAroundPoints($3, $5)];
+ [[assembler graph] setBoundingBox:NSRectAroundPoints($3, $5)];
};
/* vi:ft=yacc:noet:ts=4:sts=4:sw=4