Add type parameter to BailErrorStrategy since the class may safely be used with any type of recognizer
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9485]
This commit is contained in:
parent
2243cc2e81
commit
c25f3ff3d8
|
@ -32,14 +32,14 @@ package org.antlr.v4.runtime;
|
|||
/** Bail out of parser at first syntax error. Do this to use it:
|
||||
* myparser.setErrorHandler(new BailErrorStrategy<Token>());
|
||||
*/
|
||||
public class BailErrorStrategy extends DefaultErrorStrategy<Token> {
|
||||
public class BailErrorStrategy<Symbol> extends DefaultErrorStrategy<Symbol> {
|
||||
/** Instead of recovering from exception e, Re-throw wrote it wrapped
|
||||
* in a generic RuntimeException so it is not caught by the
|
||||
* rule function catches. Exception e is the "cause" of the
|
||||
* RuntimeException.
|
||||
*/
|
||||
@Override
|
||||
public void recover(BaseRecognizer recognizer, RecognitionException e) {
|
||||
public void recover(BaseRecognizer<Symbol> recognizer, RecognitionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class BailErrorStrategy extends DefaultErrorStrategy<Token> {
|
|||
* successfully recovers, it won't throw an exception.
|
||||
*/
|
||||
@Override
|
||||
public Token recoverInline(BaseRecognizer recognizer)
|
||||
public Symbol recoverInline(BaseRecognizer<Symbol> recognizer)
|
||||
throws RecognitionException
|
||||
{
|
||||
throw new RuntimeException(new InputMismatchException(recognizer));
|
||||
|
@ -55,5 +55,5 @@ public class BailErrorStrategy extends DefaultErrorStrategy<Token> {
|
|||
|
||||
/** Make sure we don't attempt to recover from problems in subrules. */
|
||||
@Override
|
||||
public void sync(BaseRecognizer recognizer) { }
|
||||
public void sync(BaseRecognizer<Symbol> recognizer) { }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue