4 using Queue
= System
.Collections
.Queue
;
5 using AST
= antlr
.collections
.AST
;
7 /*ANTLR Translator Generator
8 * Project led by Terence Parr at http://www.jGuru.com
9 * Software rights: http://www.antlr.org/license.html
15 // ANTLR C# Code Generator by Micheal Jordan
16 // Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com
17 // Anthony Oguntimehin
19 // With many thanks to Eric V. Smith from the ANTLR list.
23 /*ASTPair: utility class used for manipulating a pair of ASTs
24 * representing the current AST root and current AST sibling.
25 * This exists to compensate for the lack of pointers or 'var'
31 static private Queue instancePool_
= new Queue();
33 static public ASTPair
GetInstance()
35 if (instancePool_
.Count
> 0)
37 return (ASTPair
) instancePool_
.Dequeue();
42 static public void PutInstance(ASTPair p
)
47 instancePool_
.Enqueue(p
);
51 public AST root
; // current root of tree
52 public AST child
; // current child to which siblings are added
54 /*Make sure that child is the last sibling */
55 public void advanceChildToEnd()
59 while (child
.getNextSibling() != null)
61 child
= child
.getNextSibling();
66 /*Copy an ASTPair. Don't call it clone() because we want type-safety */
67 public virtual ASTPair
copy()
69 ASTPair tmp
= ASTPair
.GetInstance();
81 override public string ToString()
83 string r
= (root
== null) ? "null" : root
.getText();
84 string c
= (child
== null) ? "null" : child
.getText();
85 return "[" + r
+ "," + c
+ "]";