From af26c90d53aa43a228efeaf516dae675a213be8c Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 3 Jun 2009 12:37:22 -0400 Subject: [PATCH] parser: Do not crash if last_loken is unset Signed-off-by: Jean Privat --- src/parser/parser_prod.nit | 3 +++ src/parser/xss/nodes.xss | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/parser/parser_prod.nit b/src/parser/parser_prod.nit index 2ec5db6..43abe9e 100644 --- a/src/parser/parser_prod.nit +++ b/src/parser/parser_prod.nit @@ -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}" diff --git a/src/parser/xss/nodes.xss b/src/parser/xss/nodes.xss index 46cfafd..71d4836 100644 --- a/src/parser/xss/nodes.xss +++ b/src/parser/xss/nodes.xss @@ -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}" -- 1.7.9.5