From 19e97543cf6ca841748f12e5f301e2205e73f6c6 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 14 May 2015 19:18:15 -0400 Subject: [PATCH] parser: ComputeProdLocationVisitor remember the last token instead of the location Signed-off-by: Jean Privat --- src/parser/parser_work.nit | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/parser/parser_work.nit b/src/parser/parser_work.nit index c2eff11..363faf4 100644 --- a/src/parser/parser_work.nit +++ b/src/parser/parser_work.nit @@ -182,15 +182,15 @@ private class ComputeProdLocationVisitor # Already visited epsilon productions that waits something after them var need_after_epsilons = new Array[Prod] - # Location of the last visited token in the current production - var last_location: nullable Location = null + # The last visited token in the current production + var last_token: nullable Token = null redef fun visit(n: ANode) do if n isa Token then if not isset n._location then return var loc = n._location - _last_location = loc + _last_token = n # Add a first token to productions that need one if not _need_first_prods.is_empty then @@ -217,8 +217,7 @@ private class ComputeProdLocationVisitor var startl = n._first_location if startl != null then # Non-epsilon production - var endl = _last_location - assert endl != null + var endl = _last_token.location if startl == endl then n.location = startl -- 1.7.9.5