01: package persistence.antlr;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.jGuru.com
05: * Software rights: http://www.antlr.org/license.html
06: *
07: */
08:
09: class TokenRangeElement extends AlternativeElement {
10: String label;
11: protected int begin = Token.INVALID_TYPE;
12: protected int end = Token.INVALID_TYPE;
13: protected String beginText;
14: protected String endText;
15:
16: public TokenRangeElement(Grammar g, Token t1, Token t2,
17: int autoGenType) {
18: super (g, t1, autoGenType);
19: begin = grammar.tokenManager.getTokenSymbol(t1.getText())
20: .getTokenType();
21: beginText = t1.getText();
22: end = grammar.tokenManager.getTokenSymbol(t2.getText())
23: .getTokenType();
24: endText = t2.getText();
25: line = t1.getLine();
26: }
27:
28: public void generate() {
29: grammar.generator.gen(this );
30: }
31:
32: public String getLabel() {
33: return label;
34: }
35:
36: public Lookahead look(int k) {
37: return grammar.theLLkAnalyzer.look(k, this );
38: }
39:
40: public void setLabel(String label_) {
41: label = label_;
42: }
43:
44: public String toString() {
45: if (label != null) {
46: return " " + label + ":" + beginText + ".." + endText;
47: } else {
48: return " " + beginText + ".." + endText;
49: }
50: }
51: }
|