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: /**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: public void addAlternativeElement(AlternativeElement e) {
20: currentAlt().addElement(e);
21: }
22:
23: public Alternative currentAlt() {
24: return (Alternative) block.alternatives.elementAt(altNum);
25: }
26:
27: public AlternativeElement currentElement() {
28: return currentAlt().tail;
29: }
30: }
|