TT - The enumerator representing the scanner's token typespublic class AbstractParser<TT extends java.lang.Enum<TT>>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected ProducerWhichThrows<? extends AbstractScanner.Token<TT>,? extends ScanException> |
scanner
The source of tokens that are processed by this parser.
|
| Constructor and Description |
|---|
AbstractParser(ProducerWhichThrows<? extends AbstractScanner.Token<TT>,? extends ScanException> scanner) |
| Modifier and Type | Method and Description |
|---|---|
void |
eoi() |
AbstractScanner.Token<TT> |
peek()
Checks the next token, but does not consume it.
|
int |
peek(java.lang.Object... tokenTypeOrText)
Checks the next token, but does not consume it.
|
boolean |
peek(java.lang.String text)
Checks the next token, but does not consume it.
|
java.lang.String |
peek(TT tokenType)
Checks the next token, but does not consume it.
|
int |
peekRead(java.lang.String... texts)
Checks the next token and consumes it if it matches.
|
boolean |
peekRead(java.lang.String text)
Checks the next token and consumes it if it matches.
|
AbstractScanner.Token<TT> |
peekRead(TT... tokenTypes)
Checks the next token and consumes it if its type is one of the
tokenTypes. |
java.lang.String |
peekRead(TT tokenType)
Checks the next token and consumes it if its type is
tokenType. |
<T extends java.lang.Enum<T>> |
peekReadEnum(T... values)
Checks the next token and consumes it if its text equals the return value of
toString() of one of the values. |
AbstractScanner.Token<TT> |
read()
Consumes the next token.
|
int |
read(java.lang.Object... tokenTypeOrText)
Consumes the next token.
|
void |
read(java.lang.String text)
Consumes the next token.
|
java.lang.String |
read(TT tokenType)
Consumes the next token.
|
protected final ProducerWhichThrows<? extends AbstractScanner.Token<TT extends java.lang.Enum<TT>>,? extends ScanException> scanner
public AbstractParser(ProducerWhichThrows<? extends AbstractScanner.Token<TT>,? extends ScanException> scanner)
scanner - Its toString() method returns a human-readable indication of the scanner location@Nullable public AbstractScanner.Token<TT> peek() throws ParseException
null if the scanner is at end-of-inputParseException@Nullable public java.lang.String peek(TT tokenType) throws ParseException
null if the next token's type is not tokenType, or if the
scanner is at end-of-inputParseExceptionpublic boolean peek(@Nullable java.lang.String text) throws ParseException
text, or the scanner is not at end-of-input and
text is nullParseExceptionpublic int peek(java.lang.Object... tokenTypeOrText)
throws ParseException
An element of tokenTypeOrText matches iff:
null and the scanner is at end-of-input-1ParseException@Nullable public java.lang.String peekRead(TT tokenType) throws ParseException
tokenType.null if the next token's type is not tokenType, or if
the scanner is at end-of-inputParseExceptionpublic boolean peekRead(@Nullable java.lang.String text) throws ParseException
text, or the scanner is at end-of-input and text
is nullParseExceptionpublic int peekRead(java.lang.String... texts)
throws ParseException
An element of texts matches iff:
null and the scanner is at end-of-input-1ParseException@Nullable public <T extends java.lang.Enum<T>> T peekReadEnum(T... values) throws ParseException
toString() of one of the values.null if none match, or the scanner is at end-of-inputParseException@Nullable public AbstractScanner.Token<TT> peekRead(TT... tokenTypes) throws ParseException
tokenTypes.null iff none match, or the scanner is at end-of-inputParseExceptionpublic AbstractScanner.Token<TT> read() throws ParseException
ParseException - The scanner is at end-of-inputpublic java.lang.String read(TT tokenType) throws ParseException
ParseException - The next token's type is not tokenTypeParseException - The scanner is at end-of-inputpublic void read(java.lang.String text)
throws ParseException
ParseException - The next token's text does not equal textParseException - The scanner is at end-of-inputeoi()public int read(java.lang.Object... tokenTypeOrText)
throws ParseException
An element of tokenTypeOrText matches iff:
null and the scanner is at end-of-inputParseException - Neither the next token's type nor its text equals any of tokenTypeOrTextParseException - The scanner is at end-of-inputpublic void eoi()
throws ParseException
ParseException - Iff the scanner is not at end-of-input