forked from jasder/antlr
Extract checkCondition helper method
This commit is contained in:
parent
21ac9a3ebe
commit
6a9a6f7e50
|
@ -301,50 +301,46 @@ public abstract class ATNSimulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state instanceof PlusBlockStartState) {
|
if (state instanceof PlusBlockStartState) {
|
||||||
if (((PlusBlockStartState)state).loopBackState == null) {
|
checkCondition(((PlusBlockStartState)state).loopBackState != null);
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state instanceof StarLoopEntryState) {
|
if (state instanceof StarLoopEntryState) {
|
||||||
if (((StarLoopEntryState)state).loopBackState == null) {
|
checkCondition(((StarLoopEntryState)state).loopBackState != null);
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state instanceof LoopEndState) {
|
if (state instanceof LoopEndState) {
|
||||||
if (((LoopEndState)state).loopBackState == null) {
|
checkCondition(((LoopEndState)state).loopBackState != null);
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state instanceof RuleStartState) {
|
if (state instanceof RuleStartState) {
|
||||||
if (((RuleStartState)state).stopState == null) {
|
checkCondition(((RuleStartState)state).stopState != null);
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state instanceof BlockStartState) {
|
if (state instanceof BlockStartState) {
|
||||||
if (((BlockStartState)state).endState == null) {
|
checkCondition(((BlockStartState)state).endState != null);
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state instanceof BlockEndState) {
|
if (state instanceof BlockEndState) {
|
||||||
if (((BlockEndState)state).startState == null) {
|
checkCondition(((BlockEndState)state).startState != null);
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state instanceof DecisionState) {
|
if (state instanceof DecisionState) {
|
||||||
DecisionState decisionState = (DecisionState)state;
|
DecisionState decisionState = (DecisionState)state;
|
||||||
if (decisionState.getNumberOfTransitions() > 1 && decisionState.decision < 0) {
|
checkCondition(decisionState.getNumberOfTransitions() <= 1 || decisionState.decision >= 0);
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void checkCondition(boolean condition) {
|
||||||
|
checkCondition(condition, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkCondition(boolean condition, String message) {
|
||||||
|
if (!condition) {
|
||||||
|
throw new IllegalStateException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int toInt(char c) {
|
public static int toInt(char c) {
|
||||||
return c==65535 ? -1 : c;
|
return c==65535 ? -1 : c;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue