public class TokenStream
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) int |
offset |
(package private) java.util.List<Token> |
tokens |
Constructor and Description |
---|
TokenStream(java.util.List<Token> tokens)
Constructor or the class.
|
Modifier and Type | Method and Description |
---|---|
Token |
consume(TokenType type)
Consumes next token of the given type.
|
Token |
consumeIf(TokenType type)
Consumes token of given type; it pauses and does not consume the rest if type differs.
|
java.lang.String |
toString() |
final java.util.List<Token> tokens
int offset
public TokenStream(java.util.List<Token> tokens)
tokens
- The list of recognized tokens.public Token consume(TokenType type) throws java.text.ParseException
type
- The type of the token to consume.java.text.ParseException
- Throws exception if type differs.public Token consumeIf(TokenType type)
type
- The type of the token to consume.public java.lang.String toString()
toString
in class java.lang.Object