From 1a71fd8efa0350d1e121f6792e8fad67e82b25c1 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Thu, 5 Apr 2018 13:20:20 +0200 Subject: fixed name conflict, now builds in MSVC --- src/data/tikzparser.y | 52 +++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'src/data/tikzparser.y') diff --git a/src/data/tikzparser.y b/src/data/tikzparser.y index 76674f1..6e708a3 100644 --- a/src/data/tikzparser.y +++ b/src/data/tikzparser.y @@ -25,6 +25,7 @@ * along with this program. If not, see . */ + #include "tikzparserdefs.h" %} @@ -62,7 +63,7 @@ #include "graphelementproperty.h" #include "tikzlexer.h" -#import "tikzassembler.h" +#include "tikzassembler.h" /* the assembler (used by this parser) is stored in the lexer state as "extra" data */ #define assembler yyget_extra(scanner) @@ -71,7 +72,7 @@ void yyerror(YYLTYPE *yylloc, void *scanner, const char *str) { // TODO: implement reportError() //assembler->reportError(str, yylloc); - qDebug() << "parse error: " << str; + qDebug() << "\nparse error: " << str << " line:" << yylloc->first_line; } %} @@ -104,7 +105,7 @@ void yyerror(YYLTYPE *yylloc, void *scanner, const char *str) { %token RIGHTBRACKET "]" %token FULLSTOP "." %token EQUALS "=" -%token COORD "co-ordinate" +%token TCOORD "coordinate" %token PROPSTRING "key/value string" %token REFSTRING "string" %token DELIMITEDSTRING "{-delimited string" @@ -187,7 +188,7 @@ property: val: PROPSTRING { $$ = $1; } | DELIMITEDSTRING { $$ = $1; }; nodename: "(" REFSTRING ")" { $$ = $2; }; -node: "\\node" optproperties nodename "at" COORD DELIMITEDSTRING ";" +node: "\\node" optproperties nodename "at" TCOORD DELIMITEDSTRING ";" { Node *node = new Node(); @@ -240,36 +241,39 @@ edge: "\\draw" optproperties noderef "to" optedgenode optnoderef ";" t = s; } - Edge *edge = new Edge(s, t); - if ($2) { - edge->setData($2); - edge->setAttributesFromData(); - } + // if the source or the target of the edge doesn't exist, quietly ignore it. + if (s != 0 && t != 0) { + Edge *edge = new Edge(s, t); + if ($2) { + edge->setData($2); + edge->setAttributesFromData(); + } - if ($5) - edge->setEdgeNode($5); - if ($3.anchor) { - edge->setSourceAnchor(QString($3.anchor)); - free($3.anchor); - } + if ($5) + edge->setEdgeNode($5); + if ($3.anchor) { + edge->setSourceAnchor(QString($3.anchor)); + free($3.anchor); + } - if ($6.node) { - if ($6.anchor) { - edge->setTargetAnchor(QString($6.anchor)); - free($6.anchor); + if ($6.node) { + if ($6.anchor) { + edge->setTargetAnchor(QString($6.anchor)); + free($6.anchor); + } + } else { + edge->setTargetAnchor(edge->sourceAnchor()); } - } else { - edge->setTargetAnchor(edge->sourceAnchor()); - } - assembler->graph()->addEdge(edge); + assembler->graph()->addEdge(edge); + } }; ignoreprop: val | val "=" val; ignoreprops: ignoreprop ignoreprops | ; optignoreprops: "[" ignoreprops "]"; boundingbox: - "\\path" optignoreprops COORD "rectangle" COORD ";" + "\\path" optignoreprops TCOORD "rectangle" TCOORD ";" { assembler->graph()->setBbox(QRectF(*$3, *$5)); delete $3; -- cgit v1.2.3