-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathRecordingErrorHandler.java
More file actions
68 lines (54 loc) · 1.83 KB
/
RecordingErrorHandler.java
File metadata and controls
68 lines (54 loc) · 1.83 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
/**
* Copyright 2009, Google Inc. All rights reserved.
* Licensed to PSF under a Contributor Agreement.
*/
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.RecognitionException;
import org.python.antlr.ast.ErrorExpr;
import org.python.antlr.ast.ErrorMod;
import org.python.antlr.ast.ErrorSlice;
import org.python.antlr.ast.ErrorStmt;
import org.python.antlr.base.expr;
import org.python.antlr.base.mod;
import org.python.antlr.base.slice;
import org.python.antlr.base.stmt;
import java.util.ArrayList;
import java.util.List;
public class RecordingErrorHandler implements ErrorHandler {
public List<RecognitionException> errs = new ArrayList<RecognitionException>();
public void reportError(BaseRecognizer br, RecognitionException re) {
errs.add(re);
}
public void recover(Lexer lex, RecognitionException re) {
lex.recover(re);
}
public void recover(BaseRecognizer br, IntStream input, RecognitionException re) {
br.recover(input, re);
}
public boolean mismatch(BaseRecognizer br, IntStream input, int ttype, BitSet follow) {
return true;
}
public Object recoverFromMismatchedToken(BaseRecognizer br, IntStream input,
int ttype, BitSet follow) {
return null;
}
public expr errorExpr(PythonTree t) {
return new ErrorExpr(t);
}
public mod errorMod(PythonTree t) {
return new ErrorMod(t);
}
public slice errorSlice(PythonTree t) {
return new ErrorSlice(t);
}
public stmt errorStmt(PythonTree t) {
return new ErrorStmt(t);
}
public void error(String message, PythonTree t) {
System.err.println(message);
}
}