01: package org.antlr.analysis;
02:
03: import org.antlr.misc.Barrier;
04: import org.antlr.tool.Grammar;
05: import org.antlr.tool.ErrorManager;
06:
07: /** Convert all decisions i..j inclusive in a thread */
08: public class NFAConversionThread implements Runnable {
09: Grammar grammar;
10: int i, j;
11: Barrier barrier;
12:
13: public NFAConversionThread(Grammar grammar, Barrier barrier, int i,
14: int j) {
15: this .grammar = grammar;
16: this .barrier = barrier;
17: this .i = i;
18: this .j = j;
19: }
20:
21: public void run() {
22: for (int decision = i; decision <= j; decision++) {
23: NFAState decisionStartState = grammar
24: .getDecisionNFAStartState(decision);
25: if (decisionStartState.getNumberOfTransitions() > 1) {
26: grammar.createLookaheadDFA(decision);
27: }
28: }
29: // now wait for others to finish
30: try {
31: barrier.waitForRelease();
32: } catch (InterruptedException e) {
33: ErrorManager.internalError(
34: "what the hell? DFA interruptus", e);
35: }
36: }
37: }
|