|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.parcinj.AbstractSymbol<P>
public abstract class AbstractSymbol<P extends Processor>
Abstract super class which implements
Symbol.process(TokenIterator, Processor)
according to the contract.
Subclasses have to implement Symbol.matches(Token)
and
doProcess(TokenIterator, Processor)
.
In addition the methods of the fluent interface API are implemented.
It is recommended to extend this class when introducing a new Symbol
.
Constructor Summary | |
---|---|
AbstractSymbol()
|
Method Summary | |
---|---|
protected abstract void |
doProcess(TokenIterator iterator,
P processor)
Processes tokens taken from the specified iterator without initial matching check. |
Symbol<P> |
followedBy(Symbol<P> symbol)
Returns a symbol which assumes this symbol followed by the specified symbol. |
Symbol<P> |
oneOrMoreTimes()
Returns a symbol which allows this symbol to appear one or more times. |
Symbol<P> |
optional()
Returns a symbol which allows this symbol to be optional. |
Symbol<P> |
or(Symbol<P> symbol)
Returns a symbol which allows this symbol or the specified symbol to appear. |
void |
process(TokenIterator iterator,
P processor)
Processes zero or many tokens from the specified iterator. |
Symbol<P> |
zeroOrMoreTimes()
Returns a symbol which allows this symbol to appear zero or more times. |
Symbol<P> |
zeroOrMoreTimesSeparatedBy(Symbol<P> delimiter)
Returns a symbol which assumes this symbol to appear zero or more times separated by the specified delimiter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.parcinj.Symbol |
---|
matches |
Constructor Detail |
---|
public AbstractSymbol()
Method Detail |
---|
public final void process(TokenIterator iterator, P processor) throws ParsingException
Symbol.matches(Token)
is invoked for the current token. If it fails
a ParsingException
is thrown. Otherwise
doProcess(TokenIterator, Processor)
is invoked. All throwables
(except ParsingException
) thrown by this method are wrap by a
ParsingException
.
process
in interface Symbol<P extends Processor>
ParsingException
- if the tokens delivered by the iterator are not as expected
or processor
throws an exception which should
the cause of the thrown exception.protected abstract void doProcess(TokenIterator iterator, P processor) throws ParsingException
processor
- Processor
who does the actual processing.
ParsingException
- if a parsing error occurs.public Symbol<P> optional()
Symbol
optional
in interface Symbol<P extends Processor>
public Symbol<P> zeroOrMoreTimes()
Symbol
zeroOrMoreTimes
in interface Symbol<P extends Processor>
public Symbol<P> oneOrMoreTimes()
Symbol
oneOrMoreTimes
in interface Symbol<P extends Processor>
public Symbol<P> zeroOrMoreTimesSeparatedBy(Symbol<P> delimiter)
Symbol
zeroOrMoreTimesSeparatedBy
in interface Symbol<P extends Processor>
public Symbol<P> or(Symbol<P> symbol)
Symbol
or
in interface Symbol<P extends Processor>
public Symbol<P> followedBy(Symbol<P> symbol)
Symbol
followedBy
in interface Symbol<P extends Processor>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |