All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jeco.core.util.bnf.Rule Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy