KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > CommonAST


1 package persistence.antlr;
2
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  *
7  */

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