47 |
47 |
48 final public JSONObject object() throws ParseException { |
48 final public JSONObject object() throws ParseException { |
49 final JSONObject jobject = new JSONObject(); |
49 final JSONObject jobject = new JSONObject(); |
50 JSONPrimitive key; |
50 JSONPrimitive key; |
51 JSONElement value; |
51 JSONElement value; |
|
52 jj_consume_token(16); |
|
53 key = string(); |
52 jj_consume_token(17); |
54 jj_consume_token(17); |
53 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
|
54 case QUOTED_STRING: |
|
55 key = string(); |
|
56 break; |
|
57 case IDENTIFIER: |
|
58 key = identifier(); |
|
59 break; |
|
60 default: |
|
61 jj_la1[1] = jj_gen; |
|
62 jj_consume_token(-1); |
|
63 throw new ParseException(); |
|
64 } |
|
65 jj_consume_token(18); |
|
66 value = jsonValue(); |
55 value = jsonValue(); |
67 jobject.put((String)key.getValue(), value); |
56 jobject.put((String)key.getValue(), value); |
68 label_1: |
57 label_1: |
69 while (true) { |
58 while (true) { |
70 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
59 switch (jj_nt.kind) { |
71 case 19: |
60 case 18: |
|
61 ; |
|
62 break; |
|
63 default: |
|
64 jj_la1[1] = jj_gen; |
|
65 break label_1; |
|
66 } |
|
67 jj_consume_token(18); |
|
68 key = string(); |
|
69 jj_consume_token(17); |
|
70 value = jsonValue(); |
|
71 jobject.put((String)key.getValue(), value); |
|
72 } |
|
73 jj_consume_token(19); |
|
74 {if (true) return jobject;} |
|
75 throw new Error("Missing return statement in function"); |
|
76 } |
|
77 |
|
78 final public JSONArray list() throws ParseException { |
|
79 final JSONArray jarray = new JSONArray(); |
|
80 JSONElement value; |
|
81 jj_consume_token(20); |
|
82 value = jsonValue(); |
|
83 jarray.add(value); |
|
84 label_2: |
|
85 while (true) { |
|
86 switch (jj_nt.kind) { |
|
87 case 18: |
72 ; |
88 ; |
73 break; |
89 break; |
74 default: |
90 default: |
75 jj_la1[2] = jj_gen; |
91 jj_la1[2] = jj_gen; |
76 break label_1; |
92 break label_2; |
77 } |
|
78 jj_consume_token(19); |
|
79 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
|
80 case QUOTED_STRING: |
|
81 key = string(); |
|
82 break; |
|
83 case IDENTIFIER: |
|
84 key = identifier(); |
|
85 break; |
|
86 default: |
|
87 jj_la1[3] = jj_gen; |
|
88 jj_consume_token(-1); |
|
89 throw new ParseException(); |
|
90 } |
93 } |
91 jj_consume_token(18); |
94 jj_consume_token(18); |
92 value = jsonValue(); |
95 value = jsonValue(); |
93 jobject.put((String)key.getValue(), value); |
96 jarray.add(value); |
94 } |
97 } |
95 jj_consume_token(20); |
|
96 {if (true) return jobject;} |
|
97 throw new Error("Missing return statement in function"); |
|
98 } |
|
99 |
|
100 final public JSONArray list() throws ParseException { |
|
101 final JSONArray jarray = new JSONArray(); |
|
102 JSONElement value; |
|
103 jj_consume_token(21); |
98 jj_consume_token(21); |
104 value = jsonValue(); |
|
105 jarray.add(value); |
|
106 label_2: |
|
107 while (true) { |
|
108 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
|
109 case 19: |
|
110 ; |
|
111 break; |
|
112 default: |
|
113 jj_la1[4] = jj_gen; |
|
114 break label_2; |
|
115 } |
|
116 jj_consume_token(19); |
|
117 value = jsonValue(); |
|
118 jarray.add(value); |
|
119 } |
|
120 jj_consume_token(22); |
|
121 {if (true) return jarray;} |
99 {if (true) return jarray;} |
122 throw new Error("Missing return statement in function"); |
100 throw new Error("Missing return statement in function"); |
123 } |
101 } |
124 |
102 |
125 final public JSONPrimitive nullVal() throws ParseException { |
103 final public JSONPrimitive nullVal() throws ParseException { |
134 throw new Error("Missing return statement in function"); |
112 throw new Error("Missing return statement in function"); |
135 } |
113 } |
136 |
114 |
137 final public JSONPrimitive number() throws ParseException { |
115 final public JSONPrimitive number() throws ParseException { |
138 Token t; |
116 Token t; |
139 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
117 switch (jj_nt.kind) { |
140 case INTEGER_LITERAL: |
118 case INTEGER_LITERAL: |
141 t = jj_consume_token(INTEGER_LITERAL); |
119 t = jj_consume_token(INTEGER_LITERAL); |
142 {if (true) return new JSONPrimitive(Long.parseLong(t.image));} |
120 {if (true) return new JSONPrimitive(Long.parseLong(t.image));} |
143 break; |
121 break; |
144 case FLOATING_POINT_LITERAL: |
122 case FLOATING_POINT_LITERAL: |
145 t = jj_consume_token(FLOATING_POINT_LITERAL); |
123 t = jj_consume_token(FLOATING_POINT_LITERAL); |
146 {if (true) return new JSONPrimitive(Double.parseDouble(t.image));} |
124 {if (true) return new JSONPrimitive(Double.parseDouble(t.image));} |
147 break; |
125 break; |
148 default: |
126 default: |
149 jj_la1[5] = jj_gen; |
127 jj_la1[3] = jj_gen; |
150 jj_consume_token(-1); |
128 jj_consume_token(-1); |
151 throw new ParseException(); |
129 throw new ParseException(); |
152 } |
130 } |
153 throw new Error("Missing return statement in function"); |
131 throw new Error("Missing return statement in function"); |
154 } |
132 } |
155 |
133 |
156 final public JSONPrimitive string() throws ParseException { |
134 final public JSONPrimitive string() throws ParseException { |
157 Token t; |
135 Token t; |
158 t = jj_consume_token(QUOTED_STRING); |
136 t = jj_consume_token(QUOTED_STRING); |
159 {if (true) return new JSONPrimitive(t.image.substring(1,t.image.length()-1));} |
137 {if (true) return new JSONPrimitive(t.image.substring(1,t.image.length()-1));} |
160 throw new Error("Missing return statement in function"); |
|
161 } |
|
162 |
|
163 final public JSONPrimitive identifier() throws ParseException { |
|
164 jj_consume_token(IDENTIFIER); |
|
165 {if (true) return new JSONPrimitive(token.image);} |
|
166 throw new Error("Missing return statement in function"); |
138 throw new Error("Missing return statement in function"); |
167 } |
139 } |
168 |
140 |
169 /** Generated Token Manager. */ |
141 /** Generated Token Manager. */ |
170 public JSONParserTokenManager token_source; |
142 public JSONParserTokenManager token_source; |
171 JavaCharStream jj_input_stream; |
143 JavaCharStream jj_input_stream; |
172 /** Current token. */ |
144 /** Current token. */ |
173 public Token token; |
145 public Token token; |
174 /** Next token. */ |
146 /** Next token. */ |
175 public Token jj_nt; |
147 public Token jj_nt; |
176 private int jj_ntk; |
|
177 private int jj_gen; |
148 private int jj_gen; |
178 final private int[] jj_la1 = new int[6]; |
149 final private int[] jj_la1 = new int[4]; |
179 static private int[] jj_la1_0; |
150 static private int[] jj_la1_0; |
180 static { |
151 static { |
181 jj_la1_init_0(); |
152 jj_la1_init_0(); |
182 } |
153 } |
183 private static void jj_la1_init_0() { |
154 private static void jj_la1_init_0() { |
184 jj_la1_0 = new int[] {0x22e180,0x12000,0x80000,0x12000,0x80000,0x180,}; |
155 jj_la1_0 = new int[] {0x11e180,0x40000,0x40000,0x180,}; |
185 } |
156 } |
186 |
157 |
187 /** Constructor with InputStream. */ |
158 /** Constructor with InputStream. */ |
188 public JSONParser(java.io.InputStream stream) { |
159 public JSONParser(java.io.InputStream stream) { |
189 this(stream, null); |
160 this(stream, null); |
191 /** Constructor with InputStream and supplied encoding */ |
162 /** Constructor with InputStream and supplied encoding */ |
192 public JSONParser(java.io.InputStream stream, String encoding) { |
163 public JSONParser(java.io.InputStream stream, String encoding) { |
193 try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } |
164 try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } |
194 token_source = new JSONParserTokenManager(jj_input_stream); |
165 token_source = new JSONParserTokenManager(jj_input_stream); |
195 token = new Token(); |
166 token = new Token(); |
196 jj_ntk = -1; |
167 token.next = jj_nt = token_source.getNextToken(); |
197 jj_gen = 0; |
168 jj_gen = 0; |
198 for (int i = 0; i < 6; i++) jj_la1[i] = -1; |
169 for (int i = 0; i < 4; i++) jj_la1[i] = -1; |
199 } |
170 } |
200 |
171 |
201 /** Reinitialise. */ |
172 /** Reinitialise. */ |
202 public void ReInit(java.io.InputStream stream) { |
173 public void ReInit(java.io.InputStream stream) { |
203 ReInit(stream, null); |
174 ReInit(stream, null); |
205 /** Reinitialise. */ |
176 /** Reinitialise. */ |
206 public void ReInit(java.io.InputStream stream, String encoding) { |
177 public void ReInit(java.io.InputStream stream, String encoding) { |
207 try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } |
178 try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } |
208 token_source.ReInit(jj_input_stream); |
179 token_source.ReInit(jj_input_stream); |
209 token = new Token(); |
180 token = new Token(); |
210 jj_ntk = -1; |
181 token.next = jj_nt = token_source.getNextToken(); |
211 jj_gen = 0; |
182 jj_gen = 0; |
212 for (int i = 0; i < 6; i++) jj_la1[i] = -1; |
183 for (int i = 0; i < 4; i++) jj_la1[i] = -1; |
213 } |
184 } |
214 |
185 |
215 /** Constructor. */ |
186 /** Constructor. */ |
216 public JSONParser(java.io.Reader stream) { |
187 public JSONParser(java.io.Reader stream) { |
217 jj_input_stream = new JavaCharStream(stream, 1, 1); |
188 jj_input_stream = new JavaCharStream(stream, 1, 1); |
218 token_source = new JSONParserTokenManager(jj_input_stream); |
189 token_source = new JSONParserTokenManager(jj_input_stream); |
219 token = new Token(); |
190 token = new Token(); |
220 jj_ntk = -1; |
191 token.next = jj_nt = token_source.getNextToken(); |
221 jj_gen = 0; |
192 jj_gen = 0; |
222 for (int i = 0; i < 6; i++) jj_la1[i] = -1; |
193 for (int i = 0; i < 4; i++) jj_la1[i] = -1; |
223 } |
194 } |
224 |
195 |
225 /** Reinitialise. */ |
196 /** Reinitialise. */ |
226 public void ReInit(java.io.Reader stream) { |
197 public void ReInit(java.io.Reader stream) { |
227 jj_input_stream.ReInit(stream, 1, 1); |
198 jj_input_stream.ReInit(stream, 1, 1); |
228 token_source.ReInit(jj_input_stream); |
199 token_source.ReInit(jj_input_stream); |
229 token = new Token(); |
200 token = new Token(); |
230 jj_ntk = -1; |
201 token.next = jj_nt = token_source.getNextToken(); |
231 jj_gen = 0; |
202 jj_gen = 0; |
232 for (int i = 0; i < 6; i++) jj_la1[i] = -1; |
203 for (int i = 0; i < 4; i++) jj_la1[i] = -1; |
233 } |
204 } |
234 |
205 |
235 /** Constructor with generated Token Manager. */ |
206 /** Constructor with generated Token Manager. */ |
236 public JSONParser(JSONParserTokenManager tm) { |
207 public JSONParser(JSONParserTokenManager tm) { |
237 token_source = tm; |
208 token_source = tm; |
238 token = new Token(); |
209 token = new Token(); |
239 jj_ntk = -1; |
210 token.next = jj_nt = token_source.getNextToken(); |
240 jj_gen = 0; |
211 jj_gen = 0; |
241 for (int i = 0; i < 6; i++) jj_la1[i] = -1; |
212 for (int i = 0; i < 4; i++) jj_la1[i] = -1; |
242 } |
213 } |
243 |
214 |
244 /** Reinitialise. */ |
215 /** Reinitialise. */ |
245 public void ReInit(JSONParserTokenManager tm) { |
216 public void ReInit(JSONParserTokenManager tm) { |
246 token_source = tm; |
217 token_source = tm; |
247 token = new Token(); |
218 token = new Token(); |
248 jj_ntk = -1; |
219 token.next = jj_nt = token_source.getNextToken(); |
249 jj_gen = 0; |
220 jj_gen = 0; |
250 for (int i = 0; i < 6; i++) jj_la1[i] = -1; |
221 for (int i = 0; i < 4; i++) jj_la1[i] = -1; |
251 } |
222 } |
252 |
223 |
253 private Token jj_consume_token(int kind) throws ParseException { |
224 private Token jj_consume_token(int kind) throws ParseException { |
254 Token oldToken; |
225 Token oldToken = token; |
255 if ((oldToken = token).next != null) token = token.next; |
226 if ((token = jj_nt).next != null) jj_nt = jj_nt.next; |
256 else token = token.next = token_source.getNextToken(); |
227 else jj_nt = jj_nt.next = token_source.getNextToken(); |
257 jj_ntk = -1; |
|
258 if (token.kind == kind) { |
228 if (token.kind == kind) { |
259 jj_gen++; |
229 jj_gen++; |
260 return token; |
230 return token; |
261 } |
231 } |
|
232 jj_nt = token; |
262 token = oldToken; |
233 token = oldToken; |
263 jj_kind = kind; |
234 jj_kind = kind; |
264 throw generateParseException(); |
235 throw generateParseException(); |
265 } |
236 } |
266 |
237 |
267 |
238 |
268 /** Get the next Token. */ |
239 /** Get the next Token. */ |
269 final public Token getNextToken() { |
240 final public Token getNextToken() { |
270 if (token.next != null) token = token.next; |
241 if ((token = jj_nt).next != null) jj_nt = jj_nt.next; |
271 else token = token.next = token_source.getNextToken(); |
242 else jj_nt = jj_nt.next = token_source.getNextToken(); |
272 jj_ntk = -1; |
|
273 jj_gen++; |
243 jj_gen++; |
274 return token; |
244 return token; |
275 } |
245 } |
276 |
246 |
277 /** Get the specific Token. */ |
247 /** Get the specific Token. */ |
282 else t = t.next = token_source.getNextToken(); |
252 else t = t.next = token_source.getNextToken(); |
283 } |
253 } |
284 return t; |
254 return t; |
285 } |
255 } |
286 |
256 |
287 private int jj_ntk() { |
|
288 if ((jj_nt=token.next) == null) |
|
289 return (jj_ntk = (token.next=token_source.getNextToken()).kind); |
|
290 else |
|
291 return (jj_ntk = jj_nt.kind); |
|
292 } |
|
293 |
|
294 private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); |
257 private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); |
295 private int[] jj_expentry; |
258 private int[] jj_expentry; |
296 private int jj_kind = -1; |
259 private int jj_kind = -1; |
297 |
260 |
298 /** Generate ParseException. */ |
261 /** Generate ParseException. */ |
299 public ParseException generateParseException() { |
262 public ParseException generateParseException() { |
300 jj_expentries.clear(); |
263 jj_expentries.clear(); |
301 boolean[] la1tokens = new boolean[23]; |
264 boolean[] la1tokens = new boolean[22]; |
302 if (jj_kind >= 0) { |
265 if (jj_kind >= 0) { |
303 la1tokens[jj_kind] = true; |
266 la1tokens[jj_kind] = true; |
304 jj_kind = -1; |
267 jj_kind = -1; |
305 } |
268 } |
306 for (int i = 0; i < 6; i++) { |
269 for (int i = 0; i < 4; i++) { |
307 if (jj_la1[i] == jj_gen) { |
270 if (jj_la1[i] == jj_gen) { |
308 for (int j = 0; j < 32; j++) { |
271 for (int j = 0; j < 32; j++) { |
309 if ((jj_la1_0[i] & (1<<j)) != 0) { |
272 if ((jj_la1_0[i] & (1<<j)) != 0) { |
310 la1tokens[j] = true; |
273 la1tokens[j] = true; |
311 } |
274 } |
312 } |
275 } |
313 } |
276 } |
314 } |
277 } |
315 for (int i = 0; i < 23; i++) { |
278 for (int i = 0; i < 22; i++) { |
316 if (la1tokens[i]) { |
279 if (la1tokens[i]) { |
317 jj_expentry = new int[1]; |
280 jj_expentry = new int[1]; |
318 jj_expentry[0] = i; |
281 jj_expentry[0] = i; |
319 jj_expentries.add(jj_expentry); |
282 jj_expentries.add(jj_expentry); |
320 } |
283 } |