Another fix for non-greedy with closures

This commit is contained in:
Sam Harwell 2012-10-16 07:46:46 -05:00
parent f9a63b8810
commit fb87e4c785
2 changed files with 8 additions and 4 deletions

View File

@ -639,7 +639,9 @@ public class LexerATNSimulator extends ATNSimulator {
break;
case ATNState.STAR_LOOP_BACK:
config = config.exitNonGreedyBlock();
if (((StarLoopbackState)p).getLoopEntryState().nonGreedy) {
config = config.exitNonGreedyBlock();
}
break;
case ATNState.LOOP_END:
@ -650,9 +652,8 @@ public class LexerATNSimulator extends ATNSimulator {
}
}
else {
assert loopBackState instanceof StarLoopbackState;
ATNState loopEntry = loopBackState.transition(0).target;
if (loopEntry instanceof StarLoopEntryState && ((StarLoopEntryState)loopEntry).nonGreedy) {
StarLoopbackState starLoopbackState = (StarLoopbackState)loopBackState;
if (starLoopbackState.getLoopEntryState().nonGreedy) {
config = config.exitNonGreedyBlock();
}
}

View File

@ -30,4 +30,7 @@
package org.antlr.v4.runtime.atn;
public class StarLoopbackState extends ATNState {
public final StarLoopEntryState getLoopEntryState() {
return (StarLoopEntryState)transition(0).target;
}
}