public interface TokenStream
Tokens.| Modifier and Type | Method and Description |
|---|---|
Location |
location() |
Token |
peek() |
int |
peek(String... suspected)
Checks whether the value of the next token equals any of the suspected; does not consume the next
token.
|
boolean |
peek(String suspected) |
int |
peek(TokenType... suspected)
Checks whether the type of the next token is any of the suspected; does not consume the next token.
|
boolean |
peek(TokenType suspected) |
Token |
peekNextButOne() |
boolean |
peekNextButOne(String suspected) |
int |
peekRead(String... suspected)
Checks whether the value of the next token is one of the suspected; if so, consumes the token.
|
boolean |
peekRead(String suspected)
Checks whether the value of the next token equals the suspected; if so, consumes the token.
|
int |
peekRead(TokenType... suspected)
Checks whether the type of the next token is one of the suspected; if so, consumes the token.
|
String |
peekRead(TokenType suspected)
Checks whether the type of the next token is the suspected; if so, consumes the token.
|
Token |
read() |
int |
read(String... expected)
Verifies that the value of the next token equals one of the expected, and consumes the token.
|
void |
read(String expected)
Verifies that the value of the next token equals expected, and consumes the token.
|
int |
read(TokenType... expected)
Verifies that the type of the next token is one of the expected, and consumes the token.
|
String |
read(TokenType expected)
Verifies that the type of the next token is the expected, and consumes the token.
|
void |
setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a
WarningHandler. |
Token peek() throws CompileException, IOException
CompileExceptionIOExceptionboolean peek(String suspected) throws CompileException, IOException
CompileExceptionIOExceptionint peek(String... suspected) throws CompileException, IOException
CompileExceptionIOExceptionboolean peek(TokenType suspected) throws CompileException, IOException
CompileExceptionIOExceptionint peek(TokenType... suspected) throws CompileException, IOException
CompileExceptionIOExceptionToken peekNextButOne() throws CompileException, IOException
CompileExceptionIOExceptionboolean peekNextButOne(String suspected) throws CompileException, IOException
CompileExceptionIOExceptionToken read() throws CompileException, IOException
null iff the scanner is at end-of-inputCompileExceptionIOExceptionvoid read(String expected) throws CompileException, IOException
CompileException - The value of the next token does not equal expected (this includes the case
that the scanner is at end-of-input)IOExceptionint read(String... expected) throws CompileException, IOException
CompileException - The value of the next token does not equal any of the expected (this includes
the case where the scanner is at end-of-input)IOExceptionString read(TokenType expected) throws CompileException, IOException
interned String iff the token
represents an identifier, true, false, null, or an operatorCompileException - The next token's type is not the expectedIOExceptionint read(TokenType... expected) throws CompileException, IOException
CompileException - The next token's type is none of the expectedIOExceptionboolean peekRead(String suspected) throws CompileException, IOException
CompileExceptionIOExceptionint peekRead(String... suspected) throws CompileException, IOException
CompileExceptionIOException@Nullable String peekRead(TokenType suspected) throws CompileException, IOException
interned String iff the token represents an
identifier, true, false, null, or an operatorCompileExceptionIOExceptionint peekRead(TokenType... suspected) throws CompileException, IOException
CompileExceptionIOExceptionvoid setWarningHandler(@Nullable WarningHandler optionalWarningHandler)
WarningHandler.
Notice that there is no Parser.setErrorHandler() method, but parse errors always throw a CompileException. The reason being is that there is no reasonable way to recover from parse errors and
continue parsing, so there is no need to install a custom parse error handler.
optionalWarningHandler - null to indicate that no warnings be issuedLocation location()
Copyright © 2019. All rights reserved.