|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.unkrig.commons.text.parser.AbstractParser<TT>
TT - The enumerator representing the scanner's token typespublic class AbstractParser<TT extends java.lang.Enum<TT>>
The base class for implementing parsers. Typically, you would declare methods named 'parse...()' which invoke each other and the 'peek...()', 'read...()' and 'peekRead...()' methods to parse a document.
| Field Summary | |
|---|---|
protected ProducerWhichThrows<AbstractScanner.Token<TT>,ScanException> |
scanner
The source of tokens that are processed by this parser. |
| Constructor Summary | |
|---|---|
AbstractParser(ProducerWhichThrows<AbstractScanner.Token<TT>,ScanException> scanner)
|
|
| Method Summary | ||
|---|---|---|
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 its text equals any of texts. |
|
boolean |
peekRead(java.lang.String text)
Checks the next token and consumes it if its text equals text. |
|
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. |
|
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final ProducerWhichThrows<AbstractScanner.Token<TT extends java.lang.Enum<TT>>,ScanException> scanner
| Constructor Detail |
|---|
public AbstractParser(ProducerWhichThrows<AbstractScanner.Token<TT>,ScanException> scanner)
scanner - Its toString() method returns a human-readable indication of the scanner location| Method Detail |
|---|
@Nullable
public AbstractScanner.Token<TT> peek()
throws ParseException
null if the scanner is at end-of-input
ParseException
@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-input
ParseException
public boolean peek(java.lang.String text)
throws ParseException
text
ParseException
public int peek(java.lang.Object... tokenTypeOrText)
throws ParseException
tokenTypeOrText which equals either the next token's type or text, or
-1
ParseException
@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-input
ParseException
public boolean peekRead(java.lang.String text)
throws ParseException
text.
text
ParseException
public int peekRead(java.lang.String... texts)
throws ParseException
texts.
texts which equals the next token's text, or -1
ParseException
@Nullable
public <T extends java.lang.Enum<T>> T peekReadEnum(T... values)
throws ParseException
toString() of one of the values.
null if none matches
ParseException
@Nullable
public AbstractScanner.Token<TT> peekRead(TT... tokenTypes)
throws ParseException
tokenTypes.
null iff none matches
ParseException
public AbstractScanner.Token<TT> read()
throws ParseException
ParseException - The scanner is at end-of-input
public java.lang.String read(TT tokenType)
throws ParseException
ParseException - The next token's type is not tokenType
ParseException - The scanner is at end-of-input
public void read(java.lang.String text)
throws ParseException
ParseException - The next token's text does not equal text
ParseException - The scanner is at end-of-inputeoi()
public int read(java.lang.Object... tokenTypeOrText)
throws ParseException
tokenTypeOrText which equals either the next token's
type or text
ParseException - Neither the next token's type nor its text equals any of tokenTypeOrText
ParseException - The scanner is at end-of-input
public void eoi()
throws ParseException
ParseException - Iff the scanner is not at end-of-input
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||