An iterator over the contents of a TokenCollection.
More...
#include <bond/compiler/tokenstream.h>
|
| | TokenStream () |
| | Constructs an empty TokenStream object.
|
| | TokenStream (const Token *buffer, int length) |
| | Constructs a TokenStream object.
|
| void | SetBuffer (const Token *buffer, int length) |
| | Sets the underlying buffer of Token objects and resets the position of the stream.
|
| void | Reset () |
| | Resets the position of the stream.
|
| void | Advance () |
| | Increments the position of the stream by one.
|
| const Token * | Next () |
| | Returns the next token in the stream and advances the position.
|
| const Token * | NextIf (Token::TokenType type) |
| | Returns the next token in the stream if it matches the given type, otherwise returns nullptr.
|
| const Token * | NextIf (const TokenTypeSet &typeSet) |
| | Returns the next token in the stream if it matches any of the given types, otherwise returns nullptr.
|
| const Token * | Peek () const |
| | Returns the next token in the stream without advancing the position.
|
| const Token * | PeekIf (Token::TokenType type) const |
| | Returns the next token in the stream if it matches the given type, otherwise returns nullptr.
|
| const Token * | PeekIf (const TokenTypeSet &typeSet) const |
| | Returns the next token in the stream if it matches any of the given types, otherwise returns nullptr.
|
| void | SkipTo (Token::TokenType type) |
| | 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.
|
| void | 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.
|
| int | GetPosition () const |
| | Returns the current position of the stream.
|
| void | SetPosition (int index) |
| | Set the current position of the stream.
|
| int | GetLength () const |
| | Returns the total number of tokens in the stream.
|
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