1 package antlr; 2 3 9 10 class RuleRefElement extends AlternativeElement { 11 protected String targetRule; protected String args = null; protected String idAssign = null; protected String label; 15 16 17 public RuleRefElement(Grammar g, Token t, int autoGenType_) { 18 super(g, t, autoGenType_); 19 targetRule = t.getText(); 20 if (t.type == ANTLRTokenTypes.TOKEN_REF) { targetRule = CodeGenerator.encodeLexerRuleName(targetRule); 23 } 24 } 25 26 35 public void generate() { 36 grammar.generator.gen(this); 37 } 38 39 public String getArgs() { 40 return args; 41 } 42 43 public String getIdAssign() { 44 return idAssign; 45 } 46 47 public String getLabel() { 48 return label; 49 } 50 51 public Lookahead look(int k) { 52 return grammar.theLLkAnalyzer.look(k, this); 53 } 54 55 public void setArgs(String a) { 56 args = a; 57 } 58 59 public void setIdAssign(String id) { 60 idAssign = id; 61 } 62 63 public void setLabel(String label_) { 64 label = label_; 65 } 66 67 public String toString() { 68 if (args != null) 69 return " " + targetRule + args; 70 else 71 return " " + targetRule; 72 } 73 } 74 | Popular Tags |