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 CharRangeElement extends AlternativeElement {
10: String label;
11: protected char begin = 0;
12: protected char end = 0;
13: protected String beginText;
14: protected String endText;
15:
16: public CharRangeElement(LexerGrammar g, Token t1, Token t2,
17: int autoGenType) {
18: super (g);
19: begin = (char) ANTLRLexer.tokenTypeForCharLiteral(t1.getText());
20: beginText = t1.getText();
21: end = (char) ANTLRLexer.tokenTypeForCharLiteral(t2.getText());
22: endText = t2.getText();
23: line = t1.getLine();
24: // track which characters are referenced in the grammar
25: for (int i = begin; i <= end; i++) {
26: g.charVocabulary.add(i);
27: }
28: this .autoGenType = autoGenType;
29: }
30:
31: public void generate() {
32: grammar.generator.gen(this );
33: }
34:
35: public String getLabel() {
36: return label;
37: }
38:
39: public Lookahead look(int k) {
40: return grammar.theLLkAnalyzer.look(k, this );
41: }
42:
43: public void setLabel(String label_) {
44: label = label_;
45: }
46:
47: public String toString() {
48: if (label != null)
49: return " " + label + ":" + beginText + ".." + endText;
50: else
51: return " " + beginText + ".." + endText;
52: }
53: }
|