diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java index fafd85ef8..b7ae777eb 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java @@ -18,8 +18,7 @@ public class ArrayPredictionContext extends PredictionContext { public final int[] invokingStates; public ArrayPredictionContext(SingletonPredictionContext a) { - this(new PredictionContext[] {a.parent}, - new int[] {a==PredictionContext.EMPTY ? EMPTY_FULL_CTX_INVOKING_STATE : a.invokingState}); + this(new PredictionContext[] {a.parent}, new int[] {a.invokingState}); } public ArrayPredictionContext(PredictionContext[] parents, int[] invokingStates) { @@ -97,7 +96,7 @@ public class ArrayPredictionContext extends PredictionContext { @Override public boolean isEmpty() { return size()==1 && - invokingStates[0]==EmptyPredictionContext.EMPTY_INVOKING_STATE; + invokingStates[0]==EMPTY_INVOKING_STATE; } @Override @@ -140,7 +139,7 @@ public class ArrayPredictionContext extends PredictionContext { for (int i = 0; i < this.invokingStates.length; i++) { if (i == index) continue; PredictionContext next; - if ( this.invokingStates[i] == EMPTY_FULL_CTX_INVOKING_STATE ) { + if ( this.invokingStates[i] == EMPTY_INVOKING_STATE ) { next = PredictionContext.EMPTY; } else { @@ -179,7 +178,7 @@ public class ArrayPredictionContext extends PredictionContext { buf.append("["); for (int i=0; i0 ) buf.append(", "); - if ( invokingStates[i]==EMPTY_FULL_CTX_INVOKING_STATE ) { + if ( invokingStates[i]==EMPTY_INVOKING_STATE ) { buf.append("$"); continue; } diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/EmptyPredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/EmptyPredictionContext.java index 09b51053a..690b32f02 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/EmptyPredictionContext.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/EmptyPredictionContext.java @@ -1,7 +1,6 @@ package org.antlr.v4.runtime.atn; public class EmptyPredictionContext extends SingletonPredictionContext { - public static final int EMPTY_INVOKING_STATE = ATNState.INVALID_STATE_NUMBER - 1; public EmptyPredictionContext() { super(null, EMPTY_INVOKING_STATE); } diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java index ae12f9ef8..234d7c6cd 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java @@ -621,7 +621,7 @@ public class LexerATNSimulator extends ATNSimulator { for (SingletonPredictionContext ctx : config.context) { if ( !ctx.isEmpty() ) { PredictionContext newContext = ctx.parent; // "pop" invoking state - if ( ctx.invokingState==PredictionContext.EMPTY_FULL_CTX_INVOKING_STATE ) { + if ( ctx.invokingState==PredictionContext.EMPTY_INVOKING_STATE ) { // we have no context info. Don't pursue but // record a config that indicates how we hit end LexerATNConfig c = new LexerATNConfig(config, config.state, ctx); diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java index 48ccf72a7..ca470e926 100755 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java @@ -1104,7 +1104,7 @@ public class ParserATNSimulator extends ATNSimulator { // run thru all possible stack tops in ctx if ( config.context!=null && !config.context.isEmpty() ) { for (SingletonPredictionContext ctx : config.context) { - if ( ctx.invokingState==PredictionContext.EMPTY_FULL_CTX_INVOKING_STATE ) { + if ( ctx.invokingState==PredictionContext.EMPTY_INVOKING_STATE ) { // we have no context info, just chase follow links (if greedy) if ( debug ) System.out.println("FALLING off rule "+ getRuleName(config.state.ruleIndex)); diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java index b0b651dd8..2f4ed8d44 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java @@ -22,9 +22,9 @@ public abstract class PredictionContext implements Iterable ax @@ -408,7 +408,7 @@ public abstract class PredictionContext implements Iterable 1) { // first char is '[', if more than that this isn't the first rule diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/SingletonPredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/SingletonPredictionContext.java index 7b2c3f444..1d0f86ade 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/SingletonPredictionContext.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/SingletonPredictionContext.java @@ -11,14 +11,13 @@ public class SingletonPredictionContext extends PredictionContext { SingletonPredictionContext(PredictionContext parent, int invokingState) { super(calculateHashCode(parent!=null ? 31 ^ parent.hashCode() : 1, 31 ^ invokingState)); - assert invokingState!=EMPTY_FULL_CTX_INVOKING_STATE && - invokingState!=ATNState.INVALID_STATE_NUMBER; + assert invokingState!=ATNState.INVALID_STATE_NUMBER; this.parent = parent; this.invokingState = invokingState; } public static SingletonPredictionContext create(PredictionContext parent, int invokingState) { - if ( invokingState == EMPTY_FULL_CTX_INVOKING_STATE && parent == null ) { + if ( invokingState == EMPTY_INVOKING_STATE && parent == null ) { // someone can pass in the bits of an array ctx that mean $ return EMPTY; } @@ -92,7 +91,7 @@ public class SingletonPredictionContext extends PredictionContext { public String toString() { String up = parent!=null ? parent.toString() : ""; if ( up.length()==0 ) { - if ( invokingState == EMPTY_FULL_CTX_INVOKING_STATE ) { + if ( invokingState == EMPTY_INVOKING_STATE ) { return "$"; } return String.valueOf(invokingState); diff --git a/tool/test/org/antlr/v4/test/TestGraphNodes.java b/tool/test/org/antlr/v4/test/TestGraphNodes.java index 959dabe16..c0ec1921a 100644 --- a/tool/test/org/antlr/v4/test/TestGraphNodes.java +++ b/tool/test/org/antlr/v4/test/TestGraphNodes.java @@ -805,7 +805,7 @@ public class TestGraphNodes extends TestCase { } nodes.append("'); - if (current.getInvokingState(i) == PredictionContext.EMPTY_FULL_CTX_INVOKING_STATE) { + if (current.getInvokingState(i) == PredictionContext.EMPTY_INVOKING_STATE) { nodes.append(rootIsWildcard ? '*' : '$'); } } @@ -820,7 +820,7 @@ public class TestGraphNodes extends TestCase { } for (int i = 0; i < current.size(); i++) { - if (current.getInvokingState(i) == PredictionContext.EMPTY_FULL_CTX_INVOKING_STATE) { + if (current.getInvokingState(i) == PredictionContext.EMPTY_INVOKING_STATE) { continue; }