diff --git a/runtime/Java/src/org/antlr/v4/runtime/BaseRecognizer.java b/runtime/Java/src/org/antlr/v4/runtime/BaseRecognizer.java index d50cdc588..ccbbe7551 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/BaseRecognizer.java +++ b/runtime/Java/src/org/antlr/v4/runtime/BaseRecognizer.java @@ -148,7 +148,7 @@ public abstract class BaseRecognizer extends Recognizer getInputStream(); + public abstract SymbolStream getInputStream(); /** Match needs to return the current input symbol, which gets put * into the label for the associated token ref; e.g., x=ID. Token diff --git a/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java b/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java index dd3c00a79..48a6734b0 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java +++ b/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java @@ -33,8 +33,6 @@ import com.sun.istack.internal.NotNull; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.misc.IntervalSet; import org.antlr.v4.runtime.tree.AST; -import org.antlr.v4.runtime.tree.ASTAdaptor; -import org.antlr.v4.runtime.tree.Tree; /** This is the default error handling mechanism for ANTLR parsers * and tree parsers. @@ -158,7 +156,7 @@ public class DefaultANTLRErrorStrategy implements ANTLRErrorStrategy tokens = recognizer.getInputStream(); + SymbolStream tokens = recognizer.getInputStream(); int la = tokens.LA(1); // Return but don't end recovery. only do that upon valid token match if ( la==Token.EOF || expecting.contains(la) ) return; @@ -187,7 +185,7 @@ public class DefaultANTLRErrorStrategy implements ANTLRErrorStrategy tokens = recognizer.getInputStream(); + SymbolStream tokens = recognizer.getInputStream(); String input; if (tokens instanceof TokenStream) { input = ((TokenStream)tokens).toString(e.startToken, e.offendingToken); diff --git a/runtime/Java/src/org/antlr/v4/runtime/NoViableAltException.java b/runtime/Java/src/org/antlr/v4/runtime/NoViableAltException.java index 60ac61012..88d48a5bd 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/NoViableAltException.java +++ b/runtime/Java/src/org/antlr/v4/runtime/NoViableAltException.java @@ -55,7 +55,7 @@ public class NoViableAltException extends RecognitionException { } public NoViableAltException(BaseRecognizer recognizer, - ObjectStream input, + SymbolStream input, Token startToken, Token offendingToken, T offendingNode, diff --git a/runtime/Java/src/org/antlr/v4/runtime/ObjectStream.java b/runtime/Java/src/org/antlr/v4/runtime/SymbolStream.java similarity index 97% rename from runtime/Java/src/org/antlr/v4/runtime/ObjectStream.java rename to runtime/Java/src/org/antlr/v4/runtime/SymbolStream.java index 65595e0a0..4c801b1dc 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/ObjectStream.java +++ b/runtime/Java/src/org/antlr/v4/runtime/SymbolStream.java @@ -30,7 +30,7 @@ package org.antlr.v4.runtime; /** A stream of either tokens or tree nodes */ -public interface ObjectStream extends IntStream { +public interface SymbolStream extends IntStream { /** Get an object at absolute index i; 0..n-1. * This is only valid if the underlying stream implementation buffers * all of the incoming objects. diff --git a/runtime/Java/src/org/antlr/v4/runtime/TokenStream.java b/runtime/Java/src/org/antlr/v4/runtime/TokenStream.java index 5a4fed693..7f0b1ee4f 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/TokenStream.java +++ b/runtime/Java/src/org/antlr/v4/runtime/TokenStream.java @@ -30,7 +30,7 @@ package org.antlr.v4.runtime; /** A stream of tokens accessing tokens from a TokenSource */ -public interface TokenStream extends ObjectStream { +public interface TokenStream extends SymbolStream { /** Get Token at current input pointer + i ahead where i=1 is next Token. * i<0 indicates tokens in the past. So -1 is previous token and -2 is * two tokens ago. LT(0) is undefined. For i>=n, return Token.EOFToken. 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 43fb6583e..d37b51ad0 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java @@ -83,7 +83,7 @@ public class ParserATNSimulator extends ATNSimulator { // System.out.println(dot.getDOT(atn.rules.get(1), parser.getRuleNames())); } - public int adaptivePredict(ObjectStream input, int decision, RuleContext outerContext) { + public int adaptivePredict(SymbolStream input, int decision, RuleContext outerContext) { predict_calls++; DFA dfa = decisionToDFA[decision]; if ( dfa==null || dfa.s0==null ) { @@ -108,7 +108,7 @@ public class ParserATNSimulator extends ATNSimulator { } } - public int predictATN(DFA dfa, ObjectStream input, + public int predictATN(DFA dfa, SymbolStream input, RuleContext outerContext, boolean useContext) { @@ -146,7 +146,7 @@ public class ParserATNSimulator extends ATNSimulator { } // doesn't create DFA when matching - public int matchATN(ObjectStream input, ATNState startState) { + public int matchATN(SymbolStream input, ATNState startState) { DFA dfa = new DFA(startState); if ( outerContext==null ) outerContext = RuleContext.EMPTY; RuleContext ctx = RuleContext.EMPTY; @@ -154,7 +154,7 @@ public class ParserATNSimulator extends ATNSimulator { return execATN(input, dfa, input.index(), s0_closure, false); } - public int execDFA(ObjectStream input, DFA dfa, DFAState s0, RuleContext outerContext) { + public int execDFA(SymbolStream input, DFA dfa, DFAState s0, RuleContext outerContext) { // dump(dfa); if ( outerContext==null ) outerContext = RuleContext.EMPTY; this.outerContext = outerContext; @@ -241,7 +241,7 @@ public class ParserATNSimulator extends ATNSimulator { return prevAcceptState.prediction; } - public String getInputString(ObjectStream input, int start) { + public String getInputString(SymbolStream input, int start) { if ( input instanceof TokenStream ) { return ((TokenStream)input).toString(start,input.index()); } @@ -251,7 +251,7 @@ public class ParserATNSimulator extends ATNSimulator { return "n/a"; } - public int execATN(ObjectStream input, + public int execATN(SymbolStream input, DFA dfa, int startIndex, OrderedHashSet s0, @@ -405,7 +405,7 @@ public class ParserATNSimulator extends ATNSimulator { return exitAlt; } - public int retryWithContext(ObjectStream input, + public int retryWithContext(SymbolStream input, DFA dfa, int startIndex, RuleContext originalContext, @@ -823,7 +823,7 @@ public class ParserATNSimulator extends ATNSimulator { return String.valueOf(t); } - public String getLookaheadName(ObjectStream input) { + public String getLookaheadName(SymbolStream input) { return getTokenName(input.LA(1)); } @@ -849,7 +849,7 @@ public class ParserATNSimulator extends ATNSimulator { } } - public int throwNoViableAlt(ObjectStream input, RuleContext outerContext, + public int throwNoViableAlt(SymbolStream input, RuleContext outerContext, OrderedHashSet configs, int startIndex) { if ( parser instanceof TreeParser) { diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/ASTNodeStream.java b/runtime/Java/src/org/antlr/v4/runtime/tree/ASTNodeStream.java index c6e455dad..961f1d85b 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/tree/ASTNodeStream.java +++ b/runtime/Java/src/org/antlr/v4/runtime/tree/ASTNodeStream.java @@ -32,7 +32,7 @@ package org.antlr.v4.runtime.tree; import org.antlr.v4.runtime.*; /** A stream of tree nodes, accessing nodes from a tree of some kind */ -public interface ASTNodeStream extends ObjectStream { +public interface ASTNodeStream extends SymbolStream { /** Get a tree node at an absolute index i; 0..n-1. * If you don't want to buffer up nodes, then this method makes no * sense for you.