From 125a509e4e389d839a67254844c73d5a74f1e49e Mon Sep 17 00:00:00 2001 From: parrt Date: Thu, 17 Nov 2016 12:41:32 -0800 Subject: [PATCH] Fixes #1369 by removing any redundant edges. --- .../org/antlr/v4/runtime/atn/ATNState.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNState.java index 58f2fb4cb..86d4f1f72 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNState.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNState.java @@ -192,18 +192,20 @@ public abstract class ATNState { } boolean alreadyPresent = false; -// for (Transition t : transitions) { -// if ( t.target.stateNumber == e.target.stateNumber ) { -// if ( t.label()!=null && e.label()!=null && t.label().equals(e.label()) ) { + for (Transition t : transitions) { + if ( t.target.stateNumber == e.target.stateNumber ) { + if ( t.label()!=null && e.label()!=null && t.label().equals(e.label()) ) { // System.err.println("Repeated transition upon "+e.label()+" from "+stateNumber+"->"+t.target.stateNumber); -// alreadyPresent = true; -// } -// else if ( t.isEpsilon() && e.isEpsilon() ) { + alreadyPresent = true; + break; + } + else if ( t.isEpsilon() && e.isEpsilon() ) { // System.err.println("Repeated epsilon transition from "+stateNumber+"->"+t.target.stateNumber); -// alreadyPresent = true; -// } -// } -// } + alreadyPresent = true; + break; + } + } + } if ( !alreadyPresent ) { transitions.add(index, e); }