This project has retired. For details please refer to its
Attic page.
Yylex xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.commons.impl.json.parser;
20
21 import java.math.BigDecimal;
22 import java.math.BigInteger;
23
24
25
26
27
28 class Yylex {
29
30
31 public static final int YYEOF = -1;
32
33
34 private static final int ZZ_BUFFERSIZE = 16384;
35
36
37 public static final int YYINITIAL = 0;
38 public static final int STRING_BEGIN = 2;
39
40
41
42
43
44
45 private static final int ZZ_LEXSTATE[] = { 0, 0, 1, 1 };
46
47
48
49
50 private static final String ZZ_CMAP_PACKED = "\11\0\1\7\1\7\2\0\1\7\22\0\1\7\1\0\1\11\10\0"
51 + "\1\6\1\31\1\2\1\4\1\12\12\3\1\32\6\0\4\1\1\5" + "\1\1\24\0\1\27\1\10\1\30\3\0\1\22\1\13\2\1\1\21"
52 + "\1\14\5\0\1\23\1\0\1\15\3\0\1\16\1\24\1\17\1\20" + "\5\0\1\25\1\0\1\26\uff82\0";
53
54
55
56
57 private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
58
59
60
61
62 private static final int[] ZZ_ACTION = zzUnpackAction();
63
64 private static final String ZZ_ACTION_PACKED_0 = "\2\0\2\1\1\2\1\3\1\4\3\1\1\5\1\6"
65 + "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\5\0" + "\1\14\1\16\1\17\1\20\1\21\1\22\1\23\1\24"
66 + "\1\0\1\25\1\0\1\25\4\0\1\26\1\27\2\0" + "\1\30";
67
68 private static int[] zzUnpackAction() {
69 int[] result = new int[45];
70 int offset = 0;
71 offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
72 return result;
73 }
74
75 private static int zzUnpackAction(String packed, int offset, int[] result) {
76 int i = 0;
77 int j = offset;
78 int l = packed.length();
79 while (i < l) {
80 int count = packed.charAt(i++);
81 int value = packed.charAt(i++);
82 do
83 result[j++] = value;
84 while (--count > 0);
85 }
86 return j;
87 }
88
89
90
91
92 private static final int[] ZZ_ROWMAP = zzUnpackRowMap();
93
94 private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\33\0\66\0\121\0\154\0\207\0\66\0\242"
95 + "\0\275\0\330\0\66\0\66\0\66\0\66\0\66\0\66"
96 + "\0\363\0\u010e\0\66\0\u0129\0\u0144\0\u015f\0\u017a\0\u0195"
97 + "\0\66\0\66\0\66\0\66\0\66\0\66\0\66\0\66"
98 + "\0\u01b0\0\u01cb\0\u01e6\0\u01e6\0\u0201\0\u021c\0\u0237\0\u0252" + "\0\66\0\66\0\u026d\0\u0288\0\66";
99
100 private static int[] zzUnpackRowMap() {
101 int[] result = new int[45];
102 int offset = 0;
103 offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
104 return result;
105 }
106
107 private static int zzUnpackRowMap(String packed, int offset, int[] result) {
108 int i = 0;
109 int j = offset;
110 int l = packed.length();
111 while (i < l) {
112 int high = packed.charAt(i++) << 16;
113 result[j++] = high | packed.charAt(i++);
114 }
115 return j;
116 }
117
118
119
120
121 private static final int ZZ_TRANS[] = { 2, 2, 3, 4, 2, 2, 2, 5, 2, 6, 2, 2, 7, 8, 2, 9, 2, 2, 2, 2, 2, 10, 11, 12,
122 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
123 16, 16, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
124 -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
125 -1, -1, -1, -1, -1, -1, 4, 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, -1, -1, -1, -1, -1, -1,
126 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
127 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, -1, -1, -1, -1, -1,
128 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, -1,
129 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1,
130 -1, -1, -1, 16, 16, 16, 16, 16, 16, 16, 16, -1, -1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
131 16, 16, 16, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, -1,
132 -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
133 -1, -1, -1, -1, -1, 34, 35, -1, -1, 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
134 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, -1, -1,
135 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
136 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 38, -1, -1, -1, -1, -1, -1, -1,
137 -1, -1, -1, -1, 39, -1, 39, -1, 39, -1, -1, -1, -1, -1, 39, 39, -1, -1, -1, -1, 39, 39, -1, -1, -1, -1, -1,
138 -1, -1, -1, -1, -1, -1, 33, -1, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, -1, -1, -1, -1, -1, -1,
139 -1, -1, -1, -1, -1, -1, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
140 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 38, -1, -1, -1,
141 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 40, -1, -1, -1, -1,
142 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, -1, -1, -1, -1, -1, -1,
143 -1, -1, -1, -1, 42, -1, 42, -1, 42, -1, -1, -1, -1, -1, 42, 42, -1, -1, -1, -1, 42, 42, -1, -1, -1, -1, -1,
144 -1, -1, -1, -1, 43, -1, 43, -1, 43, -1, -1, -1, -1, -1, 43, 43, -1, -1, -1, -1, 43, 43, -1, -1, -1, -1, -1,
145 -1, -1, -1, -1, 44, -1, 44, -1, 44, -1, -1, -1, -1, -1, 44, 44, -1, -1, -1, -1, 44, 44, -1, -1, -1, -1, -1,
146 -1, -1, -1, };
147
148
149 private static final int ZZ_UNKNOWN_ERROR = 0;
150 private static final int ZZ_NO_MATCH = 1;
151 private static final int ZZ_PUSHBACK_2BIG = 2;
152
153
154 private static final String ZZ_ERROR_MSG[] = { "Unkown internal scanner error", "Error: could not match input",
155 "Error: pushback value was too large" };
156
157
158
159
160 private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute();
161
162 private static final String ZZ_ATTRIBUTE_PACKED_0 = "\2\0\1\11\3\1\1\11\3\1\6\11\2\1\1\11"
163 + "\5\0\10\11\1\0\1\1\1\0\1\1\4\0\2\11" + "\2\0\1\11";
164
165 private static int[] zzUnpackAttribute() {
166 int[] result = new int[45];
167 int offset = 0;
168 offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
169 return result;
170 }
171
172 private static int zzUnpackAttribute(String packed, int offset, int[] result) {
173 int i = 0;
174 int j = offset;
175 int l = packed.length();
176 while (i < l) {
177 int count = packed.charAt(i++);
178 int value = packed.charAt(i++);
179 do
180 result[j++] = value;
181 while (--count > 0);
182 }
183 return j;
184 }
185
186
187 private java.io.Reader zzReader;
188
189
190 private int zzState;
191
192
193 private int zzLexicalState = YYINITIAL;
194
195
196
197
198
199 private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
200
201
202 private int zzMarkedPos;
203
204
205 private int zzCurrentPos;
206
207
208 private int zzStartRead;
209
210
211
212
213
214 private int zzEndRead;
215
216
217 private int yychar;
218
219
220 private boolean zzAtEOF;
221
222
223 private StringBuilder sb = new StringBuilder();
224
225 int getPosition() {
226 return yychar;
227 }
228
229
230
231
232
233
234
235
236 Yylex(java.io.Reader in) {
237 this.zzReader = in;
238 }
239
240
241
242
243
244
245
246
247 Yylex(java.io.InputStream in) {
248 this(new java.io.InputStreamReader(in));
249 }
250
251
252
253
254
255
256
257
258 private static char[] zzUnpackCMap(String packed) {
259 char[] map = new char[0x10000];
260 int i = 0;
261 int j = 0;
262 while (i < 90) {
263 int count = packed.charAt(i++);
264 char value = packed.charAt(i++);
265 do
266 map[j++] = value;
267 while (--count > 0);
268 }
269 return map;
270 }
271
272
273
274
275
276
277
278
279
280 private boolean zzRefill() throws java.io.IOException {
281
282
283 if (zzStartRead > 0) {
284 System.arraycopy(zzBuffer, zzStartRead, zzBuffer, 0, zzEndRead - zzStartRead);
285
286
287 zzEndRead -= zzStartRead;
288 zzCurrentPos -= zzStartRead;
289 zzMarkedPos -= zzStartRead;
290 zzStartRead = 0;
291 }
292
293
294 if (zzCurrentPos >= zzBuffer.length) {
295
296 char newBuffer[] = new char[zzCurrentPos * 2];
297 System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
298 zzBuffer = newBuffer;
299 }
300
301
302 int numRead = zzReader.read(zzBuffer, zzEndRead, zzBuffer.length - zzEndRead);
303
304 if (numRead > 0) {
305 zzEndRead += numRead;
306 return false;
307 }
308
309
310 if (numRead == 0) {
311 int c = zzReader.read();
312 if (c == -1) {
313 return true;
314 } else {
315 zzBuffer[zzEndRead++] = (char) c;
316 return false;
317 }
318 }
319
320
321 return true;
322 }
323
324
325
326
327 public final void yyclose() throws java.io.IOException {
328 zzAtEOF = true;
329 zzEndRead = zzStartRead;
330
331 if (zzReader != null)
332 zzReader.close();
333 }
334
335
336
337
338
339
340
341
342
343
344
345
346 public final void yyreset(java.io.Reader reader) {
347 zzReader = reader;
348 zzAtEOF = false;
349 zzEndRead = zzStartRead = 0;
350 zzCurrentPos = zzMarkedPos = 0;
351 yychar = 0;
352 zzLexicalState = YYINITIAL;
353 }
354
355
356
357
358 public final int yystate() {
359 return zzLexicalState;
360 }
361
362
363
364
365
366
367
368 public final void yybegin(int newState) {
369 zzLexicalState = newState;
370 }
371
372
373
374
375 public final String yytext() {
376 return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
377 }
378
379
380
381
382
383
384
385
386
387
388
389
390 public final char yycharat(int pos) {
391 return zzBuffer[zzStartRead + pos];
392 }
393
394
395
396
397 public final int yylength() {
398 return zzMarkedPos - zzStartRead;
399 }
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415 private void zzScanError(int errorCode) {
416 String message;
417 try {
418 message = ZZ_ERROR_MSG[errorCode];
419 } catch (ArrayIndexOutOfBoundsException e) {
420 message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
421 }
422
423 throw new Error(message);
424 }
425
426
427
428
429
430
431
432
433
434
435 public void yypushback(int number) {
436 if (number > yylength())
437 zzScanError(ZZ_PUSHBACK_2BIG);
438
439 zzMarkedPos -= number;
440 }
441
442
443
444
445
446
447
448
449
450 public Yytoken yylex() throws java.io.IOException, JSONParseException {
451 int zzInput;
452 int zzAction;
453
454
455 int zzCurrentPosL;
456 int zzMarkedPosL;
457 int zzEndReadL = zzEndRead;
458 char[] zzBufferL = zzBuffer;
459 char[] zzCMapL = ZZ_CMAP;
460
461 int[] zzTransL = ZZ_TRANS;
462 int[] zzRowMapL = ZZ_ROWMAP;
463 int[] zzAttrL = ZZ_ATTRIBUTE;
464
465 while (true) {
466 zzMarkedPosL = zzMarkedPos;
467
468 yychar += zzMarkedPosL - zzStartRead;
469
470 zzAction = -1;
471
472 zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
473
474 zzState = ZZ_LEXSTATE[zzLexicalState];
475
476 zzForAction: {
477 while (true) {
478
479 if (zzCurrentPosL < zzEndReadL)
480 zzInput = zzBufferL[zzCurrentPosL++];
481 else if (zzAtEOF) {
482 zzInput = YYEOF;
483 break zzForAction;
484 } else {
485
486 zzCurrentPos = zzCurrentPosL;
487 zzMarkedPos = zzMarkedPosL;
488 boolean eof = zzRefill();
489
490 zzCurrentPosL = zzCurrentPos;
491 zzMarkedPosL = zzMarkedPos;
492 zzBufferL = zzBuffer;
493 zzEndReadL = zzEndRead;
494 if (eof) {
495 zzInput = YYEOF;
496 break zzForAction;
497 } else {
498 zzInput = zzBufferL[zzCurrentPosL++];
499 }
500 }
501 int zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]];
502 if (zzNext == -1)
503 break zzForAction;
504 zzState = zzNext;
505
506 int zzAttributes = zzAttrL[zzState];
507 if ((zzAttributes & 1) == 1) {
508 zzAction = zzState;
509 zzMarkedPosL = zzCurrentPosL;
510 if ((zzAttributes & 8) == 8)
511 break zzForAction;
512 }
513
514 }
515 }
516
517
518 zzMarkedPos = zzMarkedPosL;
519
520 switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
521 case 11: {
522 sb.append(yytext());
523 }
524 case 25:
525 break;
526 case 4: {
527 sb.delete(0, sb.length());
528 yybegin(STRING_BEGIN);
529 }
530 case 26:
531 break;
532 case 16: {
533 sb.append('\b');
534 }
535 case 27:
536 break;
537 case 6: {
538 return new Yytoken(Yytoken.TYPE_RIGHT_BRACE, null);
539 }
540 case 28:
541 break;
542 case 23: {
543 Boolean val = Boolean.valueOf(yytext());
544 return new Yytoken(Yytoken.TYPE_VALUE, val);
545 }
546 case 29:
547 break;
548 case 22: {
549 return new Yytoken(Yytoken.TYPE_VALUE, null);
550 }
551 case 30:
552 break;
553 case 13: {
554 yybegin(YYINITIAL);
555 return new Yytoken(Yytoken.TYPE_VALUE, sb.toString());
556 }
557 case 31:
558 break;
559 case 12: {
560 sb.append('\\');
561 }
562 case 32:
563 break;
564 case 21: {
565 BigDecimal val = new BigDecimal(yytext());
566 return new Yytoken(Yytoken.TYPE_VALUE, val);
567 }
568 case 33:
569 break;
570 case 1: {
571 throw new JSONParseException(yychar, JSONParseException.ERROR_UNEXPECTED_CHAR, new Character(yycharat(0)));
572 }
573 case 34:
574 break;
575 case 8: {
576 return new Yytoken(Yytoken.TYPE_RIGHT_SQUARE, null);
577 }
578 case 35:
579 break;
580 case 19: {
581 sb.append('\r');
582 }
583 case 36:
584 break;
585 case 15: {
586 sb.append('/');
587 }
588 case 37:
589 break;
590 case 10: {
591 return new Yytoken(Yytoken.TYPE_COLON, null);
592 }
593 case 38:
594 break;
595 case 14: {
596 sb.append('"');
597 }
598 case 39:
599 break;
600 case 5: {
601 return new Yytoken(Yytoken.TYPE_LEFT_BRACE, null);
602 }
603 case 40:
604 break;
605 case 17: {
606 sb.append('\f');
607 }
608 case 41:
609 break;
610 case 24: {
611 try {
612 int ch = Integer.parseInt(yytext().substring(2), 16);
613 sb.append((char) ch);
614 } catch (Exception e) {
615 throw new JSONParseException(yychar, JSONParseException.ERROR_UNEXPECTED_EXCEPTION, e);
616 }
617 }
618 case 42:
619 break;
620 case 20: {
621 sb.append('\t');
622 }
623 case 43:
624 break;
625 case 7: {
626 return new Yytoken(Yytoken.TYPE_LEFT_SQUARE, null);
627 }
628 case 44:
629 break;
630 case 2: {
631 BigInteger val = new BigInteger(yytext());
632 return new Yytoken(Yytoken.TYPE_VALUE, val);
633 }
634 case 45:
635 break;
636 case 18: {
637 sb.append('\n');
638 }
639 case 46:
640 break;
641 case 9: {
642 return new Yytoken(Yytoken.TYPE_COMMA, null);
643 }
644 case 47:
645 break;
646 case 3: {
647 }
648 case 48:
649 break;
650 default:
651 if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
652 zzAtEOF = true;
653 return null;
654 } else {
655 zzScanError(ZZ_NO_MATCH);
656 }
657 }
658 }
659 }
660 }