ParseException.java
4.37 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.formcalc;
import com.adobe.xfa.formcalc.Token;
public class ParseException
extends Exception {
protected boolean specialConstructor;
public Token currentToken;
public int[][] expectedTokenSequences;
public String[] tokenImage;
protected String eol = System.getProperty("line.separator", "\n");
public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal) {
super("");
this.specialConstructor = true;
this.currentToken = currentTokenVal;
this.expectedTokenSequences = expectedTokenSequencesVal;
this.tokenImage = tokenImageVal;
}
public ParseException() {
this.specialConstructor = false;
}
public ParseException(String message) {
super(message);
this.specialConstructor = false;
}
@Override
public String getMessage() {
if (!this.specialConstructor) {
return super.getMessage();
}
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < this.expectedTokenSequences.length; ++i) {
if (maxSize < this.expectedTokenSequences[i].length) {
maxSize = this.expectedTokenSequences[i].length;
}
for (int j = 0; j < this.expectedTokenSequences[i].length; ++j) {
expected.append(this.tokenImage[this.expectedTokenSequences[i][j]]).append(' ');
}
if (this.expectedTokenSequences[i][this.expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(this.eol).append(" ");
}
String retval = "Encountered \"";
Token tok = this.currentToken.next;
for (int i2 = 0; i2 < maxSize; ++i2) {
if (i2 != 0) {
retval = retval + " ";
}
if (tok.kind == 0) {
retval = retval + this.tokenImage[0];
break;
}
retval = retval + " " + this.tokenImage[tok.kind];
retval = retval + " \"";
retval = retval + this.add_escapes(tok.image);
retval = retval + " \"";
tok = tok.next;
}
retval = retval + "\" at line " + this.currentToken.next.beginLine + ", column " + this.currentToken.next.beginColumn;
retval = retval + "." + this.eol;
retval = this.expectedTokenSequences.length == 1 ? retval + "Was expecting:" + this.eol + " " : retval + "Was expecting one of:" + this.eol + " ";
retval = retval + expected.toString();
return retval;
}
protected String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
block11 : for (int i = 0; i < str.length(); ++i) {
switch (str.charAt(i)) {
case '\u0000': {
continue block11;
}
case '\b': {
retval.append("\\b");
continue block11;
}
case '\t': {
retval.append("\\t");
continue block11;
}
case '\n': {
retval.append("\\n");
continue block11;
}
case '\f': {
retval.append("\\f");
continue block11;
}
case '\r': {
retval.append("\\r");
continue block11;
}
case '\"': {
retval.append("\\\"");
continue block11;
}
case '\'': {
retval.append("\\'");
continue block11;
}
case '\\': {
retval.append("\\\\");
continue block11;
}
default: {
char ch = str.charAt(i);
if (ch < ' ' || ch > '~') {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
continue block11;
}
retval.append(ch);
}
}
}
return retval.toString();
}
}