3 /* ANTLR Translator Generator
4 * Project led by Terence Parr at http://www.jGuru.com
5 * Software rights: http://www.antlr.org/license.html
9 // ANTLR C# Code Generator by Micheal Jordan
10 // Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com
11 // Anthony Oguntimehin
15 using StringBuilder
= System
.Text
.StringBuilder
;
16 using AST
= antlr
.collections
.AST
;
18 public abstract class ParseTree
: BaseAST
21 /// Walk parse tree and return requested number of derivation steps.
22 /// If steps less-than 0, return node text. If steps equals 1, return derivation
25 /// <param name="step">derivation steps</param>
26 /// <returns></returns>
27 public string getLeftmostDerivationStep(int step
)
33 StringBuilder buf
= new StringBuilder (2000);
34 getLeftmostDerivation(buf
, step
);
35 return buf
.ToString();
38 public string getLeftmostDerivation(int maxSteps
)
40 StringBuilder buf
= new StringBuilder(2000);
41 buf
.Append(" " + this.ToString());
43 for (int d
=1; d
< maxSteps
; d
++)
46 buf
.Append(getLeftmostDerivationStep(d
));
49 return buf
.ToString();
53 /// Get derivation and return how many you did (less than requested for
56 /// <param name="buf">string buffer</param>
57 /// <param name="step">derivation steps</param>
58 /// <returns></returns>
59 protected internal abstract int getLeftmostDerivation(StringBuilder buf
, int step
);
61 // just satisfy BaseAST interface; unused as we manually create nodes
63 public override void initialize(int i
, string s
)
67 public override void initialize(AST ast
)
71 public override void initialize(IToken token
)