-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathFailFastHandler.java
More file actions
78 lines (62 loc) · 2.18 KB
/
FailFastHandler.java
File metadata and controls
78 lines (62 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package org.python.antlr;
import org.antlr.runtime.BaseRecognizer;
import org.antlr.runtime.BitSet;
import org.antlr.runtime.IntStream;
import org.antlr.runtime.Lexer;
import org.antlr.runtime.MismatchedTokenException;
import org.antlr.runtime.RecognitionException;
import org.python.antlr.base.expr;
import org.python.antlr.base.mod;
import org.python.antlr.base.slice;
import org.python.antlr.base.stmt;
public class FailFastHandler implements ErrorHandler {
@Override
public void reportError(BaseRecognizer br, RecognitionException re) {
throw new ParseException(message(br,re), re);
}
@Override
public void recover(Lexer lex, RecognitionException re) {
throw new ParseException(message(lex,re), re);
}
@Override
public void recover(BaseRecognizer br, IntStream input, RecognitionException re) {
throw new ParseException(message(br,re), re);
}
@Override
public boolean mismatch(BaseRecognizer br, IntStream input, int ttype, BitSet follow)
throws RecognitionException {
throw new MismatchedTokenException(ttype, input);
}
@Override
public Object recoverFromMismatchedToken(BaseRecognizer br, IntStream input, int ttype,
BitSet follow) throws RecognitionException {
throw new MismatchedTokenException(ttype, input);
}
@Override
public expr errorExpr(PythonTree t) {
throw new ParseException("Bad Expr Node", t);
}
@Override
public mod errorMod(PythonTree t) {
throw new ParseException("Bad Mod Node", t);
}
@Override
public slice errorSlice(PythonTree t) {
throw new ParseException("Bad Slice Node", t);
}
@Override
public stmt errorStmt(PythonTree t) {
throw new ParseException("Bad Stmt Node", t);
}
@Override
public void error(String message, PythonTree t) {
throw new ParseException(message, t);
}
@Override
public void error(String message, PythonTree t, boolean definite) {
throw new ParseException(message, t, definite);
}
private String message(BaseRecognizer br, RecognitionException re) {
return br.getErrorMessage(re, br.getTokenNames());
}
}