summaryrefslogtreecommitdiff
path: root/tikzit/src/data
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2017-01-20 12:30:31 +0100
committerAleks Kissinger <aleks0@gmail.com>2017-01-20 12:30:31 +0100
commitda45cb6f70f72d804e0a9ed58562e94455672359 (patch)
tree7e985db13abffadfade40c84f86265996e197171 /tikzit/src/data
parentb4f6b3997ba1d1355a42e6d2cd90e7715a9f9114 (diff)
parsing
Diffstat (limited to 'tikzit/src/data')
-rw-r--r--tikzit/src/data/graphelementdata.cpp5
-rw-r--r--tikzit/src/data/graphelementdata.h1
-rw-r--r--tikzit/src/data/tikzlexer.lpp9
-rw-r--r--tikzit/src/data/tikzparser.ypp12
4 files changed, 17 insertions, 10 deletions
diff --git a/tikzit/src/data/graphelementdata.cpp b/tikzit/src/data/graphelementdata.cpp
index 04c7760..8e4a7cc 100644
--- a/tikzit/src/data/graphelementdata.cpp
+++ b/tikzit/src/data/graphelementdata.cpp
@@ -32,6 +32,11 @@ void GraphElementData::unsetProperty(QString key)
_properties.remove(i);
}
+void GraphElementData::operator <<(GraphElementProperty p)
+{
+ _properties << p;
+}
+
void GraphElementData::setAtom(QString atom)
{
GraphElementProperty a(atom);
diff --git a/tikzit/src/data/graphelementdata.h b/tikzit/src/data/graphelementdata.h
index fee65e7..e3d7a68 100644
--- a/tikzit/src/data/graphelementdata.h
+++ b/tikzit/src/data/graphelementdata.h
@@ -49,6 +49,7 @@ public:
// bool removeRows(int position, int rows,
// const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE;
+ void operator <<(GraphElementProperty p);
signals:
public slots:
diff --git a/tikzit/src/data/tikzlexer.lpp b/tikzit/src/data/tikzlexer.lpp
index 19c4d85..7040d52 100644
--- a/tikzit/src/data/tikzlexer.lpp
+++ b/tikzit/src/data/tikzlexer.lpp
@@ -23,6 +23,7 @@
#include "tikzparser.h"
#include <QString>
+#include <stringstream>
#define YY_USER_ACTION \
yylloc->first_line = yylloc->last_line; \
@@ -120,7 +121,7 @@ to { return TO; }
/* we assume node names (and anchor names) never contain
newlines */
<noderef>[^\.\{\)\n]+ {
- yylval->nsstr=[NSString stringWithUTF8String:yytext];
+ yylval->qstr=QString(yytext);
return REFSTRING;
}
<noderef>\) {
@@ -129,7 +130,7 @@ to { return TO; }
}
<INITIAL,props>\{ {
- NSMutableString *buf = [NSMutableString string];
+ std::stringstream buf;
unsigned int brace_depth = 1;
unsigned int escape = 0;
while (1) {
@@ -154,10 +155,10 @@ to { return TO; }
yylloc->last_line += 1;
yylloc->last_column = 0;
}
- [buf appendFormat:@"%c", c];
+ buf << c;
}
- yylval->nsstr = buf;
+ yylval->qstr = QString(buf.str());
return DELIMITEDSTRING;
}
diff --git a/tikzit/src/data/tikzparser.ypp b/tikzit/src/data/tikzparser.ypp
index e97b1c7..ca3b4e4 100644
--- a/tikzit/src/data/tikzparser.ypp
+++ b/tikzit/src/data/tikzparser.ypp
@@ -52,7 +52,7 @@
%{
#include "node.h"
#include "edge.h"
- #include "graphelementdata.h"
+#include "graphelementdata.h"
#include "graphelementproperty.h"
#include "tikzlexer.h"
@@ -139,21 +139,21 @@ optproperties:
| { $$ = 0; };
properties: extraproperties property
{
- [$1 addObject:$2];
+ $1 << $2;
$$ = $1;
};
extraproperties:
extraproperties property ","
{
- [$1 addObject:$2];
+ $1 << $2;
$$ = $1;
}
- | { $$ = [GraphElementData data]; };
+ | { $$ = GraphElementData(); };
property:
val "=" val
- { $$ = [GraphElementProperty property:$1 withValue:$3]; }
+ { $$ = GraphElementProperty($1,$3); }
| val
- { $$ = [GraphElementProperty atom:$1]; };
+ { $$ = GraphElementProperty($1); };
val: PROPSTRING { $$ = $1; } | DELIMITEDSTRING { $$ = $1; };
nodename: "(" REFSTRING ")" { $$ = $2; };