From 5a04e1e1ebd926f348c74edb1dde587329d52f40 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 17 Aug 2013 10:43:09 +0200 Subject: keep track of line, column and character MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- auto-auto-complete.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/auto-auto-complete.py b/auto-auto-complete.py index d07d7fc..8fb7710 100755 --- a/auto-auto-complete.py +++ b/auto-auto-complete.py @@ -63,6 +63,10 @@ class Parser: quote = None buf = None + col = 0 + char = 0 + line = 1 + for charindex in range(0, len(code)): c = code[charindex] if comment: @@ -118,6 +122,15 @@ class Parser: quote = c else: buf += c + + if c == '\t': + col |= 7 + col += 1 + char += 1 + if c in '\n\r\f': + line += 1 + col = 0 + char = 0 raise Exception('premature end of file') -- cgit v1.2.3-70-g09d2