1 package persistence.antlr; 2 3 8 9 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, 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 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 label_) { 38 label = label_; 39 } 40 41 public String toString() { 42 if (label != null) { 43 return " " + label + ":" + beginText + ".." + endText; 44 } 45 else { 46 return " " + beginText + ".." + endText; 47 } 48 } 49 } 50 | Popular Tags |