-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathParseException.java
More file actions
87 lines (74 loc) · 2.66 KB
/
ParseException.java
File metadata and controls
87 lines (74 loc) · 2.66 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
79
80
81
82
83
84
85
86
87
package org.python.antlr;
import org.antlr.runtime.IntStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;
import org.python.core.Py;
import org.python.core.PyObject;
public class ParseException extends RuntimeException {
public transient IntStream input;
public int index;
public Token token;
public Object node;
public int c;
public int line;
public int charPositionInLine;
public boolean approximateLineInfo;
public boolean definite;
private PyObject type = Py.SyntaxError;
public ParseException() {
super();
}
public ParseException(String message, int lin, int charPos) {
super(message);
this.line = lin;
this.charPositionInLine = charPos;
}
public ParseException(String message) {
this(message, 0, 0);
}
/**
* Construct a {@code ParseException} specifying whether to treat as a final decision. When we
* use this constructor in the REPL, and {@code definite=true}, Jython will take it that the
* problem is a definite syntax or semantic error, not that we just haven't finished a
* multi-line construct that will be valid eventually.
*
* @param message text to include.
* @param n not {@code null}, root of the {@link PythonTree} provoking the error.
* @param definite true if we cannot recover with more input.
*/
public ParseException(String message, PythonTree n, boolean definite) {
this(message, n.getLineno(), n.getCol_offset());
this.node = n;
this.token = n.getToken();
this.definite = definite;
}
/**
* Construct a {@code ParseException} specifying message and tree. When we use this constructor
* in the REPL, Jython will assume the problem is an incomplete input (as when you wrap a line
* inside parentheses or are inside another nested construct), and a "... " prompt is likely to
* be produced.
*
* @param message text to include.
* @param n not {@code null}, root of the {@link PythonTree} provoking the error.
*/
public ParseException(String message, PythonTree n) {
this(message, n, false);
}
public ParseException(String message, RecognitionException r) {
super(message);
this.input = r.input;
this.index = r.index;
this.token = r.token;
this.node = r.node;
this.c = r.c;
this.line = r.line;
this.charPositionInLine = r.charPositionInLine;
this.approximateLineInfo = r.approximateLineInfo;
}
public void setType(PyObject t) {
this.type = t;
}
public PyObject getType() {
return this.type;
}
}