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: import java.util.Hashtable;
10:
11: /** Intermediate data class holds information about an alternative */
12: class Alternative {
13: // Tracking alternative linked list
14: AlternativeElement head; // head of alt element list
15: AlternativeElement tail; // last element added
16:
17: // Syntactic predicate block if non-null
18: protected SynPredBlock synPred;
19: // Semantic predicate action if non-null
20: protected String semPred;
21: // Exception specification if non-null
22: protected ExceptionSpec exceptionSpec;
23: // Init action if non-null;
24: protected Lookahead[] cache; // lookahead for alt. Filled in by
25: // deterministic() only!!!!!!! Used for
26: // code gen after calls to deterministic()
27: // and used by deterministic for (...)*, (..)+,
28: // and (..)? blocks. 1..k
29: protected int lookaheadDepth; // each alt has different look depth possibly.
30: // depth can be NONDETERMINISTIC too.
31: // 0..n-1
32: // If non-null, Tree specification ala -> A B C (not implemented)
33: protected Token treeSpecifier = null;
34: // True of AST generation is on for this alt
35: private boolean doAutoGen;
36:
37: public Alternative() {
38: }
39:
40: public Alternative(AlternativeElement firstElement) {
41: addElement(firstElement);
42: }
43:
44: public void addElement(AlternativeElement e) {
45: // Link the element into the list
46: if (head == null) {
47: head = tail = e;
48: } else {
49: tail.next = e;
50: tail = e;
51: }
52: }
53:
54: public boolean atStart() {
55: return head == null;
56: }
57:
58: public boolean getAutoGen() {
59: // Don't build an AST if there is a tree-rewrite-specifier
60: return doAutoGen && treeSpecifier == null;
61: }
62:
63: public Token getTreeSpecifier() {
64: return treeSpecifier;
65: }
66:
67: public void setAutoGen(boolean doAutoGen_) {
68: doAutoGen = doAutoGen_;
69: }
70: }
|