KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > CommonAST


1 package antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/RIGHTS.html
6  *
7  * $Id: //depot/code/org.antlr/main/main/antlr/CommonAST.java#4 $
8  */

9
10 import antlr.collections.AST;
11
12 /** Common AST node implementation */
13 public class CommonAST extends BaseAST {
14     int ttype = Token.INVALID_TYPE;
15     String JavaDoc text;
16
17
18     /** Get the token text for this node */
19     public String JavaDoc getText() {
20         return text;
21     }
22
23     /** Get the token type for this node */
24     public int getType() {
25         return ttype;
26     }
27
28     public void initialize(int t, String JavaDoc txt) {
29         setType(t);
30         setText(txt);
31     }
32
33     public void initialize(AST t) {
34         setText(t.getText());
35         setType(t.getType());
36     }
37
38     public CommonAST() {
39     }
40
41     public CommonAST(Token tok) {
42         initialize(tok);
43     }
44
45     public void initialize(Token tok) {
46         setText(tok.getText());
47         setType(tok.getType());
48     }
49
50     /** Set the token text for this node */
51     public void setText(String JavaDoc text_) {
52         text = text_;
53     }
54
55     /** Set the token type for this node */
56     public void setType(int ttype_) {
57         ttype = ttype_;
58     }
59 }
60
Popular Tags