An iterator over the contents of a TokenCollection.
More...
#include <bond/compiler/tokenstream.h>
An iterator over the contents of a TokenCollection.
TokenStream has methods to return the next available Token, test whether the next Token is of a certain type, peek at the next Token and manipulate the position in the stream.
◆ TokenStream() [1/2]
Bond::TokenStream::TokenStream |
( |
| ) |
|
|
inline |
◆ TokenStream() [2/2]
Bond::TokenStream::TokenStream |
( |
const Token * |
buffer, |
|
|
int |
length |
|
) |
| |
|
inline |
Constructs a TokenStream object.
- Parameters
-
buffer | A pointer to a buffer of Token objects over which the stream iterates.. |
length | The number of Tokens contained in the buffer. |
◆ Advance()
void Bond::TokenStream::Advance |
( |
| ) |
|
|
inline |
Increments the position of the stream by one.
◆ GetLength()
int Bond::TokenStream::GetLength |
( |
| ) |
const |
|
inline |
Returns the total number of tokens in the stream.
◆ GetPosition()
int Bond::TokenStream::GetPosition |
( |
| ) |
const |
|
inline |
Returns the current position of the stream.
◆ Next()
const Token * Bond::TokenStream::Next |
( |
| ) |
|
Returns the next token in the stream and advances the position.
◆ NextIf() [1/2]
Returns the next token in the stream if it matches any of the given types, otherwise returns nullptr.
- Parameters
-
typeSet | The set of types against which the next Token is compared. |
◆ NextIf() [2/2]
Returns the next token in the stream if it matches the given type, otherwise returns nullptr.
- Parameters
-
type | The type against which the next Token is compared. |
◆ Peek()
const Token * Bond::TokenStream::Peek |
( |
| ) |
const |
|
inline |
Returns the next token in the stream without advancing the position.
◆ PeekIf() [1/2]
Returns the next token in the stream if it matches any of the given types, otherwise returns nullptr.
- Parameters
-
typeSet | The set of types against which the next Token is compared. |
◆ PeekIf() [2/2]
Returns the next token in the stream if it matches the given type, otherwise returns nullptr.
- Parameters
-
type | The type against which the next Token is compared. |
◆ Reset()
void Bond::TokenStream::Reset |
( |
| ) |
|
|
inline |
Resets the position of the stream.
◆ SetBuffer()
void Bond::TokenStream::SetBuffer |
( |
const Token * |
buffer, |
|
|
int |
length |
|
) |
| |
Sets the underlying buffer of Token objects and resets the position of the stream.
- Parameters
-
buffer | A pointer to a buffer of Token objects that the stream iterates over. |
length | The number of Tokens contained in the buffer. |
◆ SetPosition()
void Bond::TokenStream::SetPosition |
( |
int |
index | ) |
|
|
inline |
Set the current position of the stream.
- Parameters
-
index | The position that the stream is set to. |
◆ SkipTo() [1/2]
void Bond::TokenStream::SkipTo |
( |
const TokenTypeSet & |
typeSet | ) |
|
Advances the position of the stream until a Token of one of the given types is encountered. If no such Token is encountered, the stream is advanced to the end.
- Parameters
-
typeSet | The set of types against which the Tokens are compared. |
◆ SkipTo() [2/2]
Advances the position of the stream until a Token of the given type is encountered. If no such Token is encountered, the stream is advanced to the end.
- Parameters
-
type | The type against which the Tokens are compared. |
The documentation for this class was generated from the following file:
- include/bond/compiler/tokenstream.h