1	package antlr;
2	
3	/**
4	 * <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	import java.util.Hashtable;
34	
35	/** Intermediate data class holds information about an alternative */
36	class Alternative {
37		// Tracking alternative linked list
38		AlternativeElement head;   // head of alt element list
39		AlternativeElement tail;  // last element added
40	
41		// Syntactic predicate block if non-null
42		protected SynPredBlock synPred;
43		// Semantic predicate action if non-null
44		protected String semPred;
45		// Exception specification if non-null
46		protected ExceptionSpec exceptionSpec;
47		// Init action if non-null;
48		protected Lookahead[] cache;	// lookahead for alt.  Filled in by
49										// deterministic() only!!!!!!!  Used for
50										// code gen after calls to deterministic()
51										// and used by deterministic for (...)*, (..)+,
52										// and (..)? blocks.  1..k
53		protected int lookaheadDepth;	// each alt has different look depth possibly.
54										// depth can be NONDETERMINISTIC too.
55										// 0..n-1
56		// If non-null, Tree specification ala -> A B C (not implemented)
57		protected Token treeSpecifier = null;
58		// True of AST generation is on for this alt
59		private boolean doAutoGen;
60	
61	
62		public Alternative() {
63		}
64		public Alternative(AlternativeElement firstElement) {
65			addElement(firstElement);
66		}
67		public void addElement(AlternativeElement e)
68		{
69			// Link the element into the list
70			if ( head == null ) {
71				head = tail = e;
72			}
73			else {
74				tail.next = e;
75				tail = e;
76			}
77		}
78		public boolean atStart() { return head == null; }
79		public boolean getAutoGen() { 
80			// Don't build an AST if there is a tree-rewrite-specifier
81			return doAutoGen && treeSpecifier == null; 
82		}
83		public Token getTreeSpecifier() {
84			return treeSpecifier;
85		}
86		public void setAutoGen(boolean doAutoGen_) {
87			doAutoGen = doAutoGen_;
88		}
89	}
90