1 /* Generated by re2c 0.16 */
2 /*
3 +----------------------------------------------------------------------+
4 | PHP Version 7 |
5 +----------------------------------------------------------------------+
6 | Copyright (c) 1997-2017 The PHP Group |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 3.01 of the PHP license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.php.net/license/3_01.txt |
12 | If you did not receive a copy of the PHP license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@php.net so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
16 | Author: Jakub Zelenka <bukka@php.net> |
17 +----------------------------------------------------------------------+
18 */
19
20 #include "php.h"
21 #include "php_json_scanner.h"
22 #include "php_json_scanner_defs.h"
23 #include "php_json_parser.h"
24 #include "json_parser.tab.h"
25
26 #define YYCTYPE php_json_ctype
27 #define YYCURSOR s->cursor
28 #define YYLIMIT s->limit
29 #define YYMARKER s->marker
30 #define YYCTXMARKER s->ctxmarker
31
32 #define YYGETCONDITION() s->state
33 #define YYSETCONDITION(yystate) s->state = yystate
34
35 #define YYFILL(n)
36
37 #define PHP_JSON_CONDITION_SET(condition) YYSETCONDITION(yyc##condition)
38 #define PHP_JSON_CONDITION_GOTO(condition) goto yyc_##condition
39
40 #define PHP_JSON_SCANNER_COPY_ESC() php_json_scanner_copy_string(s, 0)
41 #define PHP_JSON_SCANNER_COPY_UTF() php_json_scanner_copy_string(s, 5)
42 #define PHP_JSON_SCANNER_COPY_UTF_SP() php_json_scanner_copy_string(s, 11)
43
44 #define PHP_JSON_INT_MAX_LENGTH (MAX_LENGTH_OF_LONG - 1)
45
46
php_json_scanner_copy_string(php_json_scanner * s,int esc_size)47 static void php_json_scanner_copy_string(php_json_scanner *s, int esc_size)
48 {
49 size_t len = s->cursor - s->str_start - esc_size - 1;
50 if (len) {
51 memcpy(s->pstr, s->str_start, len);
52 s->pstr += len;
53 }
54 }
55
php_json_hex_to_int(char code)56 static int php_json_hex_to_int(char code)
57 {
58 if (code >= '0' && code <= '9') {
59 return code - '0';
60 } else if (code >= 'A' && code <= 'F') {
61 return code - ('A' - 10);
62 } else if (code >= 'a' && code <= 'f') {
63 return code - ('a' - 10);
64 } else {
65 /* this should never happened (just to suppress compiler warning) */
66 return -1;
67 }
68 }
69
php_json_ucs2_to_int_ex(php_json_scanner * s,int size,int start)70 static int php_json_ucs2_to_int_ex(php_json_scanner *s, int size, int start)
71 {
72 int i, code = 0;
73 php_json_ctype *pc = s->cursor - start;
74 for (i = 0; i < size; i++) {
75 code |= php_json_hex_to_int(*(pc--)) << (i * 4);
76 }
77 return code;
78 }
79
php_json_ucs2_to_int(php_json_scanner * s,int size)80 static int php_json_ucs2_to_int(php_json_scanner *s, int size)
81 {
82 return php_json_ucs2_to_int_ex(s, size, 1);
83 }
84
php_json_scanner_init(php_json_scanner * s,char * str,size_t str_len,int options)85 void php_json_scanner_init(php_json_scanner *s, char *str, size_t str_len, int options)
86 {
87 s->cursor = (php_json_ctype *) str;
88 s->limit = (php_json_ctype *) str + str_len;
89 s->options = options;
90 PHP_JSON_CONDITION_SET(JS);
91 }
92
php_json_scan(php_json_scanner * s)93 int php_json_scan(php_json_scanner *s)
94 {
95 ZVAL_NULL(&s->value);
96
97 std:
98 s->token = s->cursor;
99
100
101 {
102 YYCTYPE yych;
103 unsigned int yyaccept = 0;
104 if (YYGETCONDITION() < 1) {
105 goto yyc_JS;
106 } else {
107 if (YYGETCONDITION() < 2) {
108 goto yyc_STR_P1;
109 } else {
110 goto yyc_STR_P2;
111 }
112 }
113 /* *********************************** */
114 yyc_JS:
115 {
116 static const unsigned char yybm[] = {
117 0, 0, 0, 0, 0, 0, 0, 0,
118 0, 64, 0, 0, 0, 64, 0, 0,
119 0, 0, 0, 0, 0, 0, 0, 0,
120 0, 0, 0, 0, 0, 0, 0, 0,
121 64, 0, 0, 0, 0, 0, 0, 0,
122 0, 0, 0, 0, 0, 0, 0, 0,
123 128, 128, 128, 128, 128, 128, 128, 128,
124 128, 128, 0, 0, 0, 0, 0, 0,
125 0, 0, 0, 0, 0, 0, 0, 0,
126 0, 0, 0, 0, 0, 0, 0, 0,
127 0, 0, 0, 0, 0, 0, 0, 0,
128 0, 0, 0, 0, 0, 0, 0, 0,
129 0, 0, 0, 0, 0, 0, 0, 0,
130 0, 0, 0, 0, 0, 0, 0, 0,
131 0, 0, 0, 0, 0, 0, 0, 0,
132 0, 0, 0, 0, 0, 0, 0, 0,
133 0, 0, 0, 0, 0, 0, 0, 0,
134 0, 0, 0, 0, 0, 0, 0, 0,
135 0, 0, 0, 0, 0, 0, 0, 0,
136 0, 0, 0, 0, 0, 0, 0, 0,
137 0, 0, 0, 0, 0, 0, 0, 0,
138 0, 0, 0, 0, 0, 0, 0, 0,
139 0, 0, 0, 0, 0, 0, 0, 0,
140 0, 0, 0, 0, 0, 0, 0, 0,
141 0, 0, 0, 0, 0, 0, 0, 0,
142 0, 0, 0, 0, 0, 0, 0, 0,
143 0, 0, 0, 0, 0, 0, 0, 0,
144 0, 0, 0, 0, 0, 0, 0, 0,
145 0, 0, 0, 0, 0, 0, 0, 0,
146 0, 0, 0, 0, 0, 0, 0, 0,
147 0, 0, 0, 0, 0, 0, 0, 0,
148 0, 0, 0, 0, 0, 0, 0, 0,
149 };
150 yych = *YYCURSOR;
151 if (yych <= ']') {
152 if (yych <= '"') {
153 if (yych <= '\f') {
154 if (yych <= 0x08) {
155 if (yych >= 0x01) goto yy5;
156 } else {
157 if (yych <= '\t') goto yy7;
158 if (yych <= '\n') goto yy10;
159 goto yy5;
160 }
161 } else {
162 if (yych <= 0x1F) {
163 if (yych <= '\r') goto yy11;
164 goto yy5;
165 } else {
166 if (yych <= ' ') goto yy7;
167 if (yych <= '!') goto yy12;
168 goto yy14;
169 }
170 }
171 } else {
172 if (yych <= '0') {
173 if (yych <= ',') {
174 if (yych <= '+') goto yy12;
175 goto yy16;
176 } else {
177 if (yych <= '-') goto yy18;
178 if (yych <= '/') goto yy12;
179 goto yy19;
180 }
181 } else {
182 if (yych <= 'Z') {
183 if (yych <= '9') goto yy21;
184 if (yych <= ':') goto yy23;
185 goto yy12;
186 } else {
187 if (yych <= '[') goto yy25;
188 if (yych <= '\\') goto yy12;
189 goto yy27;
190 }
191 }
192 }
193 } else {
194 if (yych <= '}') {
195 if (yych <= 's') {
196 if (yych <= 'f') {
197 if (yych <= 'e') goto yy12;
198 goto yy29;
199 } else {
200 if (yych == 'n') goto yy30;
201 goto yy12;
202 }
203 } else {
204 if (yych <= 'z') {
205 if (yych <= 't') goto yy31;
206 goto yy12;
207 } else {
208 if (yych <= '{') goto yy32;
209 if (yych <= '|') goto yy12;
210 goto yy34;
211 }
212 }
213 } else {
214 if (yych <= 0xEC) {
215 if (yych <= 0xC1) {
216 if (yych <= 0x7F) goto yy12;
217 goto yy36;
218 } else {
219 if (yych <= 0xDF) goto yy38;
220 if (yych <= 0xE0) goto yy39;
221 goto yy40;
222 }
223 } else {
224 if (yych <= 0xF0) {
225 if (yych <= 0xED) goto yy41;
226 if (yych <= 0xEF) goto yy40;
227 goto yy42;
228 } else {
229 if (yych <= 0xF3) goto yy43;
230 if (yych <= 0xF4) goto yy44;
231 goto yy36;
232 }
233 }
234 }
235 }
236 ++YYCURSOR;
237 {
238 if (s->limit < s->cursor) {
239 return PHP_JSON_T_EOI;
240 } else {
241 s->errcode = PHP_JSON_ERROR_CTRL_CHAR;
242 return PHP_JSON_T_ERROR;
243 }
244 }
245 yy5:
246 ++YYCURSOR;
247 {
248 s->errcode = PHP_JSON_ERROR_CTRL_CHAR;
249 return PHP_JSON_T_ERROR;
250 }
251 yy7:
252 ++YYCURSOR;
253 yych = *YYCURSOR;
254 yy8:
255 if (yybm[0+yych] & 64) {
256 goto yy7;
257 }
258 yy9:
259 { goto std; }
260 yy10:
261 yych = *++YYCURSOR;
262 goto yy9;
263 yy11:
264 yych = *++YYCURSOR;
265 if (yych == '\n') goto yy10;
266 goto yy8;
267 yy12:
268 ++YYCURSOR;
269 yy13:
270 {
271 s->errcode = PHP_JSON_ERROR_SYNTAX;
272 return PHP_JSON_T_ERROR;
273 }
274 yy14:
275 ++YYCURSOR;
276 {
277 s->str_start = s->cursor;
278 s->str_esc = 0;
279 PHP_JSON_CONDITION_SET(STR_P1);
280 PHP_JSON_CONDITION_GOTO(STR_P1);
281 }
282 yy16:
283 ++YYCURSOR;
284 { return ','; }
285 yy18:
286 yych = *++YYCURSOR;
287 if (yych <= '/') goto yy13;
288 if (yych <= '0') goto yy19;
289 if (yych <= '9') goto yy21;
290 goto yy13;
291 yy19:
292 yyaccept = 0;
293 yych = *(YYMARKER = ++YYCURSOR);
294 if (yych <= 'D') {
295 if (yych == '.') goto yy45;
296 } else {
297 if (yych <= 'E') goto yy47;
298 if (yych == 'e') goto yy47;
299 }
300 yy20:
301 {
302 zend_bool bigint = 0, negative = s->token[0] == '-';
303 size_t digits = (size_t) (s->cursor - s->token - negative);
304 if (digits >= PHP_JSON_INT_MAX_LENGTH) {
305 if (digits == PHP_JSON_INT_MAX_LENGTH) {
306 int cmp = strncmp((char *) (s->token + negative), LONG_MIN_DIGITS, PHP_JSON_INT_MAX_LENGTH);
307 if (!(cmp < 0 || (cmp == 0 && negative))) {
308 bigint = 1;
309 }
310 } else {
311 bigint = 1;
312 }
313 }
314 if (!bigint) {
315 ZVAL_LONG(&s->value, ZEND_STRTOL((char *) s->token, NULL, 10));
316 return PHP_JSON_T_INT;
317 } else if (s->options & PHP_JSON_BIGINT_AS_STRING) {
318 ZVAL_STRINGL(&s->value, (char *) s->token, s->cursor - s->token);
319 return PHP_JSON_T_STRING;
320 } else {
321 ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL));
322 return PHP_JSON_T_DOUBLE;
323 }
324 }
325 yy21:
326 yyaccept = 0;
327 YYMARKER = ++YYCURSOR;
328 yych = *YYCURSOR;
329 if (yybm[0+yych] & 128) {
330 goto yy21;
331 }
332 if (yych <= 'D') {
333 if (yych == '.') goto yy45;
334 goto yy20;
335 } else {
336 if (yych <= 'E') goto yy47;
337 if (yych == 'e') goto yy47;
338 goto yy20;
339 }
340 yy23:
341 ++YYCURSOR;
342 { return ':'; }
343 yy25:
344 ++YYCURSOR;
345 { return '['; }
346 yy27:
347 ++YYCURSOR;
348 { return ']'; }
349 yy29:
350 yyaccept = 1;
351 yych = *(YYMARKER = ++YYCURSOR);
352 if (yych == 'a') goto yy48;
353 goto yy13;
354 yy30:
355 yyaccept = 1;
356 yych = *(YYMARKER = ++YYCURSOR);
357 if (yych == 'u') goto yy49;
358 goto yy13;
359 yy31:
360 yyaccept = 1;
361 yych = *(YYMARKER = ++YYCURSOR);
362 if (yych == 'r') goto yy50;
363 goto yy13;
364 yy32:
365 ++YYCURSOR;
366 { return '{'; }
367 yy34:
368 ++YYCURSOR;
369 { return '}'; }
370 yy36:
371 ++YYCURSOR;
372 yy37:
373 {
374 s->errcode = PHP_JSON_ERROR_UTF8;
375 return PHP_JSON_T_ERROR;
376 }
377 yy38:
378 yych = *++YYCURSOR;
379 if (yych <= 0x7F) goto yy37;
380 if (yych <= 0xBF) goto yy12;
381 goto yy37;
382 yy39:
383 yyaccept = 2;
384 yych = *(YYMARKER = ++YYCURSOR);
385 if (yych <= 0x9F) goto yy37;
386 if (yych <= 0xBF) goto yy51;
387 goto yy37;
388 yy40:
389 yyaccept = 2;
390 yych = *(YYMARKER = ++YYCURSOR);
391 if (yych <= 0x7F) goto yy37;
392 if (yych <= 0xBF) goto yy51;
393 goto yy37;
394 yy41:
395 yyaccept = 2;
396 yych = *(YYMARKER = ++YYCURSOR);
397 if (yych <= 0x7F) goto yy37;
398 if (yych <= 0x9F) goto yy51;
399 goto yy37;
400 yy42:
401 yyaccept = 2;
402 yych = *(YYMARKER = ++YYCURSOR);
403 if (yych <= 0x8F) goto yy37;
404 if (yych <= 0xBF) goto yy52;
405 goto yy37;
406 yy43:
407 yyaccept = 2;
408 yych = *(YYMARKER = ++YYCURSOR);
409 if (yych <= 0x7F) goto yy37;
410 if (yych <= 0xBF) goto yy52;
411 goto yy37;
412 yy44:
413 yyaccept = 2;
414 yych = *(YYMARKER = ++YYCURSOR);
415 if (yych <= 0x7F) goto yy37;
416 if (yych <= 0x8F) goto yy52;
417 goto yy37;
418 yy45:
419 yych = *++YYCURSOR;
420 if (yych <= '/') goto yy46;
421 if (yych <= '9') goto yy53;
422 yy46:
423 YYCURSOR = YYMARKER;
424 if (yyaccept <= 1) {
425 if (yyaccept == 0) {
426 goto yy20;
427 } else {
428 goto yy13;
429 }
430 } else {
431 if (yyaccept == 2) {
432 goto yy37;
433 } else {
434 goto yy55;
435 }
436 }
437 yy47:
438 yych = *++YYCURSOR;
439 if (yych <= ',') {
440 if (yych == '+') goto yy56;
441 goto yy46;
442 } else {
443 if (yych <= '-') goto yy56;
444 if (yych <= '/') goto yy46;
445 if (yych <= '9') goto yy57;
446 goto yy46;
447 }
448 yy48:
449 yych = *++YYCURSOR;
450 if (yych == 'l') goto yy59;
451 goto yy46;
452 yy49:
453 yych = *++YYCURSOR;
454 if (yych == 'l') goto yy60;
455 goto yy46;
456 yy50:
457 yych = *++YYCURSOR;
458 if (yych == 'u') goto yy61;
459 goto yy46;
460 yy51:
461 yych = *++YYCURSOR;
462 if (yych <= 0x7F) goto yy46;
463 if (yych <= 0xBF) goto yy12;
464 goto yy46;
465 yy52:
466 yych = *++YYCURSOR;
467 if (yych <= 0x7F) goto yy46;
468 if (yych <= 0xBF) goto yy51;
469 goto yy46;
470 yy53:
471 yyaccept = 3;
472 YYMARKER = ++YYCURSOR;
473 yych = *YYCURSOR;
474 if (yych <= 'D') {
475 if (yych <= '/') goto yy55;
476 if (yych <= '9') goto yy53;
477 } else {
478 if (yych <= 'E') goto yy47;
479 if (yych == 'e') goto yy47;
480 }
481 yy55:
482 {
483 ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL));
484 return PHP_JSON_T_DOUBLE;
485 }
486 yy56:
487 yych = *++YYCURSOR;
488 if (yych <= '/') goto yy46;
489 if (yych >= ':') goto yy46;
490 yy57:
491 ++YYCURSOR;
492 yych = *YYCURSOR;
493 if (yych <= '/') goto yy55;
494 if (yych <= '9') goto yy57;
495 goto yy55;
496 yy59:
497 yych = *++YYCURSOR;
498 if (yych == 's') goto yy62;
499 goto yy46;
500 yy60:
501 yych = *++YYCURSOR;
502 if (yych == 'l') goto yy63;
503 goto yy46;
504 yy61:
505 yych = *++YYCURSOR;
506 if (yych == 'e') goto yy65;
507 goto yy46;
508 yy62:
509 yych = *++YYCURSOR;
510 if (yych == 'e') goto yy67;
511 goto yy46;
512 yy63:
513 ++YYCURSOR;
514 {
515 ZVAL_NULL(&s->value);
516 return PHP_JSON_T_NUL;
517 }
518 yy65:
519 ++YYCURSOR;
520 {
521 ZVAL_TRUE(&s->value);
522 return PHP_JSON_T_TRUE;
523 }
524 yy67:
525 ++YYCURSOR;
526 {
527 ZVAL_FALSE(&s->value);
528 return PHP_JSON_T_FALSE;
529 }
530 }
531 /* *********************************** */
532 yyc_STR_P1:
533 yych = *YYCURSOR;
534 if (yych <= 0xDF) {
535 if (yych <= '[') {
536 if (yych <= 0x1F) goto yy71;
537 if (yych == '"') goto yy75;
538 goto yy73;
539 } else {
540 if (yych <= '\\') goto yy77;
541 if (yych <= 0x7F) goto yy73;
542 if (yych <= 0xC1) goto yy79;
543 goto yy81;
544 }
545 } else {
546 if (yych <= 0xEF) {
547 if (yych <= 0xE0) goto yy82;
548 if (yych == 0xED) goto yy84;
549 goto yy83;
550 } else {
551 if (yych <= 0xF0) goto yy85;
552 if (yych <= 0xF3) goto yy86;
553 if (yych <= 0xF4) goto yy87;
554 goto yy79;
555 }
556 }
557 yy71:
558 ++YYCURSOR;
559 {
560 s->errcode = PHP_JSON_ERROR_CTRL_CHAR;
561 return PHP_JSON_T_ERROR;
562 }
563 yy73:
564 ++YYCURSOR;
565 { PHP_JSON_CONDITION_GOTO(STR_P1); }
566 yy75:
567 ++YYCURSOR;
568 {
569 zend_string *str;
570 size_t len = s->cursor - s->str_start - s->str_esc - 1;
571 if (len == 0) {
572 PHP_JSON_CONDITION_SET(JS);
573 ZVAL_EMPTY_STRING(&s->value);
574 return PHP_JSON_T_ESTRING;
575 }
576 str = zend_string_alloc(len, 0);
577 ZSTR_VAL(str)[len] = '\0';
578 ZVAL_STR(&s->value, str);
579 if (s->str_esc) {
580 s->pstr = (php_json_ctype *) Z_STRVAL(s->value);
581 s->cursor = s->str_start;
582 PHP_JSON_CONDITION_SET(STR_P2);
583 PHP_JSON_CONDITION_GOTO(STR_P2);
584 } else {
585 memcpy(Z_STRVAL(s->value), s->str_start, len);
586 PHP_JSON_CONDITION_SET(JS);
587 return PHP_JSON_T_STRING;
588 }
589 }
590 yy77:
591 yyaccept = 0;
592 yych = *(YYMARKER = ++YYCURSOR);
593 if (yych <= 'e') {
594 if (yych <= '/') {
595 if (yych == '"') goto yy88;
596 if (yych >= '/') goto yy88;
597 } else {
598 if (yych <= '\\') {
599 if (yych >= '\\') goto yy88;
600 } else {
601 if (yych == 'b') goto yy88;
602 }
603 }
604 } else {
605 if (yych <= 'q') {
606 if (yych <= 'f') goto yy88;
607 if (yych == 'n') goto yy88;
608 } else {
609 if (yych <= 's') {
610 if (yych <= 'r') goto yy88;
611 } else {
612 if (yych <= 't') goto yy88;
613 if (yych <= 'u') goto yy90;
614 }
615 }
616 }
617 yy78:
618 {
619 s->errcode = PHP_JSON_ERROR_SYNTAX;
620 return PHP_JSON_T_ERROR;
621 }
622 yy79:
623 ++YYCURSOR;
624 yy80:
625 {
626 s->errcode = PHP_JSON_ERROR_UTF8;
627 return PHP_JSON_T_ERROR;
628 }
629 yy81:
630 yych = *++YYCURSOR;
631 if (yych <= 0x7F) goto yy80;
632 if (yych <= 0xBF) goto yy73;
633 goto yy80;
634 yy82:
635 yyaccept = 1;
636 yych = *(YYMARKER = ++YYCURSOR);
637 if (yych <= 0x9F) goto yy80;
638 if (yych <= 0xBF) goto yy92;
639 goto yy80;
640 yy83:
641 yyaccept = 1;
642 yych = *(YYMARKER = ++YYCURSOR);
643 if (yych <= 0x7F) goto yy80;
644 if (yych <= 0xBF) goto yy92;
645 goto yy80;
646 yy84:
647 yyaccept = 1;
648 yych = *(YYMARKER = ++YYCURSOR);
649 if (yych <= 0x7F) goto yy80;
650 if (yych <= 0x9F) goto yy92;
651 goto yy80;
652 yy85:
653 yyaccept = 1;
654 yych = *(YYMARKER = ++YYCURSOR);
655 if (yych <= 0x8F) goto yy80;
656 if (yych <= 0xBF) goto yy93;
657 goto yy80;
658 yy86:
659 yyaccept = 1;
660 yych = *(YYMARKER = ++YYCURSOR);
661 if (yych <= 0x7F) goto yy80;
662 if (yych <= 0xBF) goto yy93;
663 goto yy80;
664 yy87:
665 yyaccept = 1;
666 yych = *(YYMARKER = ++YYCURSOR);
667 if (yych <= 0x7F) goto yy80;
668 if (yych <= 0x8F) goto yy93;
669 goto yy80;
670 yy88:
671 ++YYCURSOR;
672 {
673 s->str_esc++;
674 PHP_JSON_CONDITION_GOTO(STR_P1);
675 }
676 yy90:
677 yych = *++YYCURSOR;
678 if (yych <= 'D') {
679 if (yych <= '9') {
680 if (yych <= '/') goto yy91;
681 if (yych <= '0') goto yy94;
682 goto yy95;
683 } else {
684 if (yych <= '@') goto yy91;
685 if (yych <= 'C') goto yy95;
686 goto yy96;
687 }
688 } else {
689 if (yych <= 'c') {
690 if (yych <= 'F') goto yy95;
691 if (yych >= 'a') goto yy95;
692 } else {
693 if (yych <= 'd') goto yy96;
694 if (yych <= 'f') goto yy95;
695 }
696 }
697 yy91:
698 YYCURSOR = YYMARKER;
699 if (yyaccept <= 1) {
700 if (yyaccept == 0) {
701 goto yy78;
702 } else {
703 goto yy80;
704 }
705 } else {
706 goto yy114;
707 }
708 yy92:
709 yych = *++YYCURSOR;
710 if (yych <= 0x7F) goto yy91;
711 if (yych <= 0xBF) goto yy73;
712 goto yy91;
713 yy93:
714 yych = *++YYCURSOR;
715 if (yych <= 0x7F) goto yy91;
716 if (yych <= 0xBF) goto yy92;
717 goto yy91;
718 yy94:
719 yych = *++YYCURSOR;
720 if (yych <= '9') {
721 if (yych <= '/') goto yy91;
722 if (yych <= '0') goto yy97;
723 if (yych <= '7') goto yy98;
724 goto yy99;
725 } else {
726 if (yych <= 'F') {
727 if (yych <= '@') goto yy91;
728 goto yy99;
729 } else {
730 if (yych <= '`') goto yy91;
731 if (yych <= 'f') goto yy99;
732 goto yy91;
733 }
734 }
735 yy95:
736 yych = *++YYCURSOR;
737 if (yych <= '@') {
738 if (yych <= '/') goto yy91;
739 if (yych <= '9') goto yy99;
740 goto yy91;
741 } else {
742 if (yych <= 'F') goto yy99;
743 if (yych <= '`') goto yy91;
744 if (yych <= 'f') goto yy99;
745 goto yy91;
746 }
747 yy96:
748 yych = *++YYCURSOR;
749 if (yych <= 'B') {
750 if (yych <= '7') {
751 if (yych <= '/') goto yy91;
752 goto yy99;
753 } else {
754 if (yych <= '9') goto yy100;
755 if (yych <= '@') goto yy91;
756 goto yy100;
757 }
758 } else {
759 if (yych <= '`') {
760 if (yych <= 'F') goto yy101;
761 goto yy91;
762 } else {
763 if (yych <= 'b') goto yy100;
764 if (yych <= 'f') goto yy101;
765 goto yy91;
766 }
767 }
768 yy97:
769 yych = *++YYCURSOR;
770 if (yych <= '@') {
771 if (yych <= '/') goto yy91;
772 if (yych <= '7') goto yy102;
773 if (yych <= '9') goto yy103;
774 goto yy91;
775 } else {
776 if (yych <= 'F') goto yy103;
777 if (yych <= '`') goto yy91;
778 if (yych <= 'f') goto yy103;
779 goto yy91;
780 }
781 yy98:
782 yych = *++YYCURSOR;
783 if (yych <= '@') {
784 if (yych <= '/') goto yy91;
785 if (yych <= '9') goto yy103;
786 goto yy91;
787 } else {
788 if (yych <= 'F') goto yy103;
789 if (yych <= '`') goto yy91;
790 if (yych <= 'f') goto yy103;
791 goto yy91;
792 }
793 yy99:
794 yych = *++YYCURSOR;
795 if (yych <= '@') {
796 if (yych <= '/') goto yy91;
797 if (yych <= '9') goto yy104;
798 goto yy91;
799 } else {
800 if (yych <= 'F') goto yy104;
801 if (yych <= '`') goto yy91;
802 if (yych <= 'f') goto yy104;
803 goto yy91;
804 }
805 yy100:
806 yych = *++YYCURSOR;
807 if (yych <= '@') {
808 if (yych <= '/') goto yy91;
809 if (yych <= '9') goto yy105;
810 goto yy91;
811 } else {
812 if (yych <= 'F') goto yy105;
813 if (yych <= '`') goto yy91;
814 if (yych <= 'f') goto yy105;
815 goto yy91;
816 }
817 yy101:
818 yych = *++YYCURSOR;
819 if (yych <= '@') {
820 if (yych <= '/') goto yy91;
821 if (yych <= '9') goto yy106;
822 goto yy91;
823 } else {
824 if (yych <= 'F') goto yy106;
825 if (yych <= '`') goto yy91;
826 if (yych <= 'f') goto yy106;
827 goto yy91;
828 }
829 yy102:
830 yych = *++YYCURSOR;
831 if (yych <= '@') {
832 if (yych <= '/') goto yy91;
833 if (yych <= '9') goto yy107;
834 goto yy91;
835 } else {
836 if (yych <= 'F') goto yy107;
837 if (yych <= '`') goto yy91;
838 if (yych <= 'f') goto yy107;
839 goto yy91;
840 }
841 yy103:
842 yych = *++YYCURSOR;
843 if (yych <= '@') {
844 if (yych <= '/') goto yy91;
845 if (yych <= '9') goto yy109;
846 goto yy91;
847 } else {
848 if (yych <= 'F') goto yy109;
849 if (yych <= '`') goto yy91;
850 if (yych <= 'f') goto yy109;
851 goto yy91;
852 }
853 yy104:
854 yych = *++YYCURSOR;
855 if (yych <= '@') {
856 if (yych <= '/') goto yy91;
857 if (yych <= '9') goto yy111;
858 goto yy91;
859 } else {
860 if (yych <= 'F') goto yy111;
861 if (yych <= '`') goto yy91;
862 if (yych <= 'f') goto yy111;
863 goto yy91;
864 }
865 yy105:
866 yych = *++YYCURSOR;
867 if (yych <= '@') {
868 if (yych <= '/') goto yy91;
869 if (yych <= '9') goto yy113;
870 goto yy91;
871 } else {
872 if (yych <= 'F') goto yy113;
873 if (yych <= '`') goto yy91;
874 if (yych <= 'f') goto yy113;
875 goto yy91;
876 }
877 yy106:
878 yych = *++YYCURSOR;
879 if (yych <= '@') {
880 if (yych <= '/') goto yy91;
881 if (yych <= '9') goto yy115;
882 goto yy91;
883 } else {
884 if (yych <= 'F') goto yy115;
885 if (yych <= '`') goto yy91;
886 if (yych <= 'f') goto yy115;
887 goto yy91;
888 }
889 yy107:
890 ++YYCURSOR;
891 {
892 s->str_esc += 5;
893 PHP_JSON_CONDITION_GOTO(STR_P1);
894 }
895 yy109:
896 ++YYCURSOR;
897 {
898 s->str_esc += 4;
899 PHP_JSON_CONDITION_GOTO(STR_P1);
900 }
901 yy111:
902 ++YYCURSOR;
903 {
904 s->str_esc += 3;
905 PHP_JSON_CONDITION_GOTO(STR_P1);
906 }
907 yy113:
908 yyaccept = 2;
909 yych = *(YYMARKER = ++YYCURSOR);
910 if (yych == '\\') goto yy116;
911 yy114:
912 {
913 s->errcode = PHP_JSON_ERROR_UTF16;
914 return PHP_JSON_T_ERROR;
915 }
916 yy115:
917 yych = *++YYCURSOR;
918 goto yy114;
919 yy116:
920 yych = *++YYCURSOR;
921 if (yych != 'u') goto yy91;
922 yych = *++YYCURSOR;
923 if (yych == 'D') goto yy118;
924 if (yych != 'd') goto yy91;
925 yy118:
926 yych = *++YYCURSOR;
927 if (yych <= 'B') goto yy91;
928 if (yych <= 'F') goto yy119;
929 if (yych <= 'b') goto yy91;
930 if (yych >= 'g') goto yy91;
931 yy119:
932 yych = *++YYCURSOR;
933 if (yych <= '@') {
934 if (yych <= '/') goto yy91;
935 if (yych >= ':') goto yy91;
936 } else {
937 if (yych <= 'F') goto yy120;
938 if (yych <= '`') goto yy91;
939 if (yych >= 'g') goto yy91;
940 }
941 yy120:
942 yych = *++YYCURSOR;
943 if (yych <= '@') {
944 if (yych <= '/') goto yy91;
945 if (yych >= ':') goto yy91;
946 } else {
947 if (yych <= 'F') goto yy121;
948 if (yych <= '`') goto yy91;
949 if (yych >= 'g') goto yy91;
950 }
951 yy121:
952 ++YYCURSOR;
953 {
954 s->str_esc += 8;
955 PHP_JSON_CONDITION_GOTO(STR_P1);
956 }
957 /* *********************************** */
958 yyc_STR_P2:
959 yych = *YYCURSOR;
960 if (yych == '"') goto yy127;
961 if (yych == '\\') goto yy129;
962 ++YYCURSOR;
963 { PHP_JSON_CONDITION_GOTO(STR_P2); }
964 yy127:
965 ++YYCURSOR;
966 YYSETCONDITION(yycJS);
967 {
968 PHP_JSON_SCANNER_COPY_ESC();
969 return PHP_JSON_T_STRING;
970 }
971 yy129:
972 yych = *(YYMARKER = ++YYCURSOR);
973 if (yych == 'u') goto yy131;
974 yy130:
975 {
976 char esc;
977 PHP_JSON_SCANNER_COPY_ESC();
978 switch (*s->cursor) {
979 case 'b':
980 esc = '\b';
981 break;
982 case 'f':
983 esc = '\f';
984 break;
985 case 'n':
986 esc = '\n';
987 break;
988 case 'r':
989 esc = '\r';
990 break;
991 case 't':
992 esc = '\t';
993 break;
994 case '\\':
995 case '/':
996 case '"':
997 esc = *s->cursor;
998 break;
999 default:
1000 s->errcode = PHP_JSON_ERROR_SYNTAX;
1001 return PHP_JSON_T_ERROR;
1002 }
1003 *(s->pstr++) = esc;
1004 ++YYCURSOR;
1005 s->str_start = s->cursor;
1006 PHP_JSON_CONDITION_GOTO(STR_P2);
1007 }
1008 yy131:
1009 yych = *++YYCURSOR;
1010 if (yych <= 'D') {
1011 if (yych <= '9') {
1012 if (yych <= '/') goto yy132;
1013 if (yych <= '0') goto yy133;
1014 goto yy134;
1015 } else {
1016 if (yych <= '@') goto yy132;
1017 if (yych <= 'C') goto yy134;
1018 goto yy135;
1019 }
1020 } else {
1021 if (yych <= 'c') {
1022 if (yych <= 'F') goto yy134;
1023 if (yych >= 'a') goto yy134;
1024 } else {
1025 if (yych <= 'd') goto yy135;
1026 if (yych <= 'f') goto yy134;
1027 }
1028 }
1029 yy132:
1030 YYCURSOR = YYMARKER;
1031 goto yy130;
1032 yy133:
1033 yych = *++YYCURSOR;
1034 if (yych <= '9') {
1035 if (yych <= '/') goto yy132;
1036 if (yych <= '0') goto yy136;
1037 if (yych <= '7') goto yy137;
1038 goto yy138;
1039 } else {
1040 if (yych <= 'F') {
1041 if (yych <= '@') goto yy132;
1042 goto yy138;
1043 } else {
1044 if (yych <= '`') goto yy132;
1045 if (yych <= 'f') goto yy138;
1046 goto yy132;
1047 }
1048 }
1049 yy134:
1050 yych = *++YYCURSOR;
1051 if (yych <= '@') {
1052 if (yych <= '/') goto yy132;
1053 if (yych <= '9') goto yy138;
1054 goto yy132;
1055 } else {
1056 if (yych <= 'F') goto yy138;
1057 if (yych <= '`') goto yy132;
1058 if (yych <= 'f') goto yy138;
1059 goto yy132;
1060 }
1061 yy135:
1062 yych = *++YYCURSOR;
1063 if (yych <= '@') {
1064 if (yych <= '/') goto yy132;
1065 if (yych <= '7') goto yy138;
1066 if (yych <= '9') goto yy139;
1067 goto yy132;
1068 } else {
1069 if (yych <= 'B') goto yy139;
1070 if (yych <= '`') goto yy132;
1071 if (yych <= 'b') goto yy139;
1072 goto yy132;
1073 }
1074 yy136:
1075 yych = *++YYCURSOR;
1076 if (yych <= '@') {
1077 if (yych <= '/') goto yy132;
1078 if (yych <= '7') goto yy140;
1079 if (yych <= '9') goto yy141;
1080 goto yy132;
1081 } else {
1082 if (yych <= 'F') goto yy141;
1083 if (yych <= '`') goto yy132;
1084 if (yych <= 'f') goto yy141;
1085 goto yy132;
1086 }
1087 yy137:
1088 yych = *++YYCURSOR;
1089 if (yych <= '@') {
1090 if (yych <= '/') goto yy132;
1091 if (yych <= '9') goto yy141;
1092 goto yy132;
1093 } else {
1094 if (yych <= 'F') goto yy141;
1095 if (yych <= '`') goto yy132;
1096 if (yych <= 'f') goto yy141;
1097 goto yy132;
1098 }
1099 yy138:
1100 yych = *++YYCURSOR;
1101 if (yych <= '@') {
1102 if (yych <= '/') goto yy132;
1103 if (yych <= '9') goto yy142;
1104 goto yy132;
1105 } else {
1106 if (yych <= 'F') goto yy142;
1107 if (yych <= '`') goto yy132;
1108 if (yych <= 'f') goto yy142;
1109 goto yy132;
1110 }
1111 yy139:
1112 yych = *++YYCURSOR;
1113 if (yych <= '@') {
1114 if (yych <= '/') goto yy132;
1115 if (yych <= '9') goto yy143;
1116 goto yy132;
1117 } else {
1118 if (yych <= 'F') goto yy143;
1119 if (yych <= '`') goto yy132;
1120 if (yych <= 'f') goto yy143;
1121 goto yy132;
1122 }
1123 yy140:
1124 yych = *++YYCURSOR;
1125 if (yych <= '@') {
1126 if (yych <= '/') goto yy132;
1127 if (yych <= '9') goto yy144;
1128 goto yy132;
1129 } else {
1130 if (yych <= 'F') goto yy144;
1131 if (yych <= '`') goto yy132;
1132 if (yych <= 'f') goto yy144;
1133 goto yy132;
1134 }
1135 yy141:
1136 yych = *++YYCURSOR;
1137 if (yych <= '@') {
1138 if (yych <= '/') goto yy132;
1139 if (yych <= '9') goto yy146;
1140 goto yy132;
1141 } else {
1142 if (yych <= 'F') goto yy146;
1143 if (yych <= '`') goto yy132;
1144 if (yych <= 'f') goto yy146;
1145 goto yy132;
1146 }
1147 yy142:
1148 yych = *++YYCURSOR;
1149 if (yych <= '@') {
1150 if (yych <= '/') goto yy132;
1151 if (yych <= '9') goto yy148;
1152 goto yy132;
1153 } else {
1154 if (yych <= 'F') goto yy148;
1155 if (yych <= '`') goto yy132;
1156 if (yych <= 'f') goto yy148;
1157 goto yy132;
1158 }
1159 yy143:
1160 yych = *++YYCURSOR;
1161 if (yych <= '@') {
1162 if (yych <= '/') goto yy132;
1163 if (yych <= '9') goto yy150;
1164 goto yy132;
1165 } else {
1166 if (yych <= 'F') goto yy150;
1167 if (yych <= '`') goto yy132;
1168 if (yych <= 'f') goto yy150;
1169 goto yy132;
1170 }
1171 yy144:
1172 ++YYCURSOR;
1173 {
1174 int utf16 = php_json_ucs2_to_int(s, 2);
1175 PHP_JSON_SCANNER_COPY_UTF();
1176 *(s->pstr++) = (char) utf16;
1177 s->str_start = s->cursor;
1178 PHP_JSON_CONDITION_GOTO(STR_P2);
1179 }
1180 yy146:
1181 ++YYCURSOR;
1182 {
1183 int utf16 = php_json_ucs2_to_int(s, 3);
1184 PHP_JSON_SCANNER_COPY_UTF();
1185 *(s->pstr++) = (char) (0xc0 | (utf16 >> 6));
1186 *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
1187 s->str_start = s->cursor;
1188 PHP_JSON_CONDITION_GOTO(STR_P2);
1189 }
1190 yy148:
1191 ++YYCURSOR;
1192 {
1193 int utf16 = php_json_ucs2_to_int(s, 4);
1194 PHP_JSON_SCANNER_COPY_UTF();
1195 *(s->pstr++) = (char) (0xe0 | (utf16 >> 12));
1196 *(s->pstr++) = (char) (0x80 | ((utf16 >> 6) & 0x3f));
1197 *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
1198 s->str_start = s->cursor;
1199 PHP_JSON_CONDITION_GOTO(STR_P2);
1200 }
1201 yy150:
1202 yych = *++YYCURSOR;
1203 if (yych != '\\') goto yy132;
1204 yych = *++YYCURSOR;
1205 if (yych != 'u') goto yy132;
1206 yych = *++YYCURSOR;
1207 if (yych == 'D') goto yy153;
1208 if (yych != 'd') goto yy132;
1209 yy153:
1210 yych = *++YYCURSOR;
1211 if (yych <= 'B') goto yy132;
1212 if (yych <= 'F') goto yy154;
1213 if (yych <= 'b') goto yy132;
1214 if (yych >= 'g') goto yy132;
1215 yy154:
1216 yych = *++YYCURSOR;
1217 if (yych <= '@') {
1218 if (yych <= '/') goto yy132;
1219 if (yych >= ':') goto yy132;
1220 } else {
1221 if (yych <= 'F') goto yy155;
1222 if (yych <= '`') goto yy132;
1223 if (yych >= 'g') goto yy132;
1224 }
1225 yy155:
1226 yych = *++YYCURSOR;
1227 if (yych <= '@') {
1228 if (yych <= '/') goto yy132;
1229 if (yych >= ':') goto yy132;
1230 } else {
1231 if (yych <= 'F') goto yy156;
1232 if (yych <= '`') goto yy132;
1233 if (yych >= 'g') goto yy132;
1234 }
1235 yy156:
1236 ++YYCURSOR;
1237 {
1238 int utf32, utf16_hi, utf16_lo;
1239 utf16_hi = php_json_ucs2_to_int(s, 4);
1240 utf16_lo = php_json_ucs2_to_int_ex(s, 4, 7);
1241 utf32 = ((utf16_lo & 0x3FF) << 10) + (utf16_hi & 0x3FF) + 0x10000;
1242 PHP_JSON_SCANNER_COPY_UTF_SP();
1243 *(s->pstr++) = (char) (0xf0 | (utf32 >> 18));
1244 *(s->pstr++) = (char) (0x80 | ((utf32 >> 12) & 0x3f));
1245 *(s->pstr++) = (char) (0x80 | ((utf32 >> 6) & 0x3f));
1246 *(s->pstr++) = (char) (0x80 | (utf32 & 0x3f));
1247 s->str_start = s->cursor;
1248 PHP_JSON_CONDITION_GOTO(STR_P2);
1249 }
1250 }
1251
1252
1253 }
1254
1255