From e83a5a003e0b70b1f5e7cb3f46f2d09016b3d86f Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 8 Jun 2022 19:44:09 +0200 Subject: [PATCH] Documentation Project: Token.h & Token.cpp --- src/Token.cpp | 2 -- src/Token.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Token.cpp b/src/Token.cpp index 34f7251..92cf543 100644 --- a/src/Token.cpp +++ b/src/Token.cpp @@ -198,8 +198,6 @@ std::string Token::line() const return this->line_text; } -// Return a copy of the original token, but adding the contents of the line where -// the token was located. Token Token::make_with_line(const Token& origin, const std::string& line_text) { Token result(origin.tk_type,origin.loc); diff --git a/src/Token.h b/src/Token.h index ea7d57f..7e35870 100644 --- a/src/Token.h +++ b/src/Token.h @@ -3,6 +3,7 @@ #include #include +/* All current token types. Will change in the future. */ enum TokenType { TT_Identifier, @@ -73,18 +74,27 @@ struct Token ~Token(); + /* Return a string representation of the Token's contents. */ std::string to_string() const; + /* Return the contents of the line where the Token was located. */ std::string line() const; + /* Return a copy of the original token, but adding the contents of the line where + the token was located. */ static Token make_with_line(const Token& origin, const std::string& line_text); void operator=(const Token& other); + /* Convert the Token into a blank token (does not delete it), so that the Normalizer can remove it afterwards. + This is to not alter vectors while iterating over them. */ static void erase(Token& tk); + /* Return a copy of this Token, but with its TokenType changed. */ Token copy_with_new_type(const TokenType& type); + /* Iterate over two vectors of Tokens, starting from count for vector A, starting from 0 for vector B, checking if the current Tokens' types match. + If at any point they don't, return false. Else, return true. */ static bool match_token_types(const std::vector& a, const std::vector& b, int count); private: