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