|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectec.gp.ge.GrammarParser
public class GrammarParser
A GrammarParser is the basic class for parsing a GE ruleset into a parse graph of GrammarNodes. This parse graph is then later used to produce a GPIndividual from a GEIndividual in GESpecies. It is assumed that the root will represent the first rule given in the grammar.
Field Summary | |
---|---|
protected static int |
BOOLEAN_CONSTANT
|
protected static int |
COMMENT
|
static java.lang.String[] |
DEFAULT_REGEXES
The default regular expressions for tokens in the parser. |
protected static int |
EQUALS
|
protected static int |
FUNCTION
|
protected static int |
LPAREN
|
protected static int |
NUMERIC_CONSTANT
|
static java.lang.String |
P_PARSER
|
protected static int |
PIPE
|
protected static int |
RPAREN
|
protected static int |
RULE
|
protected static int |
STRING_CONSTANT
|
Constructor Summary | |
---|---|
GrammarParser()
|
Method Summary | |
---|---|
java.lang.Object |
clone()
Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context. |
Parameter |
defaultBase()
Returns the default base for this prototype. |
java.lang.String[] |
getRegexes()
Returns the regular expressions to use for tokenizing these rules. |
static void |
main(java.lang.String[] args)
A simple testing fcility. |
GrammarRuleNode |
parseRules(EvolutionState state,
java.io.BufferedReader reader,
GPFunctionSet gpfs)
Parses the rules from a grammar and returns the resulting GrammarRuleNode root. |
void |
setup(EvolutionState state,
Parameter base)
Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. |
java.lang.String |
toString()
|
boolean |
validateRules()
Checks that all grammar rules in ruleshashmap have at least one possible production |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String P_PARSER
public static final java.lang.String[] DEFAULT_REGEXES
protected static final int COMMENT
protected static final int LPAREN
protected static final int RPAREN
protected static final int RULE
protected static final int PIPE
protected static final int EQUALS
protected static final int NUMERIC_CONSTANT
protected static final int BOOLEAN_CONSTANT
protected static final int STRING_CONSTANT
protected static final int FUNCTION
Constructor Detail |
---|
public GrammarParser()
Method Detail |
---|
public java.lang.String[] getRegexes()
public Parameter defaultBase()
Prototype
defaultBase
in interface Prototype
public void setup(EvolutionState state, Parameter base)
Prototype
For prototypes, setup(...) is typically called once for the prototype instance; cloned instances do not receive the setup(...) call. setup(...) may be called more than once; the only guarantee is that it will get called at least once on an instance or some "parent" object from which it was ultimately cloned.
setup
in interface Prototype
setup
in interface Setup
public java.lang.Object clone()
Prototype
Typically this should be a full "deep" clone. However, you may share certain elements with other objects rather than clone hem, depending on the situation:
Implementations.
public Object clone()
{
try
{
return super.clone();
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
}
public Object clone()
{
try
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
return myobj;
}
public Object clone()
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
return myobj;
}
clone
in interface Prototype
clone
in class java.lang.Object
public GrammarRuleNode parseRules(EvolutionState state, java.io.BufferedReader reader, GPFunctionSet gpfs)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean validateRules()
public static void main(java.lang.String[] args) throws java.io.FileNotFoundException
java.io.FileNotFoundException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |