summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Merry <dev@randomguy3.me.uk>2013-03-23 18:42:13 +0000
committerAlex Merry <dev@randomguy3.me.uk>2013-03-23 18:42:13 +0000
commit5f4cb99c6b358e2e554e516eaf0ecc6ea6f8690d (patch)
tree2036d9b184e3878ce0c0d21d82d5d8f214040136
parent228f49a7ccb33e9a5c274f3e9102dceb1aaa0e28 (diff)
Fix line counting for newlines in non-INITIAL modes
-rw-r--r--tikzit/src/common/tikzlexer.lm16
1 files changed, 11 insertions, 5 deletions
diff --git a/tikzit/src/common/tikzlexer.lm b/tikzit/src/common/tikzlexer.lm
index 7966028..0785c17 100644
--- a/tikzit/src/common/tikzlexer.lm
+++ b/tikzit/src/common/tikzlexer.lm
@@ -45,7 +45,7 @@ FLOAT \-?[0-9]*(\.[0-9]+)?
%%
-\n {
+<INITIAL,xcoord,ycoord,props,noderef>\n {
yylloc->first_line += 1;
yylloc->last_line = yylloc->first_line;
yylloc->first_column = yylloc->last_column = 0;
@@ -94,7 +94,10 @@ to { return TO; }
}
<props>= { return EQUALS; }
<props>, { return COMMA; }
-<props>[^=,\{\] \t]([^=,\{\]]*[^=,\{\] \t])? {
+ /* technically, it is possible to have newlines in the middle of
+ property names or values, but in practice this is unlikely and
+ screws up our line counting */
+<props>[^=,\{\] \t\n]([^=,\{\]\n]*[^=,\{\] \t\n])? {
yylval->nsstr=[NSString stringWithUTF8String:yytext];
return PROPSTRING;
}
@@ -110,7 +113,9 @@ to { return TO; }
<noderef>\. {
return FULLSTOP;
}
-<noderef>[^\.\{\)]+ {
+ /* we assume node names (and anchor names) never contain
+ newlines */
+<noderef>[^\.\{\)\n]+ {
yylval->nsstr=[NSString stringWithUTF8String:yytext];
return REFSTRING;
}
@@ -156,8 +161,9 @@ to { return TO; }
\\begin { return UNKNOWN_BEGIN_CMD; }
\\end { return UNKNOWN_END_CMD; }
-\\[a-zA-Z]+[a-zA-Z0-9]* { return UNKNOWN_CMD; }
-. { return UNKNOWN_STR; }
+\\[a-zA-Z0-9]+ { return UNKNOWN_CMD; }
+[a-zA-Z0-9]+ { return UNKNOWN_STR; }
+<INITIAL,xcoord,ycoord,props,noderef>. { return UNKNOWN_STR; }
/* vi:ft=lex:noet:ts=4:sts=4:sw=4:
*/