god::tokenstream#
Note
Declared in <god/token.hpp>
-
class tokenstream#
A set of tokens prepared for parsing
Members
-
std::size_t pos = 0#
The current parsing position in the stream.
Methods
-
std::expected<const token*, error> at(std::size_t n) const noexcept#
Retrieve a member from the tokenstream at a specific index.
- Parameters:
n – The index of the desired member
- Returns:
A constant pointer to the desired token or an error
-
token &now()#
Get the current token in the stream (the one matching
pos).- Returns:
a mutable reference to the token
-
bool done() const noexcept#
Check if we are finished with the token stream.
Note that this checks the
posagainst the deque size, NOT whether the deque has any tokens remaining- Returns:
true if
posis at the end of the deque, false otherwise
-
bool empty() const noexcept#
Check if the members deque is empty.
This is essentially just a shortcut to calling .empty() on the members container itself.
- Returns:
true if members is empty, false otherwise
-
std::size_t count() const noexcept#
Check the amount of members.
This is essentially just a shortcut to calling .size() on the ‘members’ container itself.
- Returns:
The amount of remaining members
-
void consume()#
Consume the token at the index of ‘pos’.
-
void consume(std::size_t x)#
Consume a token at a specific index.
- Parameters:
x – The index to consume
-
void consume(std::size_t x, std::size_t y)#
Consume a range of tokens.
- Parameters:
x – the beginning index of the range
y – the ending index of the range
-
std::expected<token*, error> last()#
Get the last member of the tokenstream.
- Returns:
A pointer to the last token or a god::error
-
std::expected<token*, error> first()#
Get the first (index 0) member of the tokenstream.
- Returns:
A pointer to the first token or a god::error
-
std::size_t pos = 0#