lexer: do not create useless location (for whitespaces)
authorJean Privat <jean@pryen.org>
Wed, 8 Apr 2015 05:00:20 +0000 (12:00 +0700)
committerJean Privat <jean@pryen.org>
Wed, 8 Apr 2015 05:00:20 +0000 (12:00 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/parser/lexer_work.nit

index b933208..fa7f18f 100644 (file)
@@ -234,13 +234,14 @@ class Lexer
                                end
                        else
                                if accept_state != -1 then
-                                       var location = new Location(file, start_line + 1, accept_line + 1, start_pos + 1, accept_pos)
                                        _pos = accept_pos
                                        _line = accept_line
                                        _stream_pos = start_stream_pos + accept_length
                                        if accept_token == 0 then
+                                               # Ignored token (whitespaces)
                                                return null
                                        end
+                                       var location = new Location(file, start_line + 1, accept_line + 1, start_pos + 1, accept_pos)
                                        return make_token(accept_token, location)
                                else
                                        _stream_pos = sp