3 #include "../fbuffer/fbuffer.h"
9 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
11 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
12 -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
13 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
14 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
17 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
18 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
19 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
20 -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
22 -1, -1, -1, -1, -1, -1, -1
31 result = (result << 4) | b;
33 result = (result << 4) | b;
36 result = (result << 4) | b;
39 result = (result << 4) | b;
49 }
else if (ch <= 0x07FF) {
50 buf[0] = (char) ((ch >> 6) | 0xC0);
51 buf[1] = (char) ((ch & 0x3F) | 0x80);
53 }
else if (ch <= 0xFFFF) {
54 buf[0] = (char) ((ch >> 12) | 0xE0);
55 buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
56 buf[2] = (char) ((ch & 0x3F) | 0x80);
58 }
else if (ch <= 0x1fffff) {
59 buf[0] =(char) ((ch >> 18) | 0xF0);
60 buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
61 buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
62 buf[3] =(char) ((ch & 0x3F) | 0x80);
70 #ifdef HAVE_RUBY_ENCODING_H
120 #line 166 "parser.rl"
146 if ( 9 <= (*p) && (*p) <= 10 )
150 #line 133 "parser.rl"
156 if (np ==
NULL) { p--; {p++; cs = 3;
goto _out;} }
else {p = (( np))-1;}
170 if ( 9 <= (*p) && (*p) <= 10 )
224 if ( 48 <= (*p) && (*p) <= 57 )
226 }
else if ( (*p) >= 9 )
230 #line 118 "parser.rl"
235 p--; {p++; cs = 9;
goto _out;}
258 if ( 9 <= (*p) && (*p) <= 10 )
271 if ( 9 <= (*p) && (*p) <= 10 )
339 #line 141 "parser.rl"
340 { p--; {p++; cs = 27;
goto _out;} }
413 _test_eof2: cs = 2;
goto _test_eof;
414 _test_eof3: cs = 3;
goto _test_eof;
415 _test_eof4: cs = 4;
goto _test_eof;
416 _test_eof5: cs = 5;
goto _test_eof;
417 _test_eof6: cs = 6;
goto _test_eof;
418 _test_eof7: cs = 7;
goto _test_eof;
419 _test_eof8: cs = 8;
goto _test_eof;
420 _test_eof9: cs = 9;
goto _test_eof;
421 _test_eof10: cs = 10;
goto _test_eof;
422 _test_eof11: cs = 11;
goto _test_eof;
423 _test_eof12: cs = 12;
goto _test_eof;
424 _test_eof13: cs = 13;
goto _test_eof;
425 _test_eof14: cs = 14;
goto _test_eof;
426 _test_eof15: cs = 15;
goto _test_eof;
427 _test_eof16: cs = 16;
goto _test_eof;
428 _test_eof17: cs = 17;
goto _test_eof;
429 _test_eof18: cs = 18;
goto _test_eof;
430 _test_eof27: cs = 27;
goto _test_eof;
431 _test_eof19: cs = 19;
goto _test_eof;
432 _test_eof20: cs = 20;
goto _test_eof;
433 _test_eof21: cs = 21;
goto _test_eof;
434 _test_eof22: cs = 22;
goto _test_eof;
435 _test_eof23: cs = 23;
goto _test_eof;
436 _test_eof24: cs = 24;
goto _test_eof;
437 _test_eof25: cs = 25;
goto _test_eof;
438 _test_eof26: cs = 26;
goto _test_eof;
444 #line 167 "parser.rl"
454 if (!
NIL_P(klassname)) {
477 #line 271 "parser.rl"
490 #line 278 "parser.rl"
510 if ( 48 <= (*p) && (*p) <= 57 )
517 #line 219 "parser.rl"
520 if (np ==
NULL) { p--; {p++; cs = 21;
goto _out;} }
else {p = (( np))-1;}
524 #line 224 "parser.rl"
531 p--; {p++; cs = 21;
goto _out;}
537 if (np !=
NULL) {p = (( np))-1;}
539 if (np !=
NULL) {p = (( np))-1;}
540 p--; {p++; cs = 21;
goto _out;}
544 #line 242 "parser.rl"
550 if (np ==
NULL) { p--; {p++; cs = 21;
goto _out;} }
else {p = (( np))-1;}
554 #line 250 "parser.rl"
560 if (np ==
NULL) { p--; {p++; cs = 21;
goto _out;} }
else {p = (( np))-1;}
564 #line 212 "parser.rl"
574 #line 205 "parser.rl"
584 #line 199 "parser.rl"
590 #line 196 "parser.rl"
596 #line 202 "parser.rl"
605 #line 258 "parser.rl"
606 { p--; {p++; cs = 21;
goto _out;} }
743 _test_eof21: cs = 21;
goto _test_eof;
744 _test_eof2: cs = 2;
goto _test_eof;
745 _test_eof3: cs = 3;
goto _test_eof;
746 _test_eof4: cs = 4;
goto _test_eof;
747 _test_eof5: cs = 5;
goto _test_eof;
748 _test_eof6: cs = 6;
goto _test_eof;
749 _test_eof7: cs = 7;
goto _test_eof;
750 _test_eof8: cs = 8;
goto _test_eof;
751 _test_eof9: cs = 9;
goto _test_eof;
752 _test_eof10: cs = 10;
goto _test_eof;
753 _test_eof11: cs = 11;
goto _test_eof;
754 _test_eof12: cs = 12;
goto _test_eof;
755 _test_eof13: cs = 13;
goto _test_eof;
756 _test_eof14: cs = 14;
goto _test_eof;
757 _test_eof15: cs = 15;
goto _test_eof;
758 _test_eof16: cs = 16;
goto _test_eof;
759 _test_eof17: cs = 17;
goto _test_eof;
760 _test_eof18: cs = 18;
goto _test_eof;
761 _test_eof19: cs = 19;
goto _test_eof;
762 _test_eof20: cs = 20;
goto _test_eof;
768 #line 279 "parser.rl"
786 #line 295 "parser.rl"
799 #line 302 "parser.rl"
813 if ( 49 <= (*p) && (*p) <= 57 )
825 if ( 49 <= (*p) && (*p) <= 57 )
832 if ( 48 <= (*p) && (*p) <= 57 )
836 #line 292 "parser.rl"
837 { p--; {p++; cs = 4;
goto _out;} }
849 if ( 48 <= (*p) && (*p) <= 57 )
853 _test_eof2: cs = 2;
goto _test_eof;
854 _test_eof3: cs = 3;
goto _test_eof;
855 _test_eof4: cs = 4;
goto _test_eof;
856 _test_eof5: cs = 5;
goto _test_eof;
862 #line 304 "parser.rl"
865 long len = p - json->
memo;
885 #line 329 "parser.rl"
898 #line 336 "parser.rl"
912 if ( 49 <= (*p) && (*p) <= 57 )
924 if ( 49 <= (*p) && (*p) <= 57 )
941 if ( 48 <= (*p) && (*p) <= 57 )
953 if ( 48 <= (*p) && (*p) <= 57 )
955 }
else if ( (*p) >= 45 )
959 #line 323 "parser.rl"
960 { p--; {p++; cs = 9;
goto _out;} }
976 if ( 48 <= (*p) && (*p) <= 57 )
983 if ( 48 <= (*p) && (*p) <= 57 )
995 if ( 48 <= (*p) && (*p) <= 57 )
997 }
else if ( (*p) >= 45 )
1009 if ( 48 <= (*p) && (*p) <= 57 )
1013 _test_eof2: cs = 2;
goto _test_eof;
1014 _test_eof3: cs = 3;
goto _test_eof;
1015 _test_eof4: cs = 4;
goto _test_eof;
1016 _test_eof8: cs = 8;
goto _test_eof;
1017 _test_eof9: cs = 9;
goto _test_eof;
1018 _test_eof5: cs = 5;
goto _test_eof;
1019 _test_eof6: cs = 6;
goto _test_eof;
1020 _test_eof10: cs = 10;
goto _test_eof;
1021 _test_eof7: cs = 7;
goto _test_eof;
1027 #line 338 "parser.rl"
1030 long len = p - json->
memo;
1043 #line 1044 "parser.c"
1051 #line 381 "parser.rl"
1065 #line 1066 "parser.c"
1070 #line 394 "parser.rl"
1072 #line 1073 "parser.c"
1105 if ( 48 <= (*p) && (*p) <= 57 )
1107 }
else if ( (*p) >= 9 )
1111 #line 358 "parser.rl"
1116 p--; {p++; cs = 3;
goto _out;}
1131 #line 1132 "parser.c"
1139 if ( 9 <= (*p) && (*p) <= 10 )
1161 if ( 48 <= (*p) && (*p) <= 57 )
1163 }
else if ( (*p) >= 9 )
1231 #line 373 "parser.rl"
1232 { p--; {p++; cs = 17;
goto _out;} }
1238 #line 1239 "parser.c"
1273 _test_eof2: cs = 2;
goto _test_eof;
1274 _test_eof3: cs = 3;
goto _test_eof;
1275 _test_eof4: cs = 4;
goto _test_eof;
1276 _test_eof5: cs = 5;
goto _test_eof;
1277 _test_eof6: cs = 6;
goto _test_eof;
1278 _test_eof7: cs = 7;
goto _test_eof;
1279 _test_eof8: cs = 8;
goto _test_eof;
1280 _test_eof9: cs = 9;
goto _test_eof;
1281 _test_eof10: cs = 10;
goto _test_eof;
1282 _test_eof11: cs = 11;
goto _test_eof;
1283 _test_eof12: cs = 12;
goto _test_eof;
1284 _test_eof17: cs = 17;
goto _test_eof;
1285 _test_eof13: cs = 13;
goto _test_eof;
1286 _test_eof14: cs = 14;
goto _test_eof;
1287 _test_eof15: cs = 15;
goto _test_eof;
1288 _test_eof16: cs = 16;
goto _test_eof;
1294 #line 395 "parser.rl"
1306 char *
p = string, *pe = string, *unescape;
1310 while (pe < stringEnd) {
1312 unescape = (
char *)
"?";
1317 unescape = (
char *)
"\n";
1320 unescape = (
char *)
"\r";
1323 unescape = (
char *)
"\t";
1326 unescape = (
char *)
"\"";
1329 unescape = (
char *)
"\\";
1332 unescape = (
char *)
"\b";
1335 unescape = (
char *)
"\f";
1338 if (pe > stringEnd - 4) {
1345 if (pe > stringEnd - 6)
return Qnil;
1346 if (pe[0] ==
'\\' && pe[1] ==
'u') {
1348 ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
1352 unescape = (
char *)
"?";
1375 #line 1376 "parser.c"
1383 #line 494 "parser.rl"
1405 #line 1406 "parser.c"
1410 #line 515 "parser.rl"
1413 #line 1414 "parser.c"
1434 if ( 0 <= (*p) && (*p) <= 31 )
1438 #line 480 "parser.rl"
1441 if (
NIL_P(*result)) {
1443 {p++; cs = 8;
goto _out;}
1449 #line 491 "parser.rl"
1450 { p--; {p++; cs = 8;
goto _out;} }
1456 #line 1457 "parser.c"
1464 if ( 0 <= (*p) && (*p) <= 31 )
1472 if ( 48 <= (*p) && (*p) <= 57 )
1474 }
else if ( (*p) > 70 ) {
1475 if ( 97 <= (*p) && (*p) <= 102 )
1485 if ( 48 <= (*p) && (*p) <= 57 )
1487 }
else if ( (*p) > 70 ) {
1488 if ( 97 <= (*p) && (*p) <= 102 )
1498 if ( 48 <= (*p) && (*p) <= 57 )
1500 }
else if ( (*p) > 70 ) {
1501 if ( 97 <= (*p) && (*p) <= 102 )
1511 if ( 48 <= (*p) && (*p) <= 57 )
1513 }
else if ( (*p) > 70 ) {
1514 if ( 97 <= (*p) && (*p) <= 102 )
1520 _test_eof2: cs = 2;
goto _test_eof;
1521 _test_eof8: cs = 8;
goto _test_eof;
1522 _test_eof3: cs = 3;
goto _test_eof;
1523 _test_eof4: cs = 4;
goto _test_eof;
1524 _test_eof5: cs = 5;
goto _test_eof;
1525 _test_eof6: cs = 6;
goto _test_eof;
1526 _test_eof7: cs = 7;
goto _test_eof;
1532 #line 517 "parser.rl"
1574 #ifdef HAVE_RUBY_ENCODING_H
1578 if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
1580 }
else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
1582 }
else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
1584 }
else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
1595 if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
1597 }
else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
1599 }
else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
1601 }
else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
1639 if (json->Vsource) {
1651 if (
RTEST(max_nesting)) {
1653 json->max_nesting =
FIX2INT(max_nesting);
1655 json->max_nesting = 0;
1658 json->max_nesting = 100;
1664 json->allow_nan = 0;
1670 json->symbolize_names = 0;
1675 json->quirks_mode =
RTEST(quirks_mode) ? 1 : 0;
1677 json->quirks_mode = 0;
1683 json->create_additions = 0;
1695 json->object_class =
Qnil;
1701 json->array_class =
Qnil;
1706 json->match_string =
RTEST(match_string) ? match_string :
Qnil;
1708 json->match_string =
Qnil;
1712 json->max_nesting = 100;
1713 json->allow_nan = 0;
1714 json->create_additions = 1;
1716 json->object_class =
Qnil;
1717 json->array_class =
Qnil;
1720 if (!json->quirks_mode) {
1723 json->current_nesting = 0;
1727 json->Vsource = source;
1732 #line 1733 "parser.c"
1740 #line 740 "parser.rl"
1751 #line 1752 "parser.c"
1756 #line 750 "parser.rl"
1760 #line 1761 "parser.c"
1777 if ( 9 <= (*p) && (*p) <= 10 )
1816 #line 729 "parser.rl"
1819 json->current_nesting = 1;
1821 if (np ==
NULL) { p--; {p++; cs = 10;
goto _out;} }
else {p = (( np))-1;}
1825 #line 722 "parser.rl"
1828 json->current_nesting = 1;
1830 if (np ==
NULL) { p--; {p++; cs = 10;
goto _out;} }
else {p = (( np))-1;}
1837 #line 1838 "parser.c"
1843 if ( 9 <= (*p) && (*p) <= 10 )
1879 _test_eof1: cs = 1;
goto _test_eof;
1880 _test_eof2: cs = 2;
goto _test_eof;
1881 _test_eof3: cs = 3;
goto _test_eof;
1882 _test_eof4: cs = 4;
goto _test_eof;
1883 _test_eof5: cs = 5;
goto _test_eof;
1884 _test_eof10: cs = 10;
goto _test_eof;
1885 _test_eof6: cs = 6;
goto _test_eof;
1886 _test_eof7: cs = 7;
goto _test_eof;
1887 _test_eof8: cs = 8;
goto _test_eof;
1888 _test_eof9: cs = 9;
goto _test_eof;
1894 #line 753 "parser.rl"
1906 #line 1907 "parser.c"
1914 #line 778 "parser.rl"
1925 #line 1926 "parser.c"
1930 #line 788 "parser.rl"
1934 #line 1935 "parser.c"
1959 if ( 48 <= (*p) && (*p) <= 57 )
1961 }
else if ( (*p) >= 9 )
1968 #line 770 "parser.rl"
1971 if (np ==
NULL) { p--; {p++; cs = 10;
goto _out;} }
else {p = (( np))-1;}
1978 #line 1979 "parser.c"
1984 if ( 9 <= (*p) && (*p) <= 10 )
2052 _test_eof1: cs = 1;
goto _test_eof;
2053 _test_eof10: cs = 10;
goto _test_eof;
2054 _test_eof2: cs = 2;
goto _test_eof;
2055 _test_eof3: cs = 3;
goto _test_eof;
2056 _test_eof4: cs = 4;
goto _test_eof;
2057 _test_eof5: cs = 5;
goto _test_eof;
2058 _test_eof6: cs = 6;
goto _test_eof;
2059 _test_eof7: cs = 7;
goto _test_eof;
2060 _test_eof8: cs = 8;
goto _test_eof;
2061 _test_eof9: cs = 9;
goto _test_eof;
2067 #line 791 "parser.rl"
2087 if (json->quirks_mode) {
2184 #ifdef HAVE_RUBY_ENCODING_H
static void fbuffer_clear(FBuffer *fb)
static const int JSON_string_error
static JSON_Parser * JSON_allocate()
VALUE rb_ary_entry(VALUE ary, long offset)
static const int JSON_value_error
VALUE rb_class_new_instance(int, VALUE *, VALUE)
static const int JSON_float_first_final
static VALUE cParser_source(VALUE self)
double rb_cstr_to_dbl(const char *, int)
VALUE rb_const_get(VALUE, ID)
#define option_given_p(opts, key)
static VALUE convert_encoding(VALUE source)
static VALUE CEncoding_UTF_16BE
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_ary_push(VALUE ary, VALUE item)
VALUE rb_require(const char *)
static VALUE eParserError
static VALUE match_string(VALUE match)
static void fbuffer_append_char(FBuffer *fb, char newchr)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_raise(VALUE exc, const char *fmt,...)
static const int JSON_object_start
static VALUE cJSON_parser_s_allocate(VALUE klass)
static VALUE cParser_parse(VALUE self)
static VALUE CMinusInfinity
static const int JSON_string_first_final
static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
VALUE rb_path2class(const char *)
static const int JSON_float_en_main
static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
void rb_hash_foreach(VALUE, int(*)(ANYARGS), VALUE)
#define MEMZERO(p, type, n)
static const int JSON_array_first_final
static char * JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
static VALUE rb_float_new(double d)
static const int JSON_array_error
static char * JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
static void JSON_mark(JSON_Parser *json)
static ID i_deep_const_get
static VALUE eNestingError
static const int JSON_value_start
static char * JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
static const int JSON_en_main
static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len)
static const int JSON_integer_start
static const int JSON_integer_error
static const int JSON_quirks_mode_error
static VALUE cParser_parse_strict(VALUE self)
static const int JSON_string_en_main
VALUE rb_str_buf_cat(VALUE, const char *, long)
static FBuffer * fbuffer_alloc(unsigned long initial_length)
static VALUE CEncoding_UTF_32BE
static VALUE CEncoding_UTF_32LE
VALUE rb_hash_aset(VALUE, VALUE, VALUE)
static const int JSON_float_error
static VALUE cParser_parse_quirks_mode(VALUE self)
static const int JSON_error
static void JSON_free(JSON_Parser *json)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static const int JSON_float_start
static VALUE cParser_quirks_mode_p(VALUE self)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_str_buf_new(long)
static char * JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
#define UNI_SUR_HIGH_START
void rb_gc_mark_maybe(VALUE)
static const int JSON_object_first_final
VALUE rb_define_module_under(VALUE outer, const char *name)
static const int JSON_quirks_mode_first_final
static const int JSON_integer_en_main
static const int JSON_start
static const int JSON_array_start
static const int JSON_integer_first_final
static const int JSON_object_en_main
static const int JSON_quirks_mode_en_main
static void fbuffer_free(FBuffer *fb)
static const int JSON_first_final
static char * JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
static UTF32 unescape_unicode(const unsigned char *p)
RUBY_EXTERN VALUE rb_cObject
static const int JSON_array_en_main
static const char digit_values[256]
static const int JSON_string_start
static VALUE CEncoding_ASCII_8BIT
static const int JSON_value_first_final
#define UNI_REPLACEMENT_CHAR
VALUE rb_ary_new2(long capa)
static ID i_symbolize_names
static const int JSON_quirks_mode_start
static const int JSON_value_en_main
VALUE rb_str_intern(VALUE)
static const int JSON_object_error
static ID i_json_creatable_p
static ID i_create_additions
static VALUE CEncoding_UTF_16LE
VALUE rb_hash_aref(VALUE, VALUE)
static char * JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
static int match_i(VALUE regexp, VALUE klass, VALUE memo)
#define Data_Wrap_Struct(klass, mark, free, sval)
static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
VALUE rb_define_module(const char *name)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_convert_type(VALUE, int, const char *, const char *)
VALUE rb_cstr2inum(const char *str, int base)
static VALUE CEncoding_UTF_8