parser: Do not crash if last_loken is unset
authorJean Privat <jean@pryen.org>
Wed, 3 Jun 2009 16:37:22 +0000 (12:37 -0400)
committerJean Privat <jean@pryen.org>
Wed, 10 Jun 2009 13:59:35 +0000 (09:59 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/parser/parser_prod.nit
src/parser/xss/nodes.xss

index 2ec5db6..43abe9e 100644 (file)
@@ -72,6 +72,9 @@ redef class Prod
                if first_token == null then
                        return "????"
                end
+               if last_token == null then
+                       return "{first_token.locate}--????"
+               end
                var lastpos = last_token.pos + last_token.text.length - 1
                if first_token.line == last_token.line then
                        return "{first_token.locate}--{lastpos}"
index 46cfafd..71d4836 100644 (file)
@@ -100,6 +100,9 @@ redef class Prod
                if first_token == null then
                        return "????"
                end
+               if last_token == null then
+                       return "{first_token.locate}--????"
+               end
                var lastpos = last_token.pos + last_token.text.length - 1
                if first_token.line == last_token.line then
                        return "{first_token.locate}--{lastpos}"