From 2aceb623ae53d1f3a2dfa9aa118f498fcf6e6ca0 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 11 Nov 2011 21:55:37 +0100 Subject: [PATCH] 1)Add 'Token' function 'linkAt', which simplifies the writing 'tokAt(i)->link()' to 'linkAt(i)'. It's still unused, though. 2)Fix one grammatical mistake inside token.h 3)Style change to token.cpp: remove the whitespace between '!' and 'begin'. --- lib/token.cpp | 14 +++++++++++++- lib/token.h | 9 ++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index be8f37ece..bdca266e4 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -221,6 +221,18 @@ Token *Token::tokAt(int index) return tok; } +const Token *Token::linkAt(int index) const +{ + const Token *tok = this->tokAt(index); + return tok->link(); +} + +Token *Token::linkAt(int index) +{ + Token *tok = this->tokAt(index); + return tok->link(); +} + std::string Token::strAt(int index) const { const Token *tok = this->tokAt(index); @@ -818,7 +830,7 @@ void Token::insertToken(const std::string &tokenStr) void Token::eraseTokens(Token *begin, const Token *end) { - if (! begin) + if (!begin) return; while (begin->next() && begin->next() != end) { diff --git a/lib/token.h b/lib/token.h index 0cd065baa..03032cd47 100644 --- a/lib/token.h +++ b/lib/token.h @@ -71,6 +71,13 @@ public: const Token *tokAt(int index) const; Token *tokAt(int index); + /** + * Returns the link to the token in given index, related to this token. + * For example index 1 would return the link to next token. + */ + const Token *linkAt(int index) const; + Token *linkAt(int index); + std::string strAt(int index) const; /** @@ -368,7 +375,7 @@ public: std::string strValue() const; /** - * Move srcStart and srcEnd tokens and all tokens between then + * Move srcStart and srcEnd tokens and all tokens between them * into new a location. Only links between tokens are changed. * @param srcStart This is the first token to be moved * @param srcEnd The last token to be moved