net.sf.parcinj
Class TerminalSymbolByType<P extends Processor>

java.lang.Object
  extended by net.sf.parcinj.AbstractSymbol<P>
      extended by net.sf.parcinj.TerminalSymbol<P>
          extended by net.sf.parcinj.TerminalSymbolByType<P>
All Implemented Interfaces:
Symbol<P>

public class TerminalSymbolByType<P extends Processor>
extends TerminalSymbol<P>

Terminal symbol specified by a TokenType.


Constructor Summary
TerminalSymbolByType(TokenType tokenType)
          Creates an instance for the specified token type.
 
Method Summary
protected  java.lang.String createFailure(TokenType expectedType)
          Returns failure text for the specified token type.
 MatchingResult matches(Token token)
          Returns MatchingResult.OK if the specified token is not null and it is of equal type as specified in the constructor.
 
Methods inherited from class net.sf.parcinj.TerminalSymbol
doProcess, process
 
Methods inherited from class net.sf.parcinj.AbstractSymbol
followedBy, oneOrMoreTimes, optional, or, process, zeroOrMoreTimes, zeroOrMoreTimesSeparatedBy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TerminalSymbolByType

public TerminalSymbolByType(TokenType tokenType)
Creates an instance for the specified token type.

Parameters:
tokenType -
Method Detail

matches

public MatchingResult matches(Token token)
Returns MatchingResult.OK if the specified token is not null and it is of equal type as specified in the constructor.

Parameters:
token - Token to be checked. Will be null if beyond last token.

createFailure

protected java.lang.String createFailure(TokenType expectedType)
Returns failure text for the specified token type. It appears in the failure reason of MatchingResult returned by matches(Token). Should be overridden by subclasses in order to get more meaningful failure message than 'Not a token of type <token type>'.