public class TokenStream extends Object
Constructor and Description |
---|
TokenStream()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addToken(String value,
TokenType type)
Adds a token to the stream.
|
TokenStream |
build()
Builds the stream for consumption.
|
boolean |
canConsume(String... tokenValues)
Attempts to consume the next n tokens, but only if they match the given token values.
|
boolean |
canConsume(String tokenValue)
Attempts to consume a token that matches any of the given token values.
|
boolean |
canConsumeAnyOf(String... tokenValues)
Attempts to consume a token that matches any of the given token values.
|
Token |
consume()
Consume the next token in the stream, and return what it was.
|
boolean |
hasNext()
Returns true if there are more tokens in the stream.
|
boolean |
matches(String... tokenValues)
Returns true if the next tokens in the stream match the given token values.
|
boolean |
matches(String tokenValue)
Returns true if the next token in the stream matches any of the given token values.
|
boolean |
matches(TokenType tokenType)
Returns true if the next token in the stream matches any of the given types.
|
boolean |
matchesAnyOf(String... tokenValues)
Returns true if the next token in the stream matches any of the given token values.
|
boolean |
matchesAnyOf(TokenType... tokenTypes)
Returns true if the next token in the stream matches any of the given types.
|
String |
toString() |
public void addToken(String value, TokenType type)
value
- type
- public TokenStream build()
public boolean hasNext()
public boolean canConsume(String tokenValue)
tokenValue
- public boolean canConsume(String... tokenValues)
tokenValues
- public boolean canConsumeAnyOf(String... tokenValues)
tokenValues
- public boolean matches(TokenType tokenType)
tokenType
- public boolean matchesAnyOf(TokenType... tokenTypes)
tokenTypes
- public boolean matches(String tokenValue)
tokenValue
- public boolean matches(String... tokenValues)
tokenValues
- public boolean matchesAnyOf(String... tokenValues)
tokenValues
- public Token consume()
public String toString()
toString
in class Object
Object.toString()
Copyright © 2011–2015 JBoss, a division of Red Hat. All rights reserved.