v4: Fix Parser.reset (side effect fixes Parser.setInputStream)
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9491]
This commit is contained in:
parent
1be2e2c556
commit
2bbb1ca132
|
@ -79,6 +79,11 @@ public abstract class BaseRecognizer<Symbol> extends Recognizer<Symbol, ParserAT
|
|||
if ( getInputStream()!=null ) getInputStream().seek(0);
|
||||
_errHandler.endErrorCondition(this);
|
||||
_ctx = null;
|
||||
syntaxErrors = 0;
|
||||
ParserATNSimulator<?> interpreter = getInterpreter();
|
||||
if (interpreter != null) {
|
||||
interpreter.reset();
|
||||
}
|
||||
}
|
||||
|
||||
/** Match current input symbol against ttype. Attempt
|
||||
|
|
|
@ -39,14 +39,6 @@ public class Parser extends BaseRecognizer<Token> {
|
|||
super(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset(); // reset all recognizer state variables
|
||||
if ( _input !=null ) {
|
||||
_input.seek(0); // rewind the input
|
||||
}
|
||||
}
|
||||
|
||||
/** Always called by generated parsers upon entry to a rule.
|
||||
* This occurs after the new context has been pushed. Access field
|
||||
* _ctx get the current context.
|
||||
|
|
|
@ -116,6 +116,13 @@ public class ParserATNSimulator<Symbol> extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
userWantsCtxSensitive = false;
|
||||
outerContext = RuleContext.EMPTY;
|
||||
prevAccept = null;
|
||||
prevAcceptIndex = -1;
|
||||
}
|
||||
|
||||
public int predictATN(@NotNull DFA dfa, @NotNull SymbolStream<Symbol> input,
|
||||
@Nullable RuleContext outerContext,
|
||||
boolean useContext)
|
||||
|
|
Loading…
Reference in New Issue