1	package antlr;
2	
3	/**
4	 * <b>SOFTWARE RIGHTS</b>
5	 * <p>
6	 * ANTLR 2.5.0 MageLang Institute, 1998
7	 * <p>
8	 * We reserve no legal rights to the ANTLR--it is fully in the
9	 * public domain. An individual or company may do whatever
10	 * they wish with source code distributed with ANTLR or the
11	 * code generated by ANTLR, including the incorporation of
12	 * ANTLR, or its output, into commerical software.
13	 * <p>
14	 * We encourage users to develop software with ANTLR. However,
15	 * we do ask that credit is given to us for developing
16	 * ANTLR. By "credit", we mean that if you use ANTLR or
17	 * incorporate any source code into one of your programs
18	 * (commercial product, research project, or otherwise) that
19	 * you acknowledge this fact somewhere in the documentation,
20	 * research report, etc... If you like ANTLR and have
21	 * developed a nice tool with the output, please mention that
22	 * you developed it using ANTLR. In addition, we ask that the
23	 * headers remain intact in our source code. As long as these
24	 * guidelines are kept, we expect to continue enhancing this
25	 * system and expect to make other tools available as they are
26	 * completed.
27	 * <p>
28	 * The ANTLR gang:
29	 * @version ANTLR 2.5.0 MageLang Institute, 1998
30	 * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
31	 * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
32	 */
33	import antlr.collections.AST;
34	
35	/** ASTPair:  utility class used for manipulating a pair of ASTs
36	  * representing the current AST root and current AST sibling.
37	  * This exists to compensate for the lack of pointers or 'var'
38	  * arguments in Java.
39	  */
40	public class ASTPair {
41		public AST root;		// current root of tree
42		public AST child;		// current child to which siblings are added
43	
44	
45		/** Make sure that child is the last sibling */
46		public final void advanceChildToEnd() {
47			if (child != null) {
48				while (child.getNextSibling() != null) {
49					child = child.getNextSibling();
50				}
51			}
52		}
53		/** Copy an ASTPair.  Don't call it clone() because we want type-safety */
54		public ASTPair copy() {
55			ASTPair tmp = new ASTPair();
56			tmp.root = root;
57			tmp.child = child;
58			return tmp;
59		}
60	public String toString() {
61		String r = root==null ? "null" : root.getText();
62		String c = child==null ? "null" : child.getText();
63		return "["+r+","+c+"]";
64	}
65	}
66