forked from jasder/antlr
_errHandler.sync(this);
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9176]
This commit is contained in:
parent
39314b8d74
commit
4920bb2c9e
|
@ -54,7 +54,7 @@ public interface ANTLRErrorStrategy {
|
||||||
|
|
||||||
/** Make sure that the current lookahead symbol is consistent with
|
/** Make sure that the current lookahead symbol is consistent with
|
||||||
* what were expecting at this point in the ATN. You can call this
|
* what were expecting at this point in the ATN. You can call this
|
||||||
* anytime but ANTLR only generates code to check before loops
|
* anytime but ANTLR only generates code to check before subrules/loops
|
||||||
* and each iteration.
|
* and each iteration.
|
||||||
*
|
*
|
||||||
* Implements Jim Idle's magic sync mechanism in closures and optional
|
* Implements Jim Idle's magic sync mechanism in closures and optional
|
||||||
|
@ -74,7 +74,7 @@ public interface ANTLRErrorStrategy {
|
||||||
* next member definition of the current class.
|
* next member definition of the current class.
|
||||||
*
|
*
|
||||||
* This functionality cost a little bit of effort because the parser
|
* This functionality cost a little bit of effort because the parser
|
||||||
* has to compare token set at the start of the loop and add each
|
* has to compare token set at the start of the loop and at each
|
||||||
* iteration. If for some reason speed is suffering for you, you can
|
* iteration. If for some reason speed is suffering for you, you can
|
||||||
* turn off this functionality by simply overriding this method as
|
* turn off this functionality by simply overriding this method as
|
||||||
* a blank { }.
|
* a blank { }.
|
||||||
|
|
|
@ -29,9 +29,7 @@
|
||||||
|
|
||||||
package org.antlr.v4.runtime;
|
package org.antlr.v4.runtime;
|
||||||
|
|
||||||
import org.antlr.v4.runtime.atn.ATN;
|
import org.antlr.v4.runtime.atn.*;
|
||||||
import org.antlr.v4.runtime.atn.ATNState;
|
|
||||||
import org.antlr.v4.runtime.atn.RuleTransition;
|
|
||||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||||
|
|
||||||
/** This is the default error handling mechanism for ANTLR parsers
|
/** This is the default error handling mechanism for ANTLR parsers
|
||||||
|
@ -131,9 +129,13 @@ public class DefaultANTLRErrorStrategy implements ANTLRErrorStrategy {
|
||||||
|
|
||||||
/** Make sure that the current lookahead symbol is consistent with
|
/** Make sure that the current lookahead symbol is consistent with
|
||||||
* what were expecting at this point in the ATN.
|
* what were expecting at this point in the ATN.
|
||||||
*
|
* sync() differs fundamentally from the recoverInline() method.
|
||||||
* TODO: see if we can merge sync() and recoverInline(). are they same?
|
* In this case, we throw out a token that's not in the set of what
|
||||||
* does one call the other?
|
* were expecting at this point. recoverInline() only deletes this
|
||||||
|
* token if LT(2) (token after the current token) is what were expecting;
|
||||||
|
* i.e., we have an extra token sitting on the input stream. sync()
|
||||||
|
* simply consumes until it finds something that can start whatever
|
||||||
|
* follows the call to sync().
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sync(BaseRecognizer recognizer) {
|
public void sync(BaseRecognizer recognizer) {
|
||||||
|
|
|
@ -219,6 +219,7 @@ CodeBlockForAlt(c, locals, preamble, ops) ::= <<
|
||||||
|
|
||||||
LL1AltBlock(choice, preamble, alts, error) ::= <<
|
LL1AltBlock(choice, preamble, alts, error) ::= <<
|
||||||
setState(<choice.stateNumber>);
|
setState(<choice.stateNumber>);
|
||||||
|
_errHandler.sync(this);
|
||||||
<if(choice.label)><labelref(choice.label)> = _input.LT(1);<endif>
|
<if(choice.label)><labelref(choice.label)> = _input.LT(1);<endif>
|
||||||
<preamble; separator="\n">
|
<preamble; separator="\n">
|
||||||
switch ( _input.LA(1) ) {
|
switch ( _input.LA(1) ) {
|
||||||
|
@ -232,6 +233,7 @@ switch ( _input.LA(1) ) {
|
||||||
|
|
||||||
LL1OptionalBlock(choice, alts, error) ::= <<
|
LL1OptionalBlock(choice, alts, error) ::= <<
|
||||||
setState(<choice.stateNumber>);
|
setState(<choice.stateNumber>);
|
||||||
|
_errHandler.sync(this);
|
||||||
switch ( _input.LA(1) ) {
|
switch ( _input.LA(1) ) {
|
||||||
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
|
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
|
||||||
<alt>
|
<alt>
|
||||||
|
@ -243,6 +245,7 @@ switch ( _input.LA(1) ) {
|
||||||
|
|
||||||
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
|
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
|
||||||
setState(<choice.stateNumber>);
|
setState(<choice.stateNumber>);
|
||||||
|
_errHandler.sync(this);
|
||||||
<preamble; separator="\n">
|
<preamble; separator="\n">
|
||||||
if ( <expr> ) {
|
if ( <expr> ) {
|
||||||
<alts; separator="\n">
|
<alts; separator="\n">
|
||||||
|
@ -312,6 +315,7 @@ do {
|
||||||
|
|
||||||
AltBlock(choice, preamble, alts, error) ::= <<
|
AltBlock(choice, preamble, alts, error) ::= <<
|
||||||
setState(<choice.stateNumber>);
|
setState(<choice.stateNumber>);
|
||||||
|
_errHandler.sync(this);
|
||||||
<if(choice.label)><labelref(choice.label)> = _input.LT(1);<endif>
|
<if(choice.label)><labelref(choice.label)> = _input.LT(1);<endif>
|
||||||
<preamble; separator="\n">
|
<preamble; separator="\n">
|
||||||
switch ( _interp.adaptivePredict(_input,<choice.decision>,_ctx) ) {
|
switch ( _interp.adaptivePredict(_input,<choice.decision>,_ctx) ) {
|
||||||
|
@ -324,6 +328,7 @@ case <i>:
|
||||||
|
|
||||||
OptionalBlock(choice, alts, error) ::= <<
|
OptionalBlock(choice, alts, error) ::= <<
|
||||||
setState(<choice.stateNumber>);
|
setState(<choice.stateNumber>);
|
||||||
|
_errHandler.sync(this);
|
||||||
switch ( _interp.adaptivePredict(_input,<choice.decision>,_ctx) ) {
|
switch ( _interp.adaptivePredict(_input,<choice.decision>,_ctx) ) {
|
||||||
<alts:{alt |
|
<alts:{alt |
|
||||||
case <i>:
|
case <i>:
|
||||||
|
|
Loading…
Reference in New Issue