module volta.token.writer

Code Map

module volta.token.writer;


//! Small container class for tokens, used by the lexer to write tokens
//! to.
class TokenWriter
{
public:
	errors: LexerError[];
	noDoc: bool;
	magicFlagD: bool;


public:
	//! Create a new TokenWriter and initialize the first token to
	//! TokenType.Begin.
	this(source: Source) { }
	//! Create a new TokenWriter that doesn't have a Source reference.
	this() { }
	//! Return the current source.
	fn source() Source { }
	//! Add the Return the last added token.
	fn addToken(token: Token) { }
	fn addEnd() { }
	//! Remove the last token from the token list. No checking is performed,
	//! assumes you know that you can remove a token.
	fn pop() { }
	//! Return the last added token.
	fn lastAdded() Token { }
	//! Returns this writer's tokens.
	fn getTokens() Token[] { }
}
class TokenWriter

Small container class for tokens, used by the lexer to write tokens to.

this(source: Source)

Create a new TokenWriter and initialize the first token to TokenType.Begin.

this()

Create a new TokenWriter that doesn't have a Source reference.

fn source() Source

Return the current source.

Side-effects: None.

fn addToken(token: Token)

Add the Return the last added token.

Side-effects: None.

fn pop()

Remove the last token from the token list. No checking is performed, assumes you know that you can remove a token.

Side-effects: mTokens is shortened by one.

fn lastAdded() Token

Return the last added token.

Side-effects: None.

fn getTokens() Token[]

Returns this writer's tokens.

TODO: Currently this function will leave the writer in a bit of a odd state. Since it resets the tokens but not the source.

Side-effects: Remove all tokens from this writer, and reinitializes the writer.

fn initTokenArray()

Create a Begin token add set the token array to single array only containing it.

Side-effects: mTokens is replaced, current source is left untouched.