KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > BlockContext


1 package persistence.antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/license.html
6  *
7  */

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

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

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