1 package antlr;
2
3 * <b>SOFTWARE RIGHTS</b>
5 * <p>
6 * ANTLR 2.5.0 MageLang Institute, 1998
7 * <p>
8 * We reserve no legal rights to the ANTLR--it is fully in the
9 * public domain. An individual or company may do whatever
10 * they wish with source code distributed with ANTLR or the
11 * code generated by ANTLR, including the incorporation of
12 * ANTLR, or its output, into commerical software.
13 * <p>
14 * We encourage users to develop software with ANTLR. However,
15 * we do ask that credit is given to us for developing
16 * ANTLR. By "credit", we mean that if you use ANTLR or
17 * incorporate any source code into one of your programs
18 * (commercial product, research project, or otherwise) that
19 * you acknowledge this fact somewhere in the documentation,
20 * research report, etc... If you like ANTLR and have
21 * developed a nice tool with the output, please mention that
22 * you developed it using ANTLR. In addition, we ask that the
23 * headers remain intact in our source code. As long as these
24 * guidelines are kept, we expect to continue enhancing this
25 * system and expect to make other tools available as they are
26 * completed.
27 * <p>
28 * The ANTLR gang:
29 * @version ANTLR 2.5.0 MageLang Institute, 1998
30 * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
31 * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
32 */
33 class RuleRefElement extends AlternativeElement {
34 protected String targetRule; protected String args=null; protected String idAssign=null; protected String label;
38
39
40 public RuleRefElement(Grammar g, Token t, int autoGenType_) {
41 super(g, autoGenType_);
42 targetRule = t.getText();
43 if ( Character.isUpperCase(targetRule.charAt(0)) ) { targetRule = CodeGenerator.lexerRuleName(targetRule);
45 }
46 line = t.getLine();
47 }
48 public RuleRefElement(Grammar g, String t, int line, int autoGenType_) {
49 super(g, autoGenType_);
50 targetRule = t;
51 if ( Character.isUpperCase(targetRule.charAt(0)) ) { targetRule = CodeGenerator.lexerRuleName(targetRule);
53 }
54 this.line = line;
55 }
56 public void generate() {
57 grammar.generator.gen(this);
58 }
59 public String getArgs() {
60 return args;
61 }
62 public String getIdAssign() {
63 return idAssign;
64 }
65 public String getLabel() {
66 return label;
67 }
68 public Lookahead look(int k) {
69 return grammar.theLLkAnalyzer.look(k, this);
70 }
71 public void setArgs(String a) {
72 args = a;
73 }
74 public void setIdAssign(String id) {
75 idAssign = id;
76 }
77 public void setLabel(String label_) {
78 label = label_;
79 }
80 public String toString() {
81 if ( args!=null ) return " "+targetRule+args;
82 else return " "+targetRule;
83 }
84 }
85