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 RuleRefElement extends AlternativeElement {
10: protected String targetRule; // which rule is being called?
11: protected String args = null; // were any args passed to rule?
12: protected String idAssign = null; // is the return type assigned to a variable?
13: protected String label;
14:
15: public RuleRefElement(Grammar g, Token t, int autoGenType_) {
16: super (g, t, autoGenType_);
17: targetRule = t.getText();
18: // if ( Character.isUpperCase(targetRule.charAt(0)) ) { // lexer rule?
19: if (t.type == ANTLRTokenTypes.TOKEN_REF) { // lexer rule?
20: targetRule = CodeGenerator.encodeLexerRuleName(targetRule);
21: }
22: }
23:
24: // public RuleRefElement(Grammar g, String t, int line, int autoGenType_) {
25: // super(g, autoGenType_);
26: // targetRule = t;
27: // if ( Character.isUpperCase(targetRule.charAt(0)) ) { // lexer rule?
28: // targetRule = CodeGenerator.lexerRuleName(targetRule);
29: // }
30: // this.line = line;
31: // }
32:
33: public void generate() {
34: grammar.generator.gen(this );
35: }
36:
37: public String getArgs() {
38: return args;
39: }
40:
41: public String getIdAssign() {
42: return idAssign;
43: }
44:
45: public String getLabel() {
46: return label;
47: }
48:
49: public Lookahead look(int k) {
50: return grammar.theLLkAnalyzer.look(k, this );
51: }
52:
53: public void setArgs(String a) {
54: args = a;
55: }
56:
57: public void setIdAssign(String id) {
58: idAssign = id;
59: }
60:
61: public void setLabel(String label_) {
62: label = label_;
63: }
64:
65: public String toString() {
66: if (args != null)
67: return " " + targetRule + args;
68: else
69: return " " + targetRule;
70: }
71: }
|