v4: Fix Parser.reset (side effect fixes Parser.setInputStream)

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9491]
This commit is contained in:
sharwell 2011-11-29 20:25:51 -08:00
parent 1be2e2c556
commit 2bbb1ca132
3 changed files with 12 additions and 8 deletions

View File

@ -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

View File

@ -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.

View File

@ -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)