- Type Parameters:
V
- the token value type
Parser implementation for parsing explicit
Token
sequences.- Since:
- 7.1
- Version:
- 7.1
-
Constructor Summary
ConstructorDescriptionTokenParser
(Tokenizer<Token<V>> tokenizer, int k) Create a new parser object with the giventokenizer
and lookahead countk
. -
Method Summary
Modifier and TypeMethodDescriptionint
LA
(int index) Return the token type code for the given lookahead index.match
(Token.Type type) Try to match and consume the next token of the giventype
.
-
Constructor Details
-
TokenParser
Create a new parser object with the giventokenizer
and lookahead countk
.- Parameters:
tokenizer
- the token sourcethis
parser usesk
- the lookahead count
-
-
Method Details
-
LA
Return the token type code for the given lookahead index.- Parameters:
index
- lookahead index- Returns:
- the token type code for the given lookahead index
-
match
Try to match and consume the next token of the giventype
. If the current token is not from the given type, aParsingException
is thrown.- Parameters:
type
- the token type to match- Returns:
- the matched token
- Throws:
NullPointerException
- if the given tokentype
isnull
ParsingException
- if the current token doesn't match the desired tokentype
-