Code Map
module volta.ir.tokenstream;
public import volta.ir.token;
//! Class used by the parser to read lexed tokens.
class TokenStream
{
public:
errSink: ErrorSink;
public:
//! Takes the token array, initializes mTokens and sets the current token
//! to the first token.
this(tokens: Token[], errSink: ErrorSink) { }
//! Reset the stream.
fn reset() { }
//! Compares the current token's type against the given type.
fn opEquals(type: TokenType) bool { }
//! Compares from the current token and onwards type against the list of
//! types.
fn opEquals(types: scope (const(scope (TokenType)[])) i32 { }
//! Returns the current token.
fn peek() Token { }
//! Returns the current token. Thorws: CompilerPanic on mIndex == 0.
fn previous() Token { }
//! Returns the token @n steps ahead. Will clamp @n to stream length.
fn lookahead(n: size_t, eof: bool) Token { }
//! Returns the token @n step behind the current token. Will cause a
//! compiler panic if looking to far back.
fn lookbehind(n: size_t) Token { }
//! Returns the current position in the stream.
fn save() size_t { }
//! Restore the stream to the current index retrieved from save().
fn restore(index: size_t) { }
protected:
mTokens: Token[];
mIndex: size_t;
}
Class used by the parser to read lexed tokens.
Takes the token array, initializes mTokens and sets the current token to the first token.
Reset the stream.
Side-effects: Sets mIndex = 0.
Compares the current token's type against the given type.
Side-effects: None.
Compares from the current token and onwards type against the list of types.
Side-effects: None.
Returns the current token.
Side-effects: None.
Returns the current token. Thorws: CompilerPanic on mIndex == 0.
Side-effects: None.
See also
-
lookbehind.
Returns the token @n steps ahead. Will clamp @n to stream length.
Side-effects: None.
Returns the token @n step behind the current token. Will cause a compiler panic if looking to far back.
Throws: CompilerPanic on @n being larger then mIndex.
Side-effects: None.
Returns the current position in the stream.
Side-effects: None.
Restore the stream to the current index retrieved from save().
Side-effects: mIndex is set to index.