parser_util: drop injected tokens in `parse_someting`
authorJean Privat <jean@pryen.org>
Fri, 9 May 2014 23:03:59 +0000 (19:03 -0400)
committerJean Privat <jean@pryen.org>
Fri, 9 May 2014 23:03:59 +0000 (19:03 -0400)
Since injected tokens have a false location, highlight.nit had a bad
behavior when trying to color them.
Thez should not survive `parse_something`.

Fixes #451
Signed-off-by: Jean Privat <jean@pryen.org>

src/parser_util.nit

index 9a6eec0..377e090 100644 (file)
@@ -156,7 +156,8 @@ redef class ToolContext
                tree = (new Parser(lexer)).parse
                eof = tree.n_eof
                if not eof isa AError then
-                       var nblock = tree.n_base.n_classdefs.first.n_propdefs.first.as(AMainMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(ADoExpr).n_block.as(not null)
+                       var nblock = tree.n_base.n_classdefs.first.n_propdefs.first.as(AMainMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(ADoExpr).n_block.as(ABlockExpr)
+                       nblock.n_kwend = null # drop injected token
                        return nblock
                end
                if eof.location > error.location then error = eof