01: package antlr;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.cs.usfca.edu
05: * Software rights: http://www.antlr.org/license.html
06: */
07:
08: /**BlockContext stores the information needed when creating an
09: * alternative (list of elements). Entering a subrule requires
10: * that we save this state as each block of alternatives
11: * requires state such as "tail of current alternative."
12: */
13: class BlockContext {
14: AlternativeBlock block; // current block of alternatives
15: int altNum; // which alt are we accepting 0..n-1
16: BlockEndElement blockEnd; // used if nested
17:
18: public void addAlternativeElement(AlternativeElement e) {
19: currentAlt().addElement(e);
20: }
21:
22: public Alternative currentAlt() {
23: return (Alternative) block.alternatives.elementAt(altNum);
24: }
25:
26: public AlternativeElement currentElement() {
27: return currentAlt().tail;
28: }
29: }
|