jeco.core.util.bnf.Rule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jeco-core Show documentation
Show all versions of jeco-core Show documentation
Java Evolutionary COmputation library
The newest version!
package jeco.core.util.bnf;
import java.util.ArrayList;
public class Rule extends ArrayList {
private static final long serialVersionUID = 1L;
//Variables
protected boolean recursive = false;// Recursive nature of rule
protected int minimumDepth = Integer.MAX_VALUE>>1; // Minimum depth of parse tree for production to map to terminal symbol(s)
protected Symbol lhs = null; //Left hand side symbol of the rule
public Rule(){
super();
}
public Rule clone() {
Rule clone = new Rule();
for(Production production : this) {
clone.add(production.clone());
}
clone.lhs = this.lhs.clone();
clone.recursive = this.recursive;
clone.minimumDepth = this.minimumDepth;
return clone;
}
@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(lhs.symbolString);
buffer.append("::=");
for(int i=0;i