From 5f4cb99c6b358e2e554e516eaf0ecc6ea6f8690d Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 23 Mar 2013 18:42:13 +0000 Subject: Fix line counting for newlines in non-INITIAL modes --- tikzit/src/common/tikzlexer.lm | 16 +++++++++++----- 1 file 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 { +\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; } } = { return EQUALS; } , { return COMMA; } -[^=,\{\] \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 */ +[^=,\{\] \t\n]([^=,\{\]\n]*[^=,\{\] \t\n])? { yylval->nsstr=[NSString stringWithUTF8String:yytext]; return PROPSTRING; } @@ -110,7 +113,9 @@ to { return TO; } \. { return FULLSTOP; } -[^\.\{\)]+ { + /* we assume node names (and anchor names) never contain + newlines */ +[^\.\{\)\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; } +. { return UNKNOWN_STR; } /* vi:ft=lex:noet:ts=4:sts=4:sw=4: */ -- cgit v1.2.3