diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2017-01-22 14:19:41 +0100 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2017-01-22 14:19:41 +0100 |
commit | df9f92b955ceb18a89b68dacdc3a2ab820a36123 (patch) | |
tree | 45fc97744261db1a9ce0a1078129bf805165be3a /tikzit/src/data/tikzlexer.l | |
parent | 48e69ae28bb8b40d5a2281f0ea26141220b3bf5e (diff) |
parsing
Diffstat (limited to 'tikzit/src/data/tikzlexer.l')
-rw-r--r-- | tikzit/src/data/tikzlexer.l | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/tikzit/src/data/tikzlexer.l b/tikzit/src/data/tikzlexer.l index adb6fef..8dd23c6 100644 --- a/tikzit/src/data/tikzlexer.l +++ b/tikzit/src/data/tikzlexer.l @@ -39,7 +39,6 @@ %option header-file="tikzlexer.h" %option extra-type="TikzGraphAssembler *" - %s props %s xcoord %s ycoord @@ -80,6 +79,7 @@ to { return TO; } BEGIN(xcoord); } <xcoord>{FLOAT} { + yylval->pt = new QPointF(); yylval->pt->setX(strtod(yytext,NULL)); BEGIN(ycoord); } @@ -103,7 +103,9 @@ to { return TO; } property names or values, but in practice this is unlikely and screws up our line counting */ <props>[^=,\{\] \t\n]([^=,\{\]\n]*[^=,\{\] \t\n])? { - yylval->qstr= new QString(yytext); + char *str = (char*)malloc(sizeof(char)*yyleng + 1); + strncpy(str, yytext, yyleng + 1); + yylval->str = str; return PROPSTRING; } <props>\] { @@ -121,7 +123,10 @@ to { return TO; } /* we assume node names (and anchor names) never contain newlines */ <noderef>[^\.\{\)\n]+ { - yylval->qstr = new QString(yytext); + //qDebug() << "nodename: " << yytext << " size: " << strlen(yytext); + char *str = (char*)malloc(sizeof(char)*yyleng + 1); + strncpy(str, yytext, yyleng+1); + yylval->str = str; return REFSTRING; } <noderef>\) { @@ -132,7 +137,7 @@ to { return TO; } <INITIAL,props>\{ { std::stringstream buf; unsigned int brace_depth = 1; - unsigned int escape = 0; + unsigned int escape = 0; while (1) { char c = yyinput(yyscanner); // eof reached before closing brace @@ -158,9 +163,11 @@ to { return TO; } buf << c; } - - - yylval->qstr = new QString(QString::fromStdString(buf.str())); + char *str = (char*)malloc(sizeof(char) * yyleng + 1); + strncpy(str, buf.str().c_str(), yyleng + 1); + //str[len] = 0; + yylval->str = str; + //qDebug() << "got delim string: " << str; return DELIMITEDSTRING; } |