| 构造器和说明 |
|---|
TokenStream(List<Token> tokens) |
| 限定符和类型 | 方法和说明 |
|---|---|
Token |
consume()
Consumes the next token and returns it.
|
Token |
expect(String text)
Checks if the next token matches the given text and optionally consumes, or throws an error if the next token did not match
the text.
|
Token |
expect(TokenType type)
Checks if the next token has the give type and optionally consumes, or throws an error if the next token did not match the
type.
|
Token |
getPrev() |
String |
getSource()
Returns the
Source this stream wraps. |
boolean |
hasMore()
Returns whether there are more tokens in the stream.
|
boolean |
hasNext() |
boolean |
hasPrev() |
int |
makeIndex() |
boolean |
match(boolean consume,
String... tokenTexts)
Matches any of the token texts and optionally consumes the next token in case of a match.
|
boolean |
match(boolean consume,
TokenType... types)
Matches any of the token types and optionally consumes the next token in case of a match.
|
boolean |
match(List<String> texts,
boolean consume) |
boolean |
match(String text,
boolean consume)
Matches and optionally consumes the next token in case of a match.
|
boolean |
match(TokenType type,
boolean consume)
Matches and optionally consumes the next token in case of a match.
|
Token |
next() |
Token |
prev() |
void |
resetIndex() |
void |
resetIndex(int index) |
public boolean hasMore()
public boolean hasNext()
public boolean hasPrev()
public int makeIndex()
public void resetIndex()
public void resetIndex(int index)
public Token consume()
public Token next()
public Token prev()
public Token getPrev()
public Token expect(TokenType type)
public Token expect(String text)
public boolean match(TokenType type, boolean consume)
public boolean match(String text, boolean consume)
public boolean match(boolean consume,
TokenType... types)
public boolean match(boolean consume,
String... tokenTexts)
Copyright © 2020–2021. All rights reserved.