Fix optimizer incorrectly removing predicate transitions from the ATN (fixes #588)

This commit is contained in:
Sam Harwell 2014-06-10 16:32:01 -05:00
parent e4fa8f75d4
commit 9e7b13105d
1 changed files with 2 additions and 2 deletions

View File

@ -32,8 +32,8 @@ package org.antlr.v4.automata;
import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNState;
import org.antlr.v4.runtime.atn.ActionTransition;
import org.antlr.v4.runtime.atn.BlockEndState;
import org.antlr.v4.runtime.atn.EpsilonTransition;
import org.antlr.v4.runtime.atn.PlusLoopbackState;
import org.antlr.v4.runtime.atn.RuleTransition;
import org.antlr.v4.runtime.atn.StarLoopbackState;
@ -64,7 +64,7 @@ public class TailEpsilonRemover extends ATNVisitor {
// if edge out of q is single epsilon to block end
// we can strip epsilon p-x->q-eps->r
Transition trans = q.transition(0);
if (q.getNumberOfTransitions() == 1 && trans.isEpsilon() && !(trans instanceof ActionTransition)) {
if (q.getNumberOfTransitions() == 1 && trans instanceof EpsilonTransition) {
ATNState r = trans.target;
if (r instanceof BlockEndState || r instanceof PlusLoopbackState || r instanceof StarLoopbackState) {
// skip over q