public class TokenStream extends Object
| Constructor and Description |
|---|
TokenStream(Collection<Token> tokens,
String name)
Constructor for a Token Stream
|
| Modifier and Type | Method and Description |
|---|---|
Token |
current()
Looks at the current token.
|
Token |
expect(Token.Type type)
Checks the current token to see if it matches the provided type.
|
Token |
expect(Token.Type type,
String value)
Checks the current token to see if it matches the provided type.
|
String |
getFilename() |
ArrayList<Token> |
getTokens()
used for testing purposes
|
boolean |
isEOF() |
Token |
next()
Consumes and returns the next token in the stream.
|
Token |
peek()
Returns the next token in the stream without consuming it.
|
Token |
peek(int number)
Returns a future token in the stream without consuming any.
|
String |
toString() |
public TokenStream(Collection<Token> tokens, String name)
tokens - A collection of tokensname - The filename of the template that these tokens came frompublic Token next()
public Token expect(Token.Type type) throws ParserException
type - The type of token that we expectParserException - Throws exception if expectation failspublic Token expect(Token.Type type, String value) throws ParserException
type - The type of token that we expectvalue - The expected value of the tokenParserException - Thrown if expectation failspublic Token peek()
public Token peek(int number)
number - How many tokens to lookaheadpublic boolean isEOF()
public Token current()
public String getFilename()
Copyright © 2015. All rights reserved.