Added ability to order the execution of dictionary adapter behaviors.
[castle.git] / Experiments / Attic / Rook / Castle.Rook.Compiler / Parser / antlr / ParseTree.cs
blob594b36967baff3385552431caf8cab83377f8bff
1 namespace antlr
3 /* ANTLR Translator Generator
4 * Project led by Terence Parr at http://www.jGuru.com
5 * Software rights: http://www.antlr.org/license.html
6 */
8 //
9 // ANTLR C# Code Generator by Micheal Jordan
10 // Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com
11 // Anthony Oguntimehin
14 using System;
15 using StringBuilder = System.Text.StringBuilder;
16 using AST = antlr.collections.AST;
18 public abstract class ParseTree : BaseAST
20 /// <summary>
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
23 /// string at step.
24 /// </summary>
25 /// <param name="step">derivation steps</param>
26 /// <returns></returns>
27 public string getLeftmostDerivationStep(int step)
29 if ( step <= 0 )
31 return ToString();
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());
42 buf.Append("\n");
43 for (int d=1; d < maxSteps; d++)
45 buf.Append(" =>");
46 buf.Append(getLeftmostDerivationStep(d));
47 buf.Append("\n");
49 return buf.ToString();
52 /// <summary>
53 /// Get derivation and return how many you did (less than requested for
54 /// subtree roots.
55 /// </summary>
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)