27 #ifndef SCHNEK_TOKENLIST_HPP_ 28 #define SCHNEK_TOKENLIST_HPP_ 34 #include "deckgrammar.hpp" 50 Token(std::string filename_,
int line_,
int token_, std::string str_ =
"")
51 : filename(filename_), line(line_), token(token_), str(str_) {
53 if (token==PATHIDENTIFIER) token = IDENTIFIER;
58 : filename(t.filename), line(t.line), token(t.token), str(t.str) {}
62 filename = t.filename;
104 typedef std::shared_ptr<Token> pToken;
117 std::list<Token> tlist;
118 std::string filename;
120 typedef std::list<Token>::const_iterator const_iterator;
123 TokenList(std::string filename_) : filename(filename_) {}
130 filename = filename_;
143 tlist.push_back(
Token(filename, line, token));
150 void insert(
int line,
int token,
char *str,
size_t len)
152 tlist.push_back(
Token(filename, line, token, std::string(str,len)));
161 tlist.insert(tlist.begin(), tokens.
begin(), tokens.
end());
167 return tlist.begin();
171 const_iterator
end()
const 179 #endif // SCHNEK_TOKENLIST_HPP_ Definition: tokenlist.hpp:114
Token(const Token &t)
Copy constructor.
Definition: tokenlist.hpp:57
std::string getFilename() const
Returns the name of the file from which the token was read.
Definition: tokenlist.hpp:70
void insert(int line, int token)
Insert an individual token onto the list.
Definition: tokenlist.hpp:141
TokenList(std::string filename_)
Default constructor.
Definition: tokenlist.hpp:123
const_iterator end() const
Returns an iterator to the end of the list.
Definition: tokenlist.hpp:171
int getLine() const
Returns the line number where the token was encountered.
Definition: tokenlist.hpp:76
const_iterator begin() const
Returns an iterator to the beginning of the list.
Definition: tokenlist.hpp:165
std::string getString() const
Returns the string constant associated with the token.
Definition: tokenlist.hpp:88
Definition: tokenlist.hpp:43
void reset()
Empties the list and reassigns the filename.
Definition: tokenlist.hpp:135
int getToken() const
Returns the token id.
Definition: tokenlist.hpp:82
Token(std::string filename_, int line_, int token_, std::string str_="")
Construct a token.
Definition: tokenlist.hpp:50
void reset(std::string filename_)
Empties the list and reassigns the filename.
Definition: tokenlist.hpp:127