From 324d2fddf6d1465a2b44d0a8e03c65580563c729 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 11 Jan 2016 14:49:11 -0500 Subject: [PATCH] lib/parser_base: intro `StringProcessor::eof` and fix index error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/parser_base.nit | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/parser_base.nit b/lib/parser_base.nit index 234b733..f97fbf0 100644 --- a/lib/parser_base.nit +++ b/lib/parser_base.nit @@ -101,12 +101,15 @@ class StringProcessor # Ignores any printable character until a whitespace is encountered protected fun ignore_until_whitespace: Int do - while not src[pos].is_whitespace do pos += 1 + while src.length > pos and not src[pos].is_whitespace do pos += 1 return pos end # Returns the current location as a `Location` object protected fun hot_location: Location do return new Location(line, line_offset) + + # Is `pos` at the end of the source? + protected fun eof: Bool do return pos >= src.length end # Information about the location of an entity in a source document -- 1.7.9.5