org.naturalcli
Class Syntax

java.lang.Object
  extended by org.naturalcli.Syntax

public class Syntax
extends java.lang.Object

Implements a class with a syntax definition and parser.

Author:
Ferran Busquets

Constructor Summary
Syntax(java.lang.String definition)
          Constructor for the Syntax class
 
Method Summary
 java.lang.String getDefinition()
          Gets the syntax definition
 ParseResult parse(java.lang.String[] candidates, int first, ParameterValidator pv)
          Parse the tokens to see if match with the syntax
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Syntax

public Syntax(java.lang.String definition)
       throws InvalidSyntaxException
Constructor for the Syntax class

Parameters:
definition - the syntax definition
Throws:
InvalidSyntaxException
Method Detail

getDefinition

public java.lang.String getDefinition()
Gets the syntax definition

Returns:
the definition

parse

public ParseResult parse(java.lang.String[] candidates,
                         int first,
                         ParameterValidator pv)
                  throws UnknownParameterType
Parse the tokens to see if match with the syntax

Parameters:
candidates - the candidate tokens to match
first - the first item in the tokens list
pv - the parameter validator
Returns:
null if the candidate does not match, or a ParseData object
Throws:
UnknownParameterType
See Also:
ParseResult

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object