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