parser_util: parse_somethig behave correclty when the first token is an error
authorJean Privat <jean@pryen.org>
Sat, 31 May 2014 02:55:20 +0000 (22:55 -0400)
committerJean Privat <jean@pryen.org>
Sat, 31 May 2014 02:56:57 +0000 (22:56 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/parser_util.nit

index 9652a1f..f23ccda 100644 (file)
@@ -128,12 +128,11 @@ redef class ToolContext
 
                lexer = new Lexer(source)
                var first = lexer.next
-               if not first isa EOF then
-                       var second = lexer.next
-                       if second isa EOF and not second isa AError then
-                               first.parent = null
-                               return first
-                       end
+               if first isa EOF then return first
+               var second = lexer.next
+               if second isa EOF and not second isa AError then
+                       first.parent = null
+                       return first
                end
 
                lexer = new InjectedLexer(source)