Documentation Project: Token.h & Token.cpp
This commit is contained in:
parent
46a79b6efe
commit
e83a5a003e
@ -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);
|
||||
|
10
src/Token.h
10
src/Token.h
@ -3,6 +3,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/* 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<Token>& a, const std::vector<Token>& b, int count);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user