01: package antlr.collections;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.cs.usfca.edu
05: * Software rights: http://www.antlr.org/license.html
06: */
07:
08: import antlr.Token;
09:
10: /** Minimal AST node interface used by ANTLR AST generation
11: * and tree-walker.
12: */
13: public interface AST {
14: /** Add a (rightmost) child to this node */
15: public void addChild(AST c);
16:
17: public boolean equals(AST t);
18:
19: public boolean equalsList(AST t);
20:
21: public boolean equalsListPartial(AST t);
22:
23: public boolean equalsTree(AST t);
24:
25: public boolean equalsTreePartial(AST t);
26:
27: public ASTEnumeration findAll(AST tree);
28:
29: public ASTEnumeration findAllPartial(AST subtree);
30:
31: /** Get the first child of this node; null if no children */
32: public AST getFirstChild();
33:
34: /** Get the next sibling in line after this one */
35: public AST getNextSibling();
36:
37: /** Get the token text for this node */
38: public String getText();
39:
40: /** Get the token type for this node */
41: public int getType();
42:
43: /** @since 2.7.3 Need for error handling */
44: public int getLine();
45:
46: /** @since 2.7.3 Need for error handling */
47: public int getColumn();
48:
49: /** Get number of children of this node; if leaf, returns 0 */
50: public int getNumberOfChildren();
51:
52: public void initialize(int t, String txt);
53:
54: public void initialize(AST t);
55:
56: public void initialize(Token t);
57:
58: /** Set the first child of a node. */
59: public void setFirstChild(AST c);
60:
61: /** Set the next sibling after this one. */
62: public void setNextSibling(AST n);
63:
64: /** Set the token text for this node */
65: public void setText(String text);
66:
67: /** Set the token type for this node */
68: public void setType(int ttype);
69:
70: public String toString();
71:
72: public String toStringList();
73:
74: public String toStringTree();
75: }
|