From 1cbf657d955776860580b662aefd53705b603680 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Bobot?= Date: Fri, 22 Jun 2012 15:11:16 +0000 Subject: [PATCH] fix : function AntlrInput::tokenTextSubstr --- src/parser/antlr_input.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/parser/antlr_input.h b/src/parser/antlr_input.h index 84b5099fb..10a4b907d 100644 --- a/src/parser/antlr_input.h +++ b/src/parser/antlr_input.h @@ -244,7 +244,9 @@ inline std::string AntlrInput::tokenText(pANTLR3_COMMON_TOKEN token) { inline std::string AntlrInput::tokenTextSubstr(pANTLR3_COMMON_TOKEN token, size_t index, size_t n) { + ANTLR3_MARKER start = token->getStartIndex(token); + // Its the last character of the token (not the one just after) ANTLR3_MARKER end = token->getStopIndex(token); Assert( start < end ); if( index > (size_t) end - start ) { @@ -253,7 +255,7 @@ inline std::string AntlrInput::tokenTextSubstr(pANTLR3_COMMON_TOKEN token, throw std::invalid_argument(ss.str()); } start += index; - if( n==0 || n >= (size_t) end - start ) { + if( n==0 || n > (size_t) end - start ) { return std::string( (const char *)start, end-start+1 ); } else { return std::string( (const char *)start, n ); -- 2.30.2