KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > RuleSymbol


1 package antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/RIGHTS.html
6  *
7  * $Id: //depot/code/org.antlr/main/main/antlr/RuleSymbol.java#4 $
8  */

9
10 import antlr.collections.impl.Vector;
11
12 class RuleSymbol extends GrammarSymbol {
13     RuleBlock block; // list of alternatives
14
boolean defined; // has the rule been defined yet?
15
Vector references; // list of all nodes referencing this rule
16
// not strictly needed by generic symbol table
17
// but we will almost always analyze/gen code
18
String JavaDoc access; // access specifier for this rule
19
String JavaDoc comment; // A javadoc comment if any.
20

21     public RuleSymbol(String JavaDoc r) {
22         super(r);
23         references = new Vector();
24     }
25
26     public void addReference(RuleRefElement e) {
27         references.appendElement(e);
28     }
29
30     public RuleBlock getBlock() {
31         return block;
32     }
33
34     public RuleRefElement getReference(int i) {
35         return (RuleRefElement)references.elementAt(i);
36     }
37
38     public boolean isDefined() {
39         return defined;
40     }
41
42     public int numReferences() {
43         return references.size();
44     }
45
46     public void setBlock(RuleBlock rb) {
47         block = rb;
48     }
49
50     public void setDefined() {
51         defined = true;
52     }
53 }
54
Popular Tags