Ruby  2.4.2p198(2017-09-14revision59899)
parser.c
Go to the documentation of this file.
1 
2 #line 1 "parser.rl"
3 #include "../fbuffer/fbuffer.h"
4 #include "parser.h"
5 
6 #if defined HAVE_RUBY_ENCODING_H
7 # define EXC_ENCODING rb_utf8_encoding(),
8 # ifndef HAVE_RB_ENC_RAISE
9 static void
10 enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
11 {
12  va_list args;
13  VALUE mesg;
14 
15  va_start(args, fmt);
16  mesg = rb_enc_vsprintf(enc, fmt, args);
17  va_end(args);
18 
19  rb_exc_raise(rb_exc_new3(exc, mesg));
20 }
21 # define rb_enc_raise enc_raise
22 # endif
23 #else
24 # define EXC_ENCODING /* nothing */
25 # define rb_enc_raise rb_raise
26 #endif
27 
28 /* unicode */
29 
30 static const char digit_values[256] = {
31  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
32  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
33  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
34  -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -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,
36  10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
37  -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
39  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
40  -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
42  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
43  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
44  -1, -1, -1, -1, -1, -1, -1
45 };
46 
47 static UTF32 unescape_unicode(const unsigned char *p)
48 {
49  char b;
50  UTF32 result = 0;
51  b = digit_values[p[0]];
52  if (b < 0) return UNI_REPLACEMENT_CHAR;
53  result = (result << 4) | (unsigned char)b;
54  b = digit_values[p[1]];
55  if (b < 0) return UNI_REPLACEMENT_CHAR;
56  result = (result << 4) | (unsigned char)b;
57  b = digit_values[p[2]];
58  if (b < 0) return UNI_REPLACEMENT_CHAR;
59  result = (result << 4) | (unsigned char)b;
60  b = digit_values[p[3]];
61  if (b < 0) return UNI_REPLACEMENT_CHAR;
62  result = (result << 4) | (unsigned char)b;
63  return result;
64 }
65 
66 static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
67 {
68  int len = 1;
69  if (ch <= 0x7F) {
70  buf[0] = (char) ch;
71  } else if (ch <= 0x07FF) {
72  buf[0] = (char) ((ch >> 6) | 0xC0);
73  buf[1] = (char) ((ch & 0x3F) | 0x80);
74  len++;
75  } else if (ch <= 0xFFFF) {
76  buf[0] = (char) ((ch >> 12) | 0xE0);
77  buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
78  buf[2] = (char) ((ch & 0x3F) | 0x80);
79  len += 2;
80  } else if (ch <= 0x1fffff) {
81  buf[0] =(char) ((ch >> 18) | 0xF0);
82  buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
83  buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
84  buf[3] =(char) ((ch & 0x3F) | 0x80);
85  len += 3;
86  } else {
87  buf[0] = '?';
88  }
89  return len;
90 }
91 
94 
99 
100 
101 #line 124 "parser.rl"
102 
103 
104 
105 #line 106 "parser.c"
106 enum {JSON_object_start = 1};
108 enum {JSON_object_error = 0};
109 
111 
112 
113 #line 165 "parser.rl"
114 
115 
116 static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
117 {
118  int cs = EVIL;
119  VALUE last_name = Qnil;
120  VALUE object_class = json->object_class;
121 
122  if (json->max_nesting && current_nesting > json->max_nesting) {
123  rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
124  }
125 
126  *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
127 
128 
129 #line 130 "parser.c"
130  {
131  cs = JSON_object_start;
132  }
133 
134 #line 180 "parser.rl"
135 
136 #line 137 "parser.c"
137  {
138  if ( p == pe )
139  goto _test_eof;
140  switch ( cs )
141  {
142 case 1:
143  if ( (*p) == 123 )
144  goto st2;
145  goto st0;
146 st0:
147 cs = 0;
148  goto _out;
149 st2:
150  if ( ++p == pe )
151  goto _test_eof2;
152 case 2:
153  switch( (*p) ) {
154  case 13: goto st2;
155  case 32: goto st2;
156  case 34: goto tr2;
157  case 47: goto st23;
158  case 125: goto tr4;
159  }
160  if ( 9 <= (*p) && (*p) <= 10 )
161  goto st2;
162  goto st0;
163 tr2:
164 #line 147 "parser.rl"
165  {
166  char *np;
167  json->parsing_name = 1;
168  np = JSON_parse_string(json, p, pe, &last_name);
169  json->parsing_name = 0;
170  if (np == NULL) { p--; {p++; cs = 3; goto _out;} } else {p = (( np))-1;}
171  }
172  goto st3;
173 st3:
174  if ( ++p == pe )
175  goto _test_eof3;
176 case 3:
177 #line 178 "parser.c"
178  switch( (*p) ) {
179  case 13: goto st3;
180  case 32: goto st3;
181  case 47: goto st4;
182  case 58: goto st8;
183  }
184  if ( 9 <= (*p) && (*p) <= 10 )
185  goto st3;
186  goto st0;
187 st4:
188  if ( ++p == pe )
189  goto _test_eof4;
190 case 4:
191  switch( (*p) ) {
192  case 42: goto st5;
193  case 47: goto st7;
194  }
195  goto st0;
196 st5:
197  if ( ++p == pe )
198  goto _test_eof5;
199 case 5:
200  if ( (*p) == 42 )
201  goto st6;
202  goto st5;
203 st6:
204  if ( ++p == pe )
205  goto _test_eof6;
206 case 6:
207  switch( (*p) ) {
208  case 42: goto st6;
209  case 47: goto st3;
210  }
211  goto st5;
212 st7:
213  if ( ++p == pe )
214  goto _test_eof7;
215 case 7:
216  if ( (*p) == 10 )
217  goto st3;
218  goto st7;
219 st8:
220  if ( ++p == pe )
221  goto _test_eof8;
222 case 8:
223  switch( (*p) ) {
224  case 13: goto st8;
225  case 32: goto st8;
226  case 34: goto tr11;
227  case 45: goto tr11;
228  case 47: goto st19;
229  case 73: goto tr11;
230  case 78: goto tr11;
231  case 91: goto tr11;
232  case 102: goto tr11;
233  case 110: goto tr11;
234  case 116: goto tr11;
235  case 123: goto tr11;
236  }
237  if ( (*p) > 10 ) {
238  if ( 48 <= (*p) && (*p) <= 57 )
239  goto tr11;
240  } else if ( (*p) >= 9 )
241  goto st8;
242  goto st0;
243 tr11:
244 #line 132 "parser.rl"
245  {
246  VALUE v = Qnil;
247  char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
248  if (np == NULL) {
249  p--; {p++; cs = 9; goto _out;}
250  } else {
251  if (NIL_P(json->object_class)) {
252  rb_hash_aset(*result, last_name, v);
253  } else {
254  rb_funcall(*result, i_aset, 2, last_name, v);
255  }
256  {p = (( np))-1;}
257  }
258  }
259  goto st9;
260 st9:
261  if ( ++p == pe )
262  goto _test_eof9;
263 case 9:
264 #line 265 "parser.c"
265  switch( (*p) ) {
266  case 13: goto st9;
267  case 32: goto st9;
268  case 44: goto st10;
269  case 47: goto st15;
270  case 125: goto tr4;
271  }
272  if ( 9 <= (*p) && (*p) <= 10 )
273  goto st9;
274  goto st0;
275 st10:
276  if ( ++p == pe )
277  goto _test_eof10;
278 case 10:
279  switch( (*p) ) {
280  case 13: goto st10;
281  case 32: goto st10;
282  case 34: goto tr2;
283  case 47: goto st11;
284  }
285  if ( 9 <= (*p) && (*p) <= 10 )
286  goto st10;
287  goto st0;
288 st11:
289  if ( ++p == pe )
290  goto _test_eof11;
291 case 11:
292  switch( (*p) ) {
293  case 42: goto st12;
294  case 47: goto st14;
295  }
296  goto st0;
297 st12:
298  if ( ++p == pe )
299  goto _test_eof12;
300 case 12:
301  if ( (*p) == 42 )
302  goto st13;
303  goto st12;
304 st13:
305  if ( ++p == pe )
306  goto _test_eof13;
307 case 13:
308  switch( (*p) ) {
309  case 42: goto st13;
310  case 47: goto st10;
311  }
312  goto st12;
313 st14:
314  if ( ++p == pe )
315  goto _test_eof14;
316 case 14:
317  if ( (*p) == 10 )
318  goto st10;
319  goto st14;
320 st15:
321  if ( ++p == pe )
322  goto _test_eof15;
323 case 15:
324  switch( (*p) ) {
325  case 42: goto st16;
326  case 47: goto st18;
327  }
328  goto st0;
329 st16:
330  if ( ++p == pe )
331  goto _test_eof16;
332 case 16:
333  if ( (*p) == 42 )
334  goto st17;
335  goto st16;
336 st17:
337  if ( ++p == pe )
338  goto _test_eof17;
339 case 17:
340  switch( (*p) ) {
341  case 42: goto st17;
342  case 47: goto st9;
343  }
344  goto st16;
345 st18:
346  if ( ++p == pe )
347  goto _test_eof18;
348 case 18:
349  if ( (*p) == 10 )
350  goto st9;
351  goto st18;
352 tr4:
353 #line 155 "parser.rl"
354  { p--; {p++; cs = 27; goto _out;} }
355  goto st27;
356 st27:
357  if ( ++p == pe )
358  goto _test_eof27;
359 case 27:
360 #line 361 "parser.c"
361  goto st0;
362 st19:
363  if ( ++p == pe )
364  goto _test_eof19;
365 case 19:
366  switch( (*p) ) {
367  case 42: goto st20;
368  case 47: goto st22;
369  }
370  goto st0;
371 st20:
372  if ( ++p == pe )
373  goto _test_eof20;
374 case 20:
375  if ( (*p) == 42 )
376  goto st21;
377  goto st20;
378 st21:
379  if ( ++p == pe )
380  goto _test_eof21;
381 case 21:
382  switch( (*p) ) {
383  case 42: goto st21;
384  case 47: goto st8;
385  }
386  goto st20;
387 st22:
388  if ( ++p == pe )
389  goto _test_eof22;
390 case 22:
391  if ( (*p) == 10 )
392  goto st8;
393  goto st22;
394 st23:
395  if ( ++p == pe )
396  goto _test_eof23;
397 case 23:
398  switch( (*p) ) {
399  case 42: goto st24;
400  case 47: goto st26;
401  }
402  goto st0;
403 st24:
404  if ( ++p == pe )
405  goto _test_eof24;
406 case 24:
407  if ( (*p) == 42 )
408  goto st25;
409  goto st24;
410 st25:
411  if ( ++p == pe )
412  goto _test_eof25;
413 case 25:
414  switch( (*p) ) {
415  case 42: goto st25;
416  case 47: goto st2;
417  }
418  goto st24;
419 st26:
420  if ( ++p == pe )
421  goto _test_eof26;
422 case 26:
423  if ( (*p) == 10 )
424  goto st2;
425  goto st26;
426  }
427  _test_eof2: cs = 2; goto _test_eof;
428  _test_eof3: cs = 3; goto _test_eof;
429  _test_eof4: cs = 4; goto _test_eof;
430  _test_eof5: cs = 5; goto _test_eof;
431  _test_eof6: cs = 6; goto _test_eof;
432  _test_eof7: cs = 7; goto _test_eof;
433  _test_eof8: cs = 8; goto _test_eof;
434  _test_eof9: cs = 9; goto _test_eof;
435  _test_eof10: cs = 10; goto _test_eof;
436  _test_eof11: cs = 11; goto _test_eof;
437  _test_eof12: cs = 12; goto _test_eof;
438  _test_eof13: cs = 13; goto _test_eof;
439  _test_eof14: cs = 14; goto _test_eof;
440  _test_eof15: cs = 15; goto _test_eof;
441  _test_eof16: cs = 16; goto _test_eof;
442  _test_eof17: cs = 17; goto _test_eof;
443  _test_eof18: cs = 18; goto _test_eof;
444  _test_eof27: cs = 27; goto _test_eof;
445  _test_eof19: cs = 19; goto _test_eof;
446  _test_eof20: cs = 20; goto _test_eof;
447  _test_eof21: cs = 21; goto _test_eof;
448  _test_eof22: cs = 22; goto _test_eof;
449  _test_eof23: cs = 23; goto _test_eof;
450  _test_eof24: cs = 24; goto _test_eof;
451  _test_eof25: cs = 25; goto _test_eof;
452  _test_eof26: cs = 26; goto _test_eof;
453 
454  _test_eof: {}
455  _out: {}
456  }
457 
458 #line 181 "parser.rl"
459 
460  if (cs >= JSON_object_first_final) {
461  if (json->create_additions) {
462  VALUE klassname;
463  if (NIL_P(json->object_class)) {
464  klassname = rb_hash_aref(*result, json->create_id);
465  } else {
466  klassname = rb_funcall(*result, i_aref, 1, json->create_id);
467  }
468  if (!NIL_P(klassname)) {
469  VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
470  if (RTEST(rb_funcall(klass, i_json_creatable_p, 0))) {
471  *result = rb_funcall(klass, i_json_create, 1, *result);
472  }
473  }
474  }
475  return p + 1;
476  } else {
477  return NULL;
478  }
479 }
480 
481 
482 
483 #line 484 "parser.c"
484 enum {JSON_value_start = 1};
486 enum {JSON_value_error = 0};
487 
489 
490 
491 #line 281 "parser.rl"
492 
493 
494 static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
495 {
496  int cs = EVIL;
497 
498 
499 #line 500 "parser.c"
500  {
501  cs = JSON_value_start;
502  }
503 
504 #line 288 "parser.rl"
505 
506 #line 507 "parser.c"
507  {
508  if ( p == pe )
509  goto _test_eof;
510  switch ( cs )
511  {
512 st1:
513  if ( ++p == pe )
514  goto _test_eof1;
515 case 1:
516  switch( (*p) ) {
517  case 13: goto st1;
518  case 32: goto st1;
519  case 34: goto tr2;
520  case 45: goto tr3;
521  case 47: goto st6;
522  case 73: goto st10;
523  case 78: goto st17;
524  case 91: goto tr7;
525  case 102: goto st19;
526  case 110: goto st23;
527  case 116: goto st26;
528  case 123: goto tr11;
529  }
530  if ( (*p) > 10 ) {
531  if ( 48 <= (*p) && (*p) <= 57 )
532  goto tr3;
533  } else if ( (*p) >= 9 )
534  goto st1;
535  goto st0;
536 st0:
537 cs = 0;
538  goto _out;
539 tr2:
540 #line 233 "parser.rl"
541  {
542  char *np = JSON_parse_string(json, p, pe, result);
543  if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
544  }
545  goto st29;
546 tr3:
547 #line 238 "parser.rl"
548  {
549  char *np;
550  if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
551  if (json->allow_nan) {
552  *result = CMinusInfinity;
553  {p = (( p + 10))-1;}
554  p--; {p++; cs = 29; goto _out;}
555  } else {
556  rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
557  }
558  }
559  np = JSON_parse_float(json, p, pe, result);
560  if (np != NULL) {p = (( np))-1;}
561  np = JSON_parse_integer(json, p, pe, result);
562  if (np != NULL) {p = (( np))-1;}
563  p--; {p++; cs = 29; goto _out;}
564  }
565  goto st29;
566 tr7:
567 #line 256 "parser.rl"
568  {
569  char *np;
570  np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
571  if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
572  }
573  goto st29;
574 tr11:
575 #line 262 "parser.rl"
576  {
577  char *np;
578  np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
579  if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
580  }
581  goto st29;
582 tr25:
583 #line 226 "parser.rl"
584  {
585  if (json->allow_nan) {
586  *result = CInfinity;
587  } else {
588  rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8);
589  }
590  }
591  goto st29;
592 tr27:
593 #line 219 "parser.rl"
594  {
595  if (json->allow_nan) {
596  *result = CNaN;
597  } else {
598  rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2);
599  }
600  }
601  goto st29;
602 tr31:
603 #line 213 "parser.rl"
604  {
605  *result = Qfalse;
606  }
607  goto st29;
608 tr34:
609 #line 210 "parser.rl"
610  {
611  *result = Qnil;
612  }
613  goto st29;
614 tr37:
615 #line 216 "parser.rl"
616  {
617  *result = Qtrue;
618  }
619  goto st29;
620 st29:
621  if ( ++p == pe )
622  goto _test_eof29;
623 case 29:
624 #line 268 "parser.rl"
625  { p--; {p++; cs = 29; goto _out;} }
626 #line 627 "parser.c"
627  switch( (*p) ) {
628  case 13: goto st29;
629  case 32: goto st29;
630  case 47: goto st2;
631  }
632  if ( 9 <= (*p) && (*p) <= 10 )
633  goto st29;
634  goto st0;
635 st2:
636  if ( ++p == pe )
637  goto _test_eof2;
638 case 2:
639  switch( (*p) ) {
640  case 42: goto st3;
641  case 47: goto st5;
642  }
643  goto st0;
644 st3:
645  if ( ++p == pe )
646  goto _test_eof3;
647 case 3:
648  if ( (*p) == 42 )
649  goto st4;
650  goto st3;
651 st4:
652  if ( ++p == pe )
653  goto _test_eof4;
654 case 4:
655  switch( (*p) ) {
656  case 42: goto st4;
657  case 47: goto st29;
658  }
659  goto st3;
660 st5:
661  if ( ++p == pe )
662  goto _test_eof5;
663 case 5:
664  if ( (*p) == 10 )
665  goto st29;
666  goto st5;
667 st6:
668  if ( ++p == pe )
669  goto _test_eof6;
670 case 6:
671  switch( (*p) ) {
672  case 42: goto st7;
673  case 47: goto st9;
674  }
675  goto st0;
676 st7:
677  if ( ++p == pe )
678  goto _test_eof7;
679 case 7:
680  if ( (*p) == 42 )
681  goto st8;
682  goto st7;
683 st8:
684  if ( ++p == pe )
685  goto _test_eof8;
686 case 8:
687  switch( (*p) ) {
688  case 42: goto st8;
689  case 47: goto st1;
690  }
691  goto st7;
692 st9:
693  if ( ++p == pe )
694  goto _test_eof9;
695 case 9:
696  if ( (*p) == 10 )
697  goto st1;
698  goto st9;
699 st10:
700  if ( ++p == pe )
701  goto _test_eof10;
702 case 10:
703  if ( (*p) == 110 )
704  goto st11;
705  goto st0;
706 st11:
707  if ( ++p == pe )
708  goto _test_eof11;
709 case 11:
710  if ( (*p) == 102 )
711  goto st12;
712  goto st0;
713 st12:
714  if ( ++p == pe )
715  goto _test_eof12;
716 case 12:
717  if ( (*p) == 105 )
718  goto st13;
719  goto st0;
720 st13:
721  if ( ++p == pe )
722  goto _test_eof13;
723 case 13:
724  if ( (*p) == 110 )
725  goto st14;
726  goto st0;
727 st14:
728  if ( ++p == pe )
729  goto _test_eof14;
730 case 14:
731  if ( (*p) == 105 )
732  goto st15;
733  goto st0;
734 st15:
735  if ( ++p == pe )
736  goto _test_eof15;
737 case 15:
738  if ( (*p) == 116 )
739  goto st16;
740  goto st0;
741 st16:
742  if ( ++p == pe )
743  goto _test_eof16;
744 case 16:
745  if ( (*p) == 121 )
746  goto tr25;
747  goto st0;
748 st17:
749  if ( ++p == pe )
750  goto _test_eof17;
751 case 17:
752  if ( (*p) == 97 )
753  goto st18;
754  goto st0;
755 st18:
756  if ( ++p == pe )
757  goto _test_eof18;
758 case 18:
759  if ( (*p) == 78 )
760  goto tr27;
761  goto st0;
762 st19:
763  if ( ++p == pe )
764  goto _test_eof19;
765 case 19:
766  if ( (*p) == 97 )
767  goto st20;
768  goto st0;
769 st20:
770  if ( ++p == pe )
771  goto _test_eof20;
772 case 20:
773  if ( (*p) == 108 )
774  goto st21;
775  goto st0;
776 st21:
777  if ( ++p == pe )
778  goto _test_eof21;
779 case 21:
780  if ( (*p) == 115 )
781  goto st22;
782  goto st0;
783 st22:
784  if ( ++p == pe )
785  goto _test_eof22;
786 case 22:
787  if ( (*p) == 101 )
788  goto tr31;
789  goto st0;
790 st23:
791  if ( ++p == pe )
792  goto _test_eof23;
793 case 23:
794  if ( (*p) == 117 )
795  goto st24;
796  goto st0;
797 st24:
798  if ( ++p == pe )
799  goto _test_eof24;
800 case 24:
801  if ( (*p) == 108 )
802  goto st25;
803  goto st0;
804 st25:
805  if ( ++p == pe )
806  goto _test_eof25;
807 case 25:
808  if ( (*p) == 108 )
809  goto tr34;
810  goto st0;
811 st26:
812  if ( ++p == pe )
813  goto _test_eof26;
814 case 26:
815  if ( (*p) == 114 )
816  goto st27;
817  goto st0;
818 st27:
819  if ( ++p == pe )
820  goto _test_eof27;
821 case 27:
822  if ( (*p) == 117 )
823  goto st28;
824  goto st0;
825 st28:
826  if ( ++p == pe )
827  goto _test_eof28;
828 case 28:
829  if ( (*p) == 101 )
830  goto tr37;
831  goto st0;
832  }
833  _test_eof1: cs = 1; goto _test_eof;
834  _test_eof29: cs = 29; goto _test_eof;
835  _test_eof2: cs = 2; goto _test_eof;
836  _test_eof3: cs = 3; goto _test_eof;
837  _test_eof4: cs = 4; goto _test_eof;
838  _test_eof5: cs = 5; goto _test_eof;
839  _test_eof6: cs = 6; goto _test_eof;
840  _test_eof7: cs = 7; goto _test_eof;
841  _test_eof8: cs = 8; goto _test_eof;
842  _test_eof9: cs = 9; goto _test_eof;
843  _test_eof10: cs = 10; goto _test_eof;
844  _test_eof11: cs = 11; goto _test_eof;
845  _test_eof12: cs = 12; goto _test_eof;
846  _test_eof13: cs = 13; goto _test_eof;
847  _test_eof14: cs = 14; goto _test_eof;
848  _test_eof15: cs = 15; goto _test_eof;
849  _test_eof16: cs = 16; goto _test_eof;
850  _test_eof17: cs = 17; goto _test_eof;
851  _test_eof18: cs = 18; goto _test_eof;
852  _test_eof19: cs = 19; goto _test_eof;
853  _test_eof20: cs = 20; goto _test_eof;
854  _test_eof21: cs = 21; goto _test_eof;
855  _test_eof22: cs = 22; goto _test_eof;
856  _test_eof23: cs = 23; goto _test_eof;
857  _test_eof24: cs = 24; goto _test_eof;
858  _test_eof25: cs = 25; goto _test_eof;
859  _test_eof26: cs = 26; goto _test_eof;
860  _test_eof27: cs = 27; goto _test_eof;
861  _test_eof28: cs = 28; goto _test_eof;
862 
863  _test_eof: {}
864  _out: {}
865  }
866 
867 #line 289 "parser.rl"
868 
869  if (cs >= JSON_value_first_final) {
870  return p;
871  } else {
872  return NULL;
873  }
874 }
875 
876 
877 #line 878 "parser.c"
881 
883 
884 
885 #line 305 "parser.rl"
886 
887 
888 static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
889 {
890  int cs = EVIL;
891 
892 
893 #line 894 "parser.c"
894  {
895  cs = JSON_integer_start;
896  }
897 
898 #line 312 "parser.rl"
899  json->memo = p;
900 
901 #line 902 "parser.c"
902  {
903  if ( p == pe )
904  goto _test_eof;
905  switch ( cs )
906  {
907 case 1:
908  switch( (*p) ) {
909  case 45: goto st2;
910  case 48: goto st3;
911  }
912  if ( 49 <= (*p) && (*p) <= 57 )
913  goto st5;
914  goto st0;
915 st0:
916 cs = 0;
917  goto _out;
918 st2:
919  if ( ++p == pe )
920  goto _test_eof2;
921 case 2:
922  if ( (*p) == 48 )
923  goto st3;
924  if ( 49 <= (*p) && (*p) <= 57 )
925  goto st5;
926  goto st0;
927 st3:
928  if ( ++p == pe )
929  goto _test_eof3;
930 case 3:
931  if ( 48 <= (*p) && (*p) <= 57 )
932  goto st0;
933  goto tr4;
934 tr4:
935 #line 302 "parser.rl"
936  { p--; {p++; cs = 4; goto _out;} }
937  goto st4;
938 st4:
939  if ( ++p == pe )
940  goto _test_eof4;
941 case 4:
942 #line 943 "parser.c"
943  goto st0;
944 st5:
945  if ( ++p == pe )
946  goto _test_eof5;
947 case 5:
948  if ( 48 <= (*p) && (*p) <= 57 )
949  goto st5;
950  goto tr4;
951  }
952  _test_eof2: cs = 2; goto _test_eof;
953  _test_eof3: cs = 3; goto _test_eof;
954  _test_eof4: cs = 4; goto _test_eof;
955  _test_eof5: cs = 5; goto _test_eof;
956 
957  _test_eof: {}
958  _out: {}
959  }
960 
961 #line 314 "parser.rl"
962 
963  if (cs >= JSON_integer_first_final) {
964  long len = p - json->memo;
965  fbuffer_clear(json->fbuffer);
966  fbuffer_append(json->fbuffer, json->memo, len);
967  fbuffer_append_char(json->fbuffer, '\0');
968  *result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10);
969  return p + 1;
970  } else {
971  return NULL;
972  }
973 }
974 
975 
976 #line 977 "parser.c"
977 enum {JSON_float_start = 1};
979 enum {JSON_float_error = 0};
980 
982 
983 
984 #line 339 "parser.rl"
985 
986 
987 static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
988 {
989  int cs = EVIL;
990 
991 
992 #line 993 "parser.c"
993  {
994  cs = JSON_float_start;
995  }
996 
997 #line 346 "parser.rl"
998  json->memo = p;
999 
1000 #line 1001 "parser.c"
1001  {
1002  if ( p == pe )
1003  goto _test_eof;
1004  switch ( cs )
1005  {
1006 case 1:
1007  switch( (*p) ) {
1008  case 45: goto st2;
1009  case 48: goto st3;
1010  }
1011  if ( 49 <= (*p) && (*p) <= 57 )
1012  goto st7;
1013  goto st0;
1014 st0:
1015 cs = 0;
1016  goto _out;
1017 st2:
1018  if ( ++p == pe )
1019  goto _test_eof2;
1020 case 2:
1021  if ( (*p) == 48 )
1022  goto st3;
1023  if ( 49 <= (*p) && (*p) <= 57 )
1024  goto st7;
1025  goto st0;
1026 st3:
1027  if ( ++p == pe )
1028  goto _test_eof3;
1029 case 3:
1030  switch( (*p) ) {
1031  case 46: goto st4;
1032  case 69: goto st5;
1033  case 101: goto st5;
1034  }
1035  goto st0;
1036 st4:
1037  if ( ++p == pe )
1038  goto _test_eof4;
1039 case 4:
1040  if ( 48 <= (*p) && (*p) <= 57 )
1041  goto st8;
1042  goto st0;
1043 st8:
1044  if ( ++p == pe )
1045  goto _test_eof8;
1046 case 8:
1047  switch( (*p) ) {
1048  case 69: goto st5;
1049  case 101: goto st5;
1050  }
1051  if ( (*p) > 46 ) {
1052  if ( 48 <= (*p) && (*p) <= 57 )
1053  goto st8;
1054  } else if ( (*p) >= 45 )
1055  goto st0;
1056  goto tr9;
1057 tr9:
1058 #line 333 "parser.rl"
1059  { p--; {p++; cs = 9; goto _out;} }
1060  goto st9;
1061 st9:
1062  if ( ++p == pe )
1063  goto _test_eof9;
1064 case 9:
1065 #line 1066 "parser.c"
1066  goto st0;
1067 st5:
1068  if ( ++p == pe )
1069  goto _test_eof5;
1070 case 5:
1071  switch( (*p) ) {
1072  case 43: goto st6;
1073  case 45: goto st6;
1074  }
1075  if ( 48 <= (*p) && (*p) <= 57 )
1076  goto st10;
1077  goto st0;
1078 st6:
1079  if ( ++p == pe )
1080  goto _test_eof6;
1081 case 6:
1082  if ( 48 <= (*p) && (*p) <= 57 )
1083  goto st10;
1084  goto st0;
1085 st10:
1086  if ( ++p == pe )
1087  goto _test_eof10;
1088 case 10:
1089  switch( (*p) ) {
1090  case 69: goto st0;
1091  case 101: goto st0;
1092  }
1093  if ( (*p) > 46 ) {
1094  if ( 48 <= (*p) && (*p) <= 57 )
1095  goto st10;
1096  } else if ( (*p) >= 45 )
1097  goto st0;
1098  goto tr9;
1099 st7:
1100  if ( ++p == pe )
1101  goto _test_eof7;
1102 case 7:
1103  switch( (*p) ) {
1104  case 46: goto st4;
1105  case 69: goto st5;
1106  case 101: goto st5;
1107  }
1108  if ( 48 <= (*p) && (*p) <= 57 )
1109  goto st7;
1110  goto st0;
1111  }
1112  _test_eof2: cs = 2; goto _test_eof;
1113  _test_eof3: cs = 3; goto _test_eof;
1114  _test_eof4: cs = 4; goto _test_eof;
1115  _test_eof8: cs = 8; goto _test_eof;
1116  _test_eof9: cs = 9; goto _test_eof;
1117  _test_eof5: cs = 5; goto _test_eof;
1118  _test_eof6: cs = 6; goto _test_eof;
1119  _test_eof10: cs = 10; goto _test_eof;
1120  _test_eof7: cs = 7; goto _test_eof;
1121 
1122  _test_eof: {}
1123  _out: {}
1124  }
1125 
1126 #line 348 "parser.rl"
1127 
1128  if (cs >= JSON_float_first_final) {
1129  long len = p - json->memo;
1130  fbuffer_clear(json->fbuffer);
1131  fbuffer_append(json->fbuffer, json->memo, len);
1132  fbuffer_append_char(json->fbuffer, '\0');
1133  *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
1134  return p + 1;
1135  } else {
1136  return NULL;
1137  }
1138 }
1139 
1140 
1141 
1142 #line 1143 "parser.c"
1143 enum {JSON_array_start = 1};
1145 enum {JSON_array_error = 0};
1146 
1148 
1149 
1150 #line 391 "parser.rl"
1151 
1152 
1153 static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
1154 {
1155  int cs = EVIL;
1156  VALUE array_class = json->array_class;
1157 
1158  if (json->max_nesting && current_nesting > json->max_nesting) {
1159  rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
1160  }
1161  *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
1162 
1163 
1164 #line 1165 "parser.c"
1165  {
1166  cs = JSON_array_start;
1167  }
1168 
1169 #line 404 "parser.rl"
1170 
1171 #line 1172 "parser.c"
1172  {
1173  if ( p == pe )
1174  goto _test_eof;
1175  switch ( cs )
1176  {
1177 case 1:
1178  if ( (*p) == 91 )
1179  goto st2;
1180  goto st0;
1181 st0:
1182 cs = 0;
1183  goto _out;
1184 st2:
1185  if ( ++p == pe )
1186  goto _test_eof2;
1187 case 2:
1188  switch( (*p) ) {
1189  case 13: goto st2;
1190  case 32: goto st2;
1191  case 34: goto tr2;
1192  case 45: goto tr2;
1193  case 47: goto st13;
1194  case 73: goto tr2;
1195  case 78: goto tr2;
1196  case 91: goto tr2;
1197  case 93: goto tr4;
1198  case 102: goto tr2;
1199  case 110: goto tr2;
1200  case 116: goto tr2;
1201  case 123: goto tr2;
1202  }
1203  if ( (*p) > 10 ) {
1204  if ( 48 <= (*p) && (*p) <= 57 )
1205  goto tr2;
1206  } else if ( (*p) >= 9 )
1207  goto st2;
1208  goto st0;
1209 tr2:
1210 #line 368 "parser.rl"
1211  {
1212  VALUE v = Qnil;
1213  char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
1214  if (np == NULL) {
1215  p--; {p++; cs = 3; goto _out;}
1216  } else {
1217  if (NIL_P(json->array_class)) {
1218  rb_ary_push(*result, v);
1219  } else {
1220  rb_funcall(*result, i_leftshift, 1, v);
1221  }
1222  {p = (( np))-1;}
1223  }
1224  }
1225  goto st3;
1226 st3:
1227  if ( ++p == pe )
1228  goto _test_eof3;
1229 case 3:
1230 #line 1231 "parser.c"
1231  switch( (*p) ) {
1232  case 13: goto st3;
1233  case 32: goto st3;
1234  case 44: goto st4;
1235  case 47: goto st9;
1236  case 93: goto tr4;
1237  }
1238  if ( 9 <= (*p) && (*p) <= 10 )
1239  goto st3;
1240  goto st0;
1241 st4:
1242  if ( ++p == pe )
1243  goto _test_eof4;
1244 case 4:
1245  switch( (*p) ) {
1246  case 13: goto st4;
1247  case 32: goto st4;
1248  case 34: goto tr2;
1249  case 45: goto tr2;
1250  case 47: goto st5;
1251  case 73: goto tr2;
1252  case 78: goto tr2;
1253  case 91: goto tr2;
1254  case 102: goto tr2;
1255  case 110: goto tr2;
1256  case 116: goto tr2;
1257  case 123: goto tr2;
1258  }
1259  if ( (*p) > 10 ) {
1260  if ( 48 <= (*p) && (*p) <= 57 )
1261  goto tr2;
1262  } else if ( (*p) >= 9 )
1263  goto st4;
1264  goto st0;
1265 st5:
1266  if ( ++p == pe )
1267  goto _test_eof5;
1268 case 5:
1269  switch( (*p) ) {
1270  case 42: goto st6;
1271  case 47: goto st8;
1272  }
1273  goto st0;
1274 st6:
1275  if ( ++p == pe )
1276  goto _test_eof6;
1277 case 6:
1278  if ( (*p) == 42 )
1279  goto st7;
1280  goto st6;
1281 st7:
1282  if ( ++p == pe )
1283  goto _test_eof7;
1284 case 7:
1285  switch( (*p) ) {
1286  case 42: goto st7;
1287  case 47: goto st4;
1288  }
1289  goto st6;
1290 st8:
1291  if ( ++p == pe )
1292  goto _test_eof8;
1293 case 8:
1294  if ( (*p) == 10 )
1295  goto st4;
1296  goto st8;
1297 st9:
1298  if ( ++p == pe )
1299  goto _test_eof9;
1300 case 9:
1301  switch( (*p) ) {
1302  case 42: goto st10;
1303  case 47: goto st12;
1304  }
1305  goto st0;
1306 st10:
1307  if ( ++p == pe )
1308  goto _test_eof10;
1309 case 10:
1310  if ( (*p) == 42 )
1311  goto st11;
1312  goto st10;
1313 st11:
1314  if ( ++p == pe )
1315  goto _test_eof11;
1316 case 11:
1317  switch( (*p) ) {
1318  case 42: goto st11;
1319  case 47: goto st3;
1320  }
1321  goto st10;
1322 st12:
1323  if ( ++p == pe )
1324  goto _test_eof12;
1325 case 12:
1326  if ( (*p) == 10 )
1327  goto st3;
1328  goto st12;
1329 tr4:
1330 #line 383 "parser.rl"
1331  { p--; {p++; cs = 17; goto _out;} }
1332  goto st17;
1333 st17:
1334  if ( ++p == pe )
1335  goto _test_eof17;
1336 case 17:
1337 #line 1338 "parser.c"
1338  goto st0;
1339 st13:
1340  if ( ++p == pe )
1341  goto _test_eof13;
1342 case 13:
1343  switch( (*p) ) {
1344  case 42: goto st14;
1345  case 47: goto st16;
1346  }
1347  goto st0;
1348 st14:
1349  if ( ++p == pe )
1350  goto _test_eof14;
1351 case 14:
1352  if ( (*p) == 42 )
1353  goto st15;
1354  goto st14;
1355 st15:
1356  if ( ++p == pe )
1357  goto _test_eof15;
1358 case 15:
1359  switch( (*p) ) {
1360  case 42: goto st15;
1361  case 47: goto st2;
1362  }
1363  goto st14;
1364 st16:
1365  if ( ++p == pe )
1366  goto _test_eof16;
1367 case 16:
1368  if ( (*p) == 10 )
1369  goto st2;
1370  goto st16;
1371  }
1372  _test_eof2: cs = 2; goto _test_eof;
1373  _test_eof3: cs = 3; goto _test_eof;
1374  _test_eof4: cs = 4; goto _test_eof;
1375  _test_eof5: cs = 5; goto _test_eof;
1376  _test_eof6: cs = 6; goto _test_eof;
1377  _test_eof7: cs = 7; goto _test_eof;
1378  _test_eof8: cs = 8; goto _test_eof;
1379  _test_eof9: cs = 9; goto _test_eof;
1380  _test_eof10: cs = 10; goto _test_eof;
1381  _test_eof11: cs = 11; goto _test_eof;
1382  _test_eof12: cs = 12; goto _test_eof;
1383  _test_eof17: cs = 17; goto _test_eof;
1384  _test_eof13: cs = 13; goto _test_eof;
1385  _test_eof14: cs = 14; goto _test_eof;
1386  _test_eof15: cs = 15; goto _test_eof;
1387  _test_eof16: cs = 16; goto _test_eof;
1388 
1389  _test_eof: {}
1390  _out: {}
1391  }
1392 
1393 #line 405 "parser.rl"
1394 
1395  if(cs >= JSON_array_first_final) {
1396  return p + 1;
1397  } else {
1398  rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
1399  return NULL;
1400  }
1401 }
1402 
1403 static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
1404 {
1405  char *p = string, *pe = string, *unescape;
1406  int unescape_len;
1407  char buf[4];
1408 
1409  while (pe < stringEnd) {
1410  if (*pe == '\\') {
1411  unescape = (char *) "?";
1412  unescape_len = 1;
1413  if (pe > p) rb_str_buf_cat(result, p, pe - p);
1414  switch (*++pe) {
1415  case 'n':
1416  unescape = (char *) "\n";
1417  break;
1418  case 'r':
1419  unescape = (char *) "\r";
1420  break;
1421  case 't':
1422  unescape = (char *) "\t";
1423  break;
1424  case '"':
1425  unescape = (char *) "\"";
1426  break;
1427  case '\\':
1428  unescape = (char *) "\\";
1429  break;
1430  case 'b':
1431  unescape = (char *) "\b";
1432  break;
1433  case 'f':
1434  unescape = (char *) "\f";
1435  break;
1436  case 'u':
1437  if (pe > stringEnd - 4) {
1438  rb_enc_raise(
1440  "%u: incomplete unicode character escape sequence at '%s'", __LINE__, p
1441  );
1442  } else {
1443  UTF32 ch = unescape_unicode((unsigned char *) ++pe);
1444  pe += 3;
1445  if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
1446  pe++;
1447  if (pe > stringEnd - 6) {
1448  rb_enc_raise(
1450  "%u: incomplete surrogate pair at '%s'", __LINE__, p
1451  );
1452  }
1453  if (pe[0] == '\\' && pe[1] == 'u') {
1454  UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
1455  ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
1456  | (sur & 0x3FF));
1457  pe += 5;
1458  } else {
1459  unescape = (char *) "?";
1460  break;
1461  }
1462  }
1463  unescape_len = convert_UTF32_to_UTF8(buf, ch);
1464  unescape = buf;
1465  }
1466  break;
1467  default:
1468  p = pe;
1469  continue;
1470  }
1471  rb_str_buf_cat(result, unescape, unescape_len);
1472  p = ++pe;
1473  } else {
1474  pe++;
1475  }
1476  }
1477  rb_str_buf_cat(result, p, pe - p);
1478  return result;
1479 }
1480 
1481 
1482 #line 1483 "parser.c"
1486 
1488 
1489 
1490 #line 512 "parser.rl"
1491 
1492 
1493 static int
1494 match_i(VALUE regexp, VALUE klass, VALUE memo)
1495 {
1496  if (regexp == Qundef) return ST_STOP;
1497  if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) &&
1498  RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) {
1499  rb_ary_push(memo, klass);
1500  return ST_STOP;
1501  }
1502  return ST_CONTINUE;
1503 }
1504 
1505 static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
1506 {
1507  int cs = EVIL;
1509 
1510  *result = rb_str_buf_new(0);
1511 
1512 #line 1513 "parser.c"
1513  {
1514  cs = JSON_string_start;
1515  }
1516 
1517 #line 533 "parser.rl"
1518  json->memo = p;
1519 
1520 #line 1521 "parser.c"
1521  {
1522  if ( p == pe )
1523  goto _test_eof;
1524  switch ( cs )
1525  {
1526 case 1:
1527  if ( (*p) == 34 )
1528  goto st2;
1529  goto st0;
1530 st0:
1531 cs = 0;
1532  goto _out;
1533 st2:
1534  if ( ++p == pe )
1535  goto _test_eof2;
1536 case 2:
1537  switch( (*p) ) {
1538  case 34: goto tr2;
1539  case 92: goto st3;
1540  }
1541  if ( 0 <= (*p) && (*p) <= 31 )
1542  goto st0;
1543  goto st2;
1544 tr2:
1545 #line 498 "parser.rl"
1546  {
1547  *result = json_string_unescape(*result, json->memo + 1, p);
1548  if (NIL_P(*result)) {
1549  p--;
1550  {p++; cs = 8; goto _out;}
1551  } else {
1552  FORCE_UTF8(*result);
1553  {p = (( p + 1))-1;}
1554  }
1555  }
1556 #line 509 "parser.rl"
1557  { p--; {p++; cs = 8; goto _out;} }
1558  goto st8;
1559 st8:
1560  if ( ++p == pe )
1561  goto _test_eof8;
1562 case 8:
1563 #line 1564 "parser.c"
1564  goto st0;
1565 st3:
1566  if ( ++p == pe )
1567  goto _test_eof3;
1568 case 3:
1569  if ( (*p) == 117 )
1570  goto st4;
1571  if ( 0 <= (*p) && (*p) <= 31 )
1572  goto st0;
1573  goto st2;
1574 st4:
1575  if ( ++p == pe )
1576  goto _test_eof4;
1577 case 4:
1578  if ( (*p) < 65 ) {
1579  if ( 48 <= (*p) && (*p) <= 57 )
1580  goto st5;
1581  } else if ( (*p) > 70 ) {
1582  if ( 97 <= (*p) && (*p) <= 102 )
1583  goto st5;
1584  } else
1585  goto st5;
1586  goto st0;
1587 st5:
1588  if ( ++p == pe )
1589  goto _test_eof5;
1590 case 5:
1591  if ( (*p) < 65 ) {
1592  if ( 48 <= (*p) && (*p) <= 57 )
1593  goto st6;
1594  } else if ( (*p) > 70 ) {
1595  if ( 97 <= (*p) && (*p) <= 102 )
1596  goto st6;
1597  } else
1598  goto st6;
1599  goto st0;
1600 st6:
1601  if ( ++p == pe )
1602  goto _test_eof6;
1603 case 6:
1604  if ( (*p) < 65 ) {
1605  if ( 48 <= (*p) && (*p) <= 57 )
1606  goto st7;
1607  } else if ( (*p) > 70 ) {
1608  if ( 97 <= (*p) && (*p) <= 102 )
1609  goto st7;
1610  } else
1611  goto st7;
1612  goto st0;
1613 st7:
1614  if ( ++p == pe )
1615  goto _test_eof7;
1616 case 7:
1617  if ( (*p) < 65 ) {
1618  if ( 48 <= (*p) && (*p) <= 57 )
1619  goto st2;
1620  } else if ( (*p) > 70 ) {
1621  if ( 97 <= (*p) && (*p) <= 102 )
1622  goto st2;
1623  } else
1624  goto st2;
1625  goto st0;
1626  }
1627  _test_eof2: cs = 2; goto _test_eof;
1628  _test_eof8: cs = 8; goto _test_eof;
1629  _test_eof3: cs = 3; goto _test_eof;
1630  _test_eof4: cs = 4; goto _test_eof;
1631  _test_eof5: cs = 5; goto _test_eof;
1632  _test_eof6: cs = 6; goto _test_eof;
1633  _test_eof7: cs = 7; goto _test_eof;
1634 
1635  _test_eof: {}
1636  _out: {}
1637  }
1638 
1639 #line 535 "parser.rl"
1640 
1641  if (json->create_additions && RTEST(match_string = json->match_string)) {
1642  VALUE klass;
1643  VALUE memo = rb_ary_new2(2);
1644  rb_ary_push(memo, *result);
1645  rb_hash_foreach(match_string, match_i, memo);
1646  klass = rb_ary_entry(memo, 1);
1647  if (RTEST(klass)) {
1648  *result = rb_funcall(klass, i_json_create, 1, *result);
1649  }
1650  }
1651 
1652  if (json->symbolize_names && json->parsing_name) {
1653  *result = rb_str_intern(*result);
1654  } else {
1655  rb_str_resize(*result, RSTRING_LEN(*result));
1656  }
1657  if (cs >= JSON_string_first_final) {
1658  return p + 1;
1659  } else {
1660  return NULL;
1661  }
1662 }
1663 
1664 /*
1665  * Document-class: JSON::Ext::Parser
1666  *
1667  * This is the JSON parser implemented as a C extension. It can be configured
1668  * to be used by setting
1669  *
1670  * JSON.parser = JSON::Ext::Parser
1671  *
1672  * with the method parser= in JSON.
1673  *
1674  */
1675 
1677 {
1678 #ifdef HAVE_RUBY_ENCODING_H
1679  rb_encoding *enc = rb_enc_get(source);
1680  if (enc == rb_ascii8bit_encoding()) {
1681  if (OBJ_FROZEN(source)) {
1682  source = rb_str_dup(source);
1683  }
1684  FORCE_UTF8(source);
1685  } else {
1686  source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding());
1687  }
1688 #endif
1689  return source;
1690 }
1691 
1692 /*
1693  * call-seq: new(source, opts => {})
1694  *
1695  * Creates a new JSON::Ext::Parser instance for the string _source_.
1696  *
1697  * Creates a new JSON::Ext::Parser instance for the string _source_.
1698  *
1699  * It will be configured by the _opts_ hash. _opts_ can have the following
1700  * keys:
1701  *
1702  * _opts_ can have the following keys:
1703  * * *max_nesting*: The maximum depth of nesting allowed in the parsed data
1704  * structures. Disable depth checking with :max_nesting => false|nil|0, it
1705  * defaults to 100.
1706  * * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
1707  * defiance of RFC 4627 to be parsed by the Parser. This option defaults to
1708  * false.
1709  * * *symbolize_names*: If set to true, returns symbols for the names
1710  * (keys) in a JSON object. Otherwise strings are returned, which is
1711  * also the default. It's not possible to use this option in
1712  * conjunction with the *create_additions* option.
1713  * * *create_additions*: If set to false, the Parser doesn't create
1714  * additions even if a matching class and create_id was found. This option
1715  * defaults to false.
1716  * * *object_class*: Defaults to Hash
1717  * * *array_class*: Defaults to Array
1718  */
1720 {
1721  VALUE source, opts;
1723 
1724  if (json->Vsource) {
1725  rb_raise(rb_eTypeError, "already initialized instance");
1726  }
1727 #ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
1728  rb_scan_args(argc, argv, "1:", &source, &opts);
1729 #else
1730  rb_scan_args(argc, argv, "11", &source, &opts);
1731 #endif
1732  if (!NIL_P(opts)) {
1733 #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
1734  opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
1735  if (NIL_P(opts)) {
1736  rb_raise(rb_eArgError, "opts needs to be like a hash");
1737  } else {
1738 #endif
1739  VALUE tmp = ID2SYM(i_max_nesting);
1740  if (option_given_p(opts, tmp)) {
1741  VALUE max_nesting = rb_hash_aref(opts, tmp);
1742  if (RTEST(max_nesting)) {
1743  Check_Type(max_nesting, T_FIXNUM);
1744  json->max_nesting = FIX2INT(max_nesting);
1745  } else {
1746  json->max_nesting = 0;
1747  }
1748  } else {
1749  json->max_nesting = 100;
1750  }
1751  tmp = ID2SYM(i_allow_nan);
1752  if (option_given_p(opts, tmp)) {
1753  json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
1754  } else {
1755  json->allow_nan = 0;
1756  }
1757  tmp = ID2SYM(i_symbolize_names);
1758  if (option_given_p(opts, tmp)) {
1759  json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
1760  } else {
1761  json->symbolize_names = 0;
1762  }
1763  tmp = ID2SYM(i_create_additions);
1764  if (option_given_p(opts, tmp)) {
1765  json->create_additions = RTEST(rb_hash_aref(opts, tmp));
1766  } else {
1767  json->create_additions = 0;
1768  }
1769  if (json->symbolize_names && json->create_additions) {
1771  "options :symbolize_names and :create_additions cannot be "
1772  " used in conjunction");
1773  }
1774  tmp = ID2SYM(i_create_id);
1775  if (option_given_p(opts, tmp)) {
1776  json->create_id = rb_hash_aref(opts, tmp);
1777  } else {
1778  json->create_id = rb_funcall(mJSON, i_create_id, 0);
1779  }
1780  tmp = ID2SYM(i_object_class);
1781  if (option_given_p(opts, tmp)) {
1782  json->object_class = rb_hash_aref(opts, tmp);
1783  } else {
1784  json->object_class = Qnil;
1785  }
1786  tmp = ID2SYM(i_array_class);
1787  if (option_given_p(opts, tmp)) {
1788  json->array_class = rb_hash_aref(opts, tmp);
1789  } else {
1790  json->array_class = Qnil;
1791  }
1792  tmp = ID2SYM(i_match_string);
1793  if (option_given_p(opts, tmp)) {
1794  VALUE match_string = rb_hash_aref(opts, tmp);
1795  json->match_string = RTEST(match_string) ? match_string : Qnil;
1796  } else {
1797  json->match_string = Qnil;
1798  }
1799 #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
1800  }
1801 #endif
1802  } else {
1803  json->max_nesting = 100;
1804  json->allow_nan = 0;
1805  json->create_additions = 1;
1806  json->create_id = rb_funcall(mJSON, i_create_id, 0);
1807  json->object_class = Qnil;
1808  json->array_class = Qnil;
1809  }
1810  source = convert_encoding(StringValue(source));
1811  StringValue(source);
1812  json->len = RSTRING_LEN(source);
1813  json->source = RSTRING_PTR(source);;
1814  json->Vsource = source;
1815  return self;
1816 }
1817 
1818 
1819 #line 1820 "parser.c"
1820 enum {JSON_start = 1};
1821 enum {JSON_first_final = 10};
1822 enum {JSON_error = 0};
1823 
1824 enum {JSON_en_main = 1};
1825 
1826 
1827 #line 728 "parser.rl"
1828 
1829 
1830 /*
1831  * call-seq: parse()
1832  *
1833  * Parses the current JSON text _source_ and returns the complete data
1834  * structure as a result.
1835  */
1837 {
1838  char *p, *pe;
1839  int cs = EVIL;
1840  VALUE result = Qnil;
1841  GET_PARSER;
1842 
1843 
1844 #line 1845 "parser.c"
1845  {
1846  cs = JSON_start;
1847  }
1848 
1849 #line 744 "parser.rl"
1850  p = json->source;
1851  pe = p + json->len;
1852 
1853 #line 1854 "parser.c"
1854  {
1855  if ( p == pe )
1856  goto _test_eof;
1857  switch ( cs )
1858  {
1859 st1:
1860  if ( ++p == pe )
1861  goto _test_eof1;
1862 case 1:
1863  switch( (*p) ) {
1864  case 13: goto st1;
1865  case 32: goto st1;
1866  case 34: goto tr2;
1867  case 45: goto tr2;
1868  case 47: goto st6;
1869  case 73: goto tr2;
1870  case 78: goto tr2;
1871  case 91: goto tr2;
1872  case 102: goto tr2;
1873  case 110: goto tr2;
1874  case 116: goto tr2;
1875  case 123: goto tr2;
1876  }
1877  if ( (*p) > 10 ) {
1878  if ( 48 <= (*p) && (*p) <= 57 )
1879  goto tr2;
1880  } else if ( (*p) >= 9 )
1881  goto st1;
1882  goto st0;
1883 st0:
1884 cs = 0;
1885  goto _out;
1886 tr2:
1887 #line 720 "parser.rl"
1888  {
1889  char *np = JSON_parse_value(json, p, pe, &result, 0);
1890  if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
1891  }
1892  goto st10;
1893 st10:
1894  if ( ++p == pe )
1895  goto _test_eof10;
1896 case 10:
1897 #line 1898 "parser.c"
1898  switch( (*p) ) {
1899  case 13: goto st10;
1900  case 32: goto st10;
1901  case 47: goto st2;
1902  }
1903  if ( 9 <= (*p) && (*p) <= 10 )
1904  goto st10;
1905  goto st0;
1906 st2:
1907  if ( ++p == pe )
1908  goto _test_eof2;
1909 case 2:
1910  switch( (*p) ) {
1911  case 42: goto st3;
1912  case 47: goto st5;
1913  }
1914  goto st0;
1915 st3:
1916  if ( ++p == pe )
1917  goto _test_eof3;
1918 case 3:
1919  if ( (*p) == 42 )
1920  goto st4;
1921  goto st3;
1922 st4:
1923  if ( ++p == pe )
1924  goto _test_eof4;
1925 case 4:
1926  switch( (*p) ) {
1927  case 42: goto st4;
1928  case 47: goto st10;
1929  }
1930  goto st3;
1931 st5:
1932  if ( ++p == pe )
1933  goto _test_eof5;
1934 case 5:
1935  if ( (*p) == 10 )
1936  goto st10;
1937  goto st5;
1938 st6:
1939  if ( ++p == pe )
1940  goto _test_eof6;
1941 case 6:
1942  switch( (*p) ) {
1943  case 42: goto st7;
1944  case 47: goto st9;
1945  }
1946  goto st0;
1947 st7:
1948  if ( ++p == pe )
1949  goto _test_eof7;
1950 case 7:
1951  if ( (*p) == 42 )
1952  goto st8;
1953  goto st7;
1954 st8:
1955  if ( ++p == pe )
1956  goto _test_eof8;
1957 case 8:
1958  switch( (*p) ) {
1959  case 42: goto st8;
1960  case 47: goto st1;
1961  }
1962  goto st7;
1963 st9:
1964  if ( ++p == pe )
1965  goto _test_eof9;
1966 case 9:
1967  if ( (*p) == 10 )
1968  goto st1;
1969  goto st9;
1970  }
1971  _test_eof1: cs = 1; goto _test_eof;
1972  _test_eof10: cs = 10; goto _test_eof;
1973  _test_eof2: cs = 2; goto _test_eof;
1974  _test_eof3: cs = 3; goto _test_eof;
1975  _test_eof4: cs = 4; goto _test_eof;
1976  _test_eof5: cs = 5; goto _test_eof;
1977  _test_eof6: cs = 6; goto _test_eof;
1978  _test_eof7: cs = 7; goto _test_eof;
1979  _test_eof8: cs = 8; goto _test_eof;
1980  _test_eof9: cs = 9; goto _test_eof;
1981 
1982  _test_eof: {}
1983  _out: {}
1984  }
1985 
1986 #line 747 "parser.rl"
1987 
1988  if (cs >= JSON_first_final && p == pe) {
1989  return result;
1990  } else {
1991  rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
1992  return Qnil;
1993  }
1994 }
1995 
1996 static void JSON_mark(void *ptr)
1997 {
1998  JSON_Parser *json = ptr;
1999  rb_gc_mark_maybe(json->Vsource);
2000  rb_gc_mark_maybe(json->create_id);
2004 }
2005 
2006 static void JSON_free(void *ptr)
2007 {
2008  JSON_Parser *json = ptr;
2009  fbuffer_free(json->fbuffer);
2010  ruby_xfree(json);
2011 }
2012 
2013 static size_t JSON_memsize(const void *ptr)
2014 {
2015  const JSON_Parser *json = ptr;
2016  return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
2017 }
2018 
2019 #ifdef NEW_TYPEDDATA_WRAPPER
2021  "JSON/Parser",
2023 #ifdef RUBY_TYPED_FREE_IMMEDIATELY
2024  0, 0,
2026 #endif
2027 };
2028 #endif
2029 
2031 {
2032  JSON_Parser *json;
2033  VALUE obj = TypedData_Make_Struct(klass, JSON_Parser, &JSON_Parser_type, json);
2034  json->fbuffer = fbuffer_alloc(0);
2035  return obj;
2036 }
2037 
2038 /*
2039  * call-seq: source()
2040  *
2041  * Returns a copy of the current _source_ string, that was used to construct
2042  * this Parser.
2043  */
2045 {
2046  GET_PARSER;
2047  return rb_str_dup(json->Vsource);
2048 }
2049 
2050 void Init_parser(void)
2051 {
2052  rb_require("json/common");
2053  mJSON = rb_define_module("JSON");
2054  mExt = rb_define_module_under(mJSON, "Ext");
2056  eParserError = rb_path2class("JSON::ParserError");
2057  eNestingError = rb_path2class("JSON::NestingError");
2059  rb_define_method(cParser, "initialize", cParser_initialize, -1);
2060  rb_define_method(cParser, "parse", cParser_parse, 0);
2061  rb_define_method(cParser, "source", cParser_source, 0);
2062 
2063  CNaN = rb_const_get(mJSON, rb_intern("NaN"));
2064  CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
2065  CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
2066 
2067  i_json_creatable_p = rb_intern("json_creatable?");
2068  i_json_create = rb_intern("json_create");
2069  i_create_id = rb_intern("create_id");
2070  i_create_additions = rb_intern("create_additions");
2071  i_chr = rb_intern("chr");
2072  i_max_nesting = rb_intern("max_nesting");
2073  i_allow_nan = rb_intern("allow_nan");
2074  i_symbolize_names = rb_intern("symbolize_names");
2075  i_object_class = rb_intern("object_class");
2076  i_array_class = rb_intern("array_class");
2077  i_match = rb_intern("match");
2078  i_match_string = rb_intern("match_string");
2079  i_key_p = rb_intern("key?");
2080  i_deep_const_get = rb_intern("deep_const_get");
2081  i_aset = rb_intern("[]=");
2082  i_aref = rb_intern("[]");
2083  i_leftshift = rb_intern("<<");
2084 }
2085 
2086 /*
2087  * Local variables:
2088  * mode: c
2089  * c-file-style: ruby
2090  * indent-tabs-mode: nil
2091  * End:
2092  */
static size_t JSON_memsize(const void *ptr)
Definition: parser.c:2013
#define FBUFFER_CAPA(fb)
Definition: fbuffer.h:57
static void fbuffer_clear(FBuffer *fb)
Definition: fbuffer.h:89
int create_additions
Definition: parser.h:42
VALUE rb_ary_entry(VALUE ary, long offset)
Definition: array.c:1196
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
char * memo
Definition: parser.h:34
#define T_FIXNUM
Definition: ruby.h:503
static ID i_aref
Definition: parser.c:95
Definition: st.h:99
static void JSON_mark(void *ptr)
Definition: parser.c:1996
static VALUE cParser_source(VALUE self)
Definition: parser.c:2044
#define Qtrue
Definition: ruby.h:437
#define option_given_p(opts, key)
Definition: generator.h:23
static VALUE convert_encoding(VALUE source)
Definition: parser.c:1676
Definition: st.h:99
static ID i_allow_nan
Definition: parser.c:95
VALUE rb_eTypeError
Definition: error.c:762
VALUE rb_ary_push(VALUE ary, VALUE item)
Definition: array.c:905
static VALUE eParserError
Definition: parser.c:92
static VALUE match_string(VALUE match)
Definition: re.c:2105
static ID i_max_nesting
Definition: parser.c:95
int parsing_name
Definition: parser.h:38
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:821
static void fbuffer_append_char(FBuffer *fb, char newchr)
Definition: fbuffer.h:132
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
Definition: class.c:693
#define Check_Type(v, t)
Definition: ruby.h:562
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2207
VALUE rb_convert_type(VALUE, int, const char *, const char *)
Definition: object.c:2630
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
#define T_HASH
Definition: ruby.h:499
static VALUE cJSON_parser_s_allocate(VALUE klass)
Definition: parser.c:2030
static VALUE cParser_parse(VALUE self)
Definition: parser.c:1836
static char * JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
Definition: parser.c:494
static VALUE CMinusInfinity
Definition: parser.c:93
static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
Definition: parser.c:66
VALUE rb_enc_vsprintf(rb_encoding *, const char *, va_list)
Definition: sprintf.c:1388
static const rb_data_type_t JSON_Parser_type
Definition: parser.c:2020
VALUE rb_path2class(const char *)
Definition: variable.c:431
rb_encoding * rb_utf8_encoding(void)
Definition: encoding.c:1320
#define GET_PARSER
Definition: parser.h:47
static char * JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
Definition: parser.c:1153
static ID i_aset
Definition: parser.c:95
static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
Definition: parser.c:1719
#define rb_ary_new2
Definition: intern.h:90
VALUE rb_str_buf_cat(VALUE, const char *, long)
void rb_hash_foreach(VALUE hash, int(*func)(ANYARGS), VALUE farg)
Definition: hash.c:402
void rb_exc_raise(VALUE mesg)
Definition: eval.c:620
static char * JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
Definition: parser.c:1505
static ID i_chr
Definition: parser.c:95
VALUE rb_require(const char *)
Definition: load.c:1056
#define GET_PARSER_INIT
Definition: parser.h:50
static ID i_deep_const_get
Definition: parser.c:95
static VALUE eNestingError
Definition: parser.c:92
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
Definition: hash.c:1576
RUBY_EXTERN VALUE rb_cObject
Definition: ruby.h:1872
#define rb_float_new(d)
Definition: internal.h:1296
static ID i_match
Definition: parser.c:95
static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len)
Definition: fbuffer.h:111
VALUE rb_ary_new(void)
Definition: array.c:493
unsigned long UTF32
Definition: generator.h:29
#define NIL_P(v)
Definition: ruby.h:451
static void JSON_free(void *ptr)
Definition: parser.c:2006
static ID i_object_class
Definition: parser.c:95
VALUE object_class
Definition: parser.h:40
#define rb_enc_raise
Definition: parser.c:21
#define OBJ_FROZEN(x)
Definition: ruby.h:1306
static VALUE cParser
Definition: parser.c:92
int argc
Definition: ruby.c:183
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
Definition: string.c:992
#define Qfalse
Definition: ruby.h:436
static ID i_match_string
Definition: parser.c:95
int symbolize_names
Definition: parser.h:39
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
Definition: object.c:1891
static VALUE CNaN
Definition: parser.c:93
static FBuffer * fbuffer_alloc(unsigned long initial_length)
Definition: fbuffer.h:73
VALUE rb_str_resize(VALUE, long)
Definition: string.c:2562
VALUE rb_const_get(VALUE, ID)
Definition: variable.c:2335
#define RSTRING_LEN(str)
Definition: ruby.h:978
static ID i_json_create
Definition: parser.c:95
VALUE rb_hash_new(void)
Definition: hash.c:441
void ruby_xfree(void *x)
Definition: gc.c:8017
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Definition: class.c:1919
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4309
unsigned long ID
Definition: ruby.h:86
#define Qnil
Definition: ruby.h:438
unsigned long VALUE
Definition: ruby.h:85
static VALUE result
Definition: nkf.c:40
static VALUE mJSON
Definition: parser.c:92
#define FIX2INT(x)
Definition: ruby.h:686
static ID i_key_p
Definition: parser.c:95
static char * JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
Definition: parser.c:116
#define UNI_SUR_HIGH_START
Definition: generator.h:39
VALUE rb_str_dup(VALUE)
Definition: string.c:1436
register unsigned int len
Definition: zonetab.h:51
VALUE rb_define_module_under(VALUE outer, const char *name)
Definition: class.c:790
#define RSTRING_PTR(str)
Definition: ruby.h:982
#define rb_exc_new3
Definition: intern.h:246
static VALUE mExt
Definition: parser.c:92
static ID i_array_class
Definition: parser.c:95
rb_encoding * rb_enc_get(VALUE obj)
Definition: encoding.c:860
static void enc_raise(rb_encoding *enc, VALUE exc, const char *fmt,...)
Definition: parser.c:10
static ID i_create_id
Definition: parser.c:95
static VALUE CInfinity
Definition: parser.c:93
#define FORCE_UTF8(obj)
Definition: fbuffer.h:36
static void fbuffer_free(FBuffer *fb)
Definition: fbuffer.h:83
#define FBUFFER_PTR(fb)
Definition: fbuffer.h:55
static char * JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
Definition: parser.c:888
static UTF32 unescape_unicode(const unsigned char *p)
Definition: parser.c:47
VALUE rb_hash_aref(VALUE hash, VALUE key)
Definition: hash.c:845
#define EXC_ENCODING
Definition: parser.c:7
void Init_parser(void)
Definition: parser.c:2050
#define MinusInfinity
Definition: parser.h:54
#define RTEST(v)
Definition: ruby.h:450
static const char digit_values[256]
Definition: parser.c:30
#define TypedData_Make_Struct(klass, type, data_type, sval)
Definition: ruby.h:1182
#define UNI_REPLACEMENT_CHAR
Definition: generator.h:33
static ID i_symbolize_names
Definition: parser.c:95
void rb_gc_mark_maybe(VALUE obj)
Definition: gc.c:4247
#define ID2SYM(x)
Definition: ruby.h:383
FBuffer * fbuffer
Definition: parser.h:44
static ID i_json_creatable_p
Definition: parser.c:95
VALUE array_class
Definition: parser.h:41
static ID i_create_additions
Definition: parser.c:95
rb_encoding * rb_ascii8bit_encoding(void)
Definition: encoding.c:1305
#define EVIL
Definition: parser.h:55
VALUE Vsource
Definition: parser.h:31
VALUE match_string
Definition: parser.h:43
static char * JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
Definition: parser.c:987
VALUE rb_str_intern(VALUE)
Definition: symbol.c:661
static int match_i(VALUE regexp, VALUE klass, VALUE memo)
Definition: parser.c:1494
static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
Definition: parser.c:1403
static ID i_leftshift
Definition: parser.c:95
VALUE rb_define_module(const char *name)
Definition: class.c:768
#define rb_intern(str)
VALUE rb_str_buf_new(long)
Definition: string.c:1247
#define NULL
Definition: _sdbm.c:102
#define Qundef
Definition: ruby.h:439
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1515
VALUE create_id
Definition: parser.h:35
double rb_cstr_to_dbl(const char *, int)
Definition: object.c:2785
VALUE rb_eArgError
Definition: error.c:763
VALUE rb_cstr2inum(const char *str, int base)
Definition: bignum.c:4488
char ** argv
Definition: ruby.c:184
#define StringValue(v)
Definition: ruby.h:569