KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > TokenRangeElement


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 class TokenRangeElement extends AlternativeElement {
10     String JavaDoc label;
11     protected int begin = Token.INVALID_TYPE;
12     protected int end = Token.INVALID_TYPE;
13     protected String JavaDoc beginText;
14     protected String JavaDoc endText;
15
16     public TokenRangeElement(Grammar g, Token t1, Token t2, int autoGenType) {
17         super(g, t1, autoGenType);
18         begin = grammar.tokenManager.getTokenSymbol(t1.getText()).getTokenType();
19         beginText = t1.getText();
20         end = grammar.tokenManager.getTokenSymbol(t2.getText()).getTokenType();
21         endText = t2.getText();
22         line = t1.getLine();
23     }
24
25     public void generate() {
26         grammar.generator.gen(this);
27     }
28
29     public String JavaDoc getLabel() {
30         return label;
31     }
32
33     public Lookahead look(int k) {
34         return grammar.theLLkAnalyzer.look(k, this);
35     }
36
37     public void setLabel(String JavaDoc label_) {
38         label = label_;
39     }
40
41     public String JavaDoc toString() {
42         if (label != null) {
43             return " " + label + ":" + beginText + ".." + endText;
44         }
45         else {
46             return " " + beginText + ".." + endText;
47         }
48     }
49 }
50
Popular Tags