KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > BlockContext


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/BlockContext.java#4 $
8  */

9
10 /**BlockContext stores the information needed when creating an
11  * alternative (list of elements). Entering a subrule requires
12  * that we save this state as each block of alternatives
13  * requires state such as "tail of current alternative."
14  */

15 class BlockContext {
16     AlternativeBlock block; // current block of alternatives
17
int altNum; // which alt are we accepting 0..n-1
18
BlockEndElement blockEnd; // used if nested
19

20
21     public void addAlternativeElement(AlternativeElement e) {
22         currentAlt().addElement(e);
23     }
24
25     public Alternative currentAlt() {
26         return (Alternative)block.alternatives.elementAt(altNum);
27     }
28
29     public AlternativeElement currentElement() {
30         return currentAlt().tail;
31     }
32 }
33
Popular Tags