From 9e47962ddd0dc9f6874b7ca50874d444ed81c848 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 24 Mar 2013 15:21:23 +0000 Subject: Make first/last_column count character offsets This means that tabs don't get treated specially. No-one can seem to agree how many spaces a tab should be, and the first thing we actually ended up doing was to undo the extra tab counting. --- tikzit/src/common/tikzlexer.lm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tikzit/src/common/tikzlexer.lm') diff --git a/tikzit/src/common/tikzlexer.lm b/tikzit/src/common/tikzlexer.lm index 4e675ad..2956a8b 100644 --- a/tikzit/src/common/tikzlexer.lm +++ b/tikzit/src/common/tikzlexer.lm @@ -44,17 +44,18 @@ FLOAT \-?[0-9]*(\.[0-9]+)? %% -\n { + /* whitespace is ignored, except for position counting; we don't + count formfeed and vtab as whitespace, because it's not obvious + how they should be dealt with and no-one actually uses them */ + + /* lex will take the longest-matching string */ +\r\n|\r|\n { yylloc->first_line += 1; yylloc->last_line = yylloc->first_line; yylloc->first_column = yylloc->last_column = 0; } -[ ]+ { } /* ignore whitespace */; -[\t]+ { - // tab = 8 columns - // note that we have already adjusted by yyleng at this point - yylloc->last_column += 7*yyleng; -} +[\t ]+ { } + \\begin\{tikzpicture\} { return BEGIN_TIKZPICTURE_CMD; } \\end\{tikzpicture\} { return END_TIKZPICTURE_CMD; } \\begin\{pgfonlayer\} { return BEGIN_PGFONLAYER_CMD; } -- cgit v1.2.3