|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Symbol<P extends Processor>
Interface of classes representing a symbol. A fluent interface API is
supported by the methods followedBy(Symbol),
oneOrMoreTimes(), optional(), or(Symbol),
zeroOrMoreTimes(), and zeroOrMoreTimesSeparatedBy(Symbol).
Implementations should extend AbstractSymbol to
fulfill the contract of process(TokenIterator, Processor).
AbstractSymbol also implements the methods of the fluent interface
API.
| Method Summary | |
|---|---|
Symbol<P> |
followedBy(Symbol<P> symbol)
Returns a symbol which assumes this symbol followed by the specified symbol. |
MatchingResult |
matches(Token token)
Returns true if the specified token matches. |
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 more tokens consumed from the specified iterator by using the specified processor. |
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. |
| Method Detail |
|---|
MatchingResult matches(Token token)
true if the specified token matches.
token - Token to be checked. Will be null if beyond last
token.
void process(TokenIterator iterator,
P processor)
throws ParsingException
Implementation have to call matches(Token) first with
iterator.currentToken() as argument. If the matching result
isn't successful a ParsingException has to be thrown which contains
the failure reason.
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.Symbol<P> optional()
Symbol<P> zeroOrMoreTimes()
Symbol<P> oneOrMoreTimes()
Symbol<P> zeroOrMoreTimesSeparatedBy(Symbol<P> delimiter)
Symbol<P> or(Symbol<P> symbol)
Symbol<P> followedBy(Symbol<P> symbol)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||