1 package persistence.antlr; 2 3 7 8 import persistence.antlr.*; 9 import persistence.antlr.collections.AST; 10 11 public abstract class ParseTree extends BaseAST { 12 13 17 public String getLeftmostDerivationStep(int step) { 18 if ( step<=0 ) { 19 return toString(); 20 } 21 StringBuffer buf = new StringBuffer (2000); 22 getLeftmostDerivation(buf, step); 23 return buf.toString(); 24 } 25 26 public String getLeftmostDerivation(int maxSteps) { 27 StringBuffer buf = new StringBuffer (2000); 28 buf.append(" "+this.toString()); 29 buf.append("\n"); 30 for (int d=1; d<maxSteps; d++) { 31 buf.append(" =>"); 32 buf.append(getLeftmostDerivationStep(d)); 33 buf.append("\n"); 34 } 35 return buf.toString(); 36 } 37 38 41 protected abstract int getLeftmostDerivation(StringBuffer buf, int step); 42 43 45 public void initialize(int i, String s) { 46 } 47 public void initialize(AST ast) { 48 } 49 public void initialize(Token token) { 50 } 51 } 52 | Popular Tags |