Last change
on this file since 1 was
1,
checked in by lnalod, 15 years ago
|
Initial import of YAO sources
|
File size:
1.2 KB
|
Line | |
---|
1 | package antlr; |
---|
2 | |
---|
3 | /* ANTLR Translator Generator |
---|
4 | * Project led by Terence Parr at http://www.cs.usfca.edu |
---|
5 | * Software rights: http://www.antlr.org/license.html |
---|
6 | * |
---|
7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CommonAST.java#2 $ |
---|
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 text; |
---|
16 | |
---|
17 | |
---|
18 | /** Get the token text for this node */ |
---|
19 | public String 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 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 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 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.