json_pure 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,5 @@
1
+ 2007-03-24 (1.0.2)
2
+ * Ext Parser didn't parse 0e0 correctly into 0.0: Fixed!
1
3
  2007-03-24 (1.0.1)
2
4
  * Forgot some object files in the build dir. I really like that- not!
3
5
  2007-03-24 (1.0.0)
data/Rakefile CHANGED
@@ -77,24 +77,20 @@ end
77
77
  desc "Generate diagrams of ragel parser (ps)"
78
78
  task :ragel_dot_ps do
79
79
  root = 'diagrams'
80
- cd EXT_PARSER_DIR do
81
- specs = []
82
- File.new('parser.rl').grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
83
- for s in specs
84
- sh "ragel parser.rl -S#{s} | #{RAGEL_CODEGEN} -p -V|dot -Tps -o#{root}/#{s}.ps"
85
- end
80
+ specs = []
81
+ File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
82
+ for s in specs
83
+ sh "ragel #{RAGEL_PATH} -S#{s} | #{RAGEL_CODEGEN} -p -V|dot -Tps -o#{root}/#{s}.ps"
86
84
  end
87
85
  end
88
86
 
89
87
  desc "Generate diagrams of ragel parser (png)"
90
88
  task :ragel_dot_png do
91
89
  root = 'diagrams'
92
- cd EXT_PARSER_DIR do
93
- specs = []
94
- File.new('parser.rl').grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
95
- for s in specs
96
- sh "ragel parser.rl -S#{s} | #{RAGEL_CODEGEN} -p -V|dot -Tpng -o#{root}/#{s}.png"
97
- end
90
+ specs = []
91
+ File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
92
+ for s in specs
93
+ sh "ragel #{RAGEL_PATH} -S#{s} | #{RAGEL_CODEGEN} -p -V|dot -Tpng -o#{root}/#{s}.png"
98
94
  end
99
95
  end
100
96
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ $KCODE = 'U'
3
+ require 'json'
4
+ require 'fileutils'
5
+ include FileUtils
6
+
7
+ # Parses the argument array _args_, according to the pattern _s_, to
8
+ # retrieve the single character command line options from it. If _s_ is
9
+ # 'xy:' an option '-x' without an option argument is searched, and an
10
+ # option '-y foo' with an option argument ('foo').
11
+ #
12
+ # An option hash is returned with all found options set to true or the
13
+ # found option argument.
14
+ def go(s, args = ARGV)
15
+ b, v = s.scan(/(.)(:?)/).inject([{},{}]) { |t,(o,a)|
16
+ t[a.empty? ? 0 : 1][o] = a.empty? ? false : nil
17
+ t
18
+ }
19
+ while a = args.shift
20
+ a !~ /\A-(.+)/ and args.unshift a and break
21
+ p = $1
22
+ until p == ''
23
+ o = p.slice!(0, 1)
24
+ if v.key?(o)
25
+ v[o] = if p == '': args.shift or break 1 else p end
26
+ break
27
+ elsif b.key?(o)
28
+ b[o] = true
29
+ else
30
+ args.unshift a
31
+ break 1
32
+ end
33
+ end and break
34
+ end
35
+ b.merge(v)
36
+ end
37
+
38
+ opts = go 'slhi:', args = ARGV.dup
39
+ if opts['h'] || opts['l'] && opts['s']
40
+ puts <<EOT
41
+ Usage: #{File.basename($0)} [OPTION] [FILE]
42
+
43
+ If FILE is skipped, this scripts waits for input from STDIN. Otherwise
44
+ FILE is opened, read, and used as input for the prettifier.
45
+
46
+ OPTION can be
47
+ -s to output the shortest possible JSON (precludes -l)
48
+ -l to output a longer, better formatted JSON (precludes -s)
49
+ -i EXT prettifies FILE in place, saving a backup to FILE.EXT
50
+ -h this help
51
+ EOT
52
+ exit 0
53
+ end
54
+
55
+ filename = nil
56
+ json = JSON[
57
+ if args.empty?
58
+ STDIN.read
59
+ else
60
+ File.read filename = args.first
61
+ end
62
+ ]
63
+
64
+ output = if opts['s']
65
+ JSON.fast_generate json
66
+ else # default is -l
67
+ JSON.pretty_generate json
68
+ end
69
+
70
+ if opts['i'] && filename
71
+ cp filename, "#{filename}.#{opts['i']}"
72
+ File.open(filename, 'w') { |f| f.puts output }
73
+ else
74
+ puts output
75
+ end
@@ -39,11 +39,11 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
39
39
 
40
40
 
41
41
  #line 42 "parser.c"
42
- static const int JSON_object_start = 0;
43
-
42
+ static const int JSON_object_start = 1;
44
43
  static const int JSON_object_first_final = 27;
44
+ static const int JSON_object_error = 0;
45
45
 
46
- static const int JSON_object_error = 1;
46
+ static const int JSON_object_en_main = 1;
47
47
 
48
48
  #line 92 "parser.rl"
49
49
 
@@ -67,12 +67,12 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
67
67
  goto _out;
68
68
  switch ( cs )
69
69
  {
70
- case 0:
70
+ case 1:
71
71
  if ( (*p) == 123 )
72
72
  goto st2;
73
- goto st1;
74
- st1:
75
- goto _out1;
73
+ goto st0;
74
+ st0:
75
+ goto _out0;
76
76
  st2:
77
77
  if ( ++p == pe )
78
78
  goto _out2;
@@ -80,14 +80,14 @@ case 2:
80
80
  switch( (*p) ) {
81
81
  case 13: goto st2;
82
82
  case 32: goto st2;
83
- case 34: goto tr13;
83
+ case 34: goto tr2;
84
84
  case 47: goto st23;
85
- case 125: goto tr10;
85
+ case 125: goto tr4;
86
86
  }
87
87
  if ( 9 <= (*p) && (*p) <= 10 )
88
88
  goto st2;
89
- goto st1;
90
- tr13:
89
+ goto st0;
90
+ tr2:
91
91
  #line 78 "parser.rl"
92
92
  {
93
93
  char *np = JSON_parse_string(json, p, pe, &last_name);
@@ -107,7 +107,7 @@ case 3:
107
107
  }
108
108
  if ( 9 <= (*p) && (*p) <= 10 )
109
109
  goto st3;
110
- goto st1;
110
+ goto st0;
111
111
  st4:
112
112
  if ( ++p == pe )
113
113
  goto _out4;
@@ -116,7 +116,7 @@ case 4:
116
116
  case 42: goto st5;
117
117
  case 47: goto st7;
118
118
  }
119
- goto st1;
119
+ goto st0;
120
120
  st5:
121
121
  if ( ++p == pe )
122
122
  goto _out5;
@@ -161,7 +161,7 @@ case 8:
161
161
  goto tr11;
162
162
  } else if ( (*p) >= 9 )
163
163
  goto st8;
164
- goto st1;
164
+ goto st0;
165
165
  tr11:
166
166
  #line 67 "parser.rl"
167
167
  {
@@ -185,11 +185,11 @@ case 9:
185
185
  case 32: goto st9;
186
186
  case 44: goto st10;
187
187
  case 47: goto st15;
188
- case 125: goto tr10;
188
+ case 125: goto tr4;
189
189
  }
190
190
  if ( 9 <= (*p) && (*p) <= 10 )
191
191
  goto st9;
192
- goto st1;
192
+ goto st0;
193
193
  st10:
194
194
  if ( ++p == pe )
195
195
  goto _out10;
@@ -197,12 +197,12 @@ case 10:
197
197
  switch( (*p) ) {
198
198
  case 13: goto st10;
199
199
  case 32: goto st10;
200
- case 34: goto tr13;
200
+ case 34: goto tr2;
201
201
  case 47: goto st11;
202
202
  }
203
203
  if ( 9 <= (*p) && (*p) <= 10 )
204
204
  goto st10;
205
- goto st1;
205
+ goto st0;
206
206
  st11:
207
207
  if ( ++p == pe )
208
208
  goto _out11;
@@ -211,7 +211,7 @@ case 11:
211
211
  case 42: goto st12;
212
212
  case 47: goto st14;
213
213
  }
214
- goto st1;
214
+ goto st0;
215
215
  st12:
216
216
  if ( ++p == pe )
217
217
  goto _out12;
@@ -243,7 +243,7 @@ case 15:
243
243
  case 42: goto st16;
244
244
  case 47: goto st18;
245
245
  }
246
- goto st1;
246
+ goto st0;
247
247
  st16:
248
248
  if ( ++p == pe )
249
249
  goto _out16;
@@ -267,7 +267,7 @@ case 18:
267
267
  if ( (*p) == 10 )
268
268
  goto st9;
269
269
  goto st18;
270
- tr10:
270
+ tr4:
271
271
  #line 83 "parser.rl"
272
272
  { goto _out27; }
273
273
  goto st27;
@@ -276,7 +276,7 @@ st27:
276
276
  goto _out27;
277
277
  case 27:
278
278
  #line 279 "parser.c"
279
- goto st1;
279
+ goto st0;
280
280
  st19:
281
281
  if ( ++p == pe )
282
282
  goto _out19;
@@ -285,7 +285,7 @@ case 19:
285
285
  case 42: goto st20;
286
286
  case 47: goto st22;
287
287
  }
288
- goto st1;
288
+ goto st0;
289
289
  st20:
290
290
  if ( ++p == pe )
291
291
  goto _out20;
@@ -317,7 +317,7 @@ case 23:
317
317
  case 42: goto st24;
318
318
  case 47: goto st26;
319
319
  }
320
- goto st1;
320
+ goto st0;
321
321
  st24:
322
322
  if ( ++p == pe )
323
323
  goto _out24;
@@ -342,7 +342,7 @@ case 26:
342
342
  goto st2;
343
343
  goto st26;
344
344
  }
345
- _out1: cs = 1; goto _out;
345
+ _out0: cs = 0; goto _out;
346
346
  _out2: cs = 2; goto _out;
347
347
  _out3: cs = 3; goto _out;
348
348
  _out4: cs = 4; goto _out;
@@ -390,11 +390,11 @@ case 26:
390
390
 
391
391
 
392
392
  #line 393 "parser.c"
393
- static const int JSON_value_start = 0;
394
-
393
+ static const int JSON_value_start = 1;
395
394
  static const int JSON_value_first_final = 12;
395
+ static const int JSON_value_error = 0;
396
396
 
397
- static const int JSON_value_error = 1;
397
+ static const int JSON_value_en_main = 1;
398
398
 
399
399
  #line 167 "parser.rl"
400
400
 
@@ -416,47 +416,29 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
416
416
  goto _out;
417
417
  switch ( cs )
418
418
  {
419
- case 0:
419
+ case 1:
420
420
  switch( (*p) ) {
421
- case 34: goto tr9;
422
- case 45: goto tr10;
423
- case 91: goto tr11;
421
+ case 34: goto tr0;
422
+ case 45: goto tr2;
423
+ case 91: goto tr3;
424
424
  case 102: goto st2;
425
425
  case 110: goto st6;
426
426
  case 116: goto st9;
427
- case 123: goto tr15;
427
+ case 123: goto tr7;
428
428
  }
429
429
  if ( 48 <= (*p) && (*p) <= 57 )
430
- goto tr10;
431
- goto st1;
432
- st1:
433
- goto _out1;
434
- tr5:
435
- #line 123 "parser.rl"
436
- {
437
- *result = Qnil;
438
- }
439
- goto st12;
440
- tr6:
441
- #line 126 "parser.rl"
442
- {
443
- *result = Qfalse;
444
- }
445
- goto st12;
446
- tr7:
447
- #line 129 "parser.rl"
448
- {
449
- *result = Qtrue;
450
- }
451
- goto st12;
452
- tr9:
430
+ goto tr2;
431
+ goto st0;
432
+ st0:
433
+ goto _out0;
434
+ tr0:
453
435
  #line 132 "parser.rl"
454
436
  {
455
437
  char *np = JSON_parse_string(json, p, pe, result);
456
438
  if (np == NULL) goto _out12; else {p = (( np))-1;}
457
439
  }
458
440
  goto st12;
459
- tr10:
441
+ tr2:
460
442
  #line 137 "parser.rl"
461
443
  {
462
444
  char *np;
@@ -467,20 +449,38 @@ tr10:
467
449
  goto _out12;
468
450
  }
469
451
  goto st12;
470
- tr11:
452
+ tr3:
471
453
  #line 146 "parser.rl"
472
454
  {
473
455
  char *np = JSON_parse_array(json, p, pe, result);
474
456
  if (np == NULL) goto _out12; else {p = (( np))-1;}
475
457
  }
476
458
  goto st12;
477
- tr15:
459
+ tr7:
478
460
  #line 151 "parser.rl"
479
461
  {
480
462
  char *np = JSON_parse_object(json, p, pe, result);
481
463
  if (np == NULL) goto _out12; else {p = (( np))-1;}
482
464
  }
483
465
  goto st12;
466
+ tr11:
467
+ #line 126 "parser.rl"
468
+ {
469
+ *result = Qfalse;
470
+ }
471
+ goto st12;
472
+ tr14:
473
+ #line 123 "parser.rl"
474
+ {
475
+ *result = Qnil;
476
+ }
477
+ goto st12;
478
+ tr17:
479
+ #line 129 "parser.rl"
480
+ {
481
+ *result = Qtrue;
482
+ }
483
+ goto st12;
484
484
  st12:
485
485
  if ( ++p == pe )
486
486
  goto _out12;
@@ -488,79 +488,79 @@ case 12:
488
488
  #line 156 "parser.rl"
489
489
  { goto _out12; }
490
490
  #line 491 "parser.c"
491
- goto st1;
491
+ goto st0;
492
492
  st2:
493
493
  if ( ++p == pe )
494
494
  goto _out2;
495
495
  case 2:
496
496
  if ( (*p) == 97 )
497
497
  goto st3;
498
- goto st1;
498
+ goto st0;
499
499
  st3:
500
500
  if ( ++p == pe )
501
501
  goto _out3;
502
502
  case 3:
503
503
  if ( (*p) == 108 )
504
504
  goto st4;
505
- goto st1;
505
+ goto st0;
506
506
  st4:
507
507
  if ( ++p == pe )
508
508
  goto _out4;
509
509
  case 4:
510
510
  if ( (*p) == 115 )
511
511
  goto st5;
512
- goto st1;
512
+ goto st0;
513
513
  st5:
514
514
  if ( ++p == pe )
515
515
  goto _out5;
516
516
  case 5:
517
517
  if ( (*p) == 101 )
518
- goto tr6;
519
- goto st1;
518
+ goto tr11;
519
+ goto st0;
520
520
  st6:
521
521
  if ( ++p == pe )
522
522
  goto _out6;
523
523
  case 6:
524
524
  if ( (*p) == 117 )
525
525
  goto st7;
526
- goto st1;
526
+ goto st0;
527
527
  st7:
528
528
  if ( ++p == pe )
529
529
  goto _out7;
530
530
  case 7:
531
531
  if ( (*p) == 108 )
532
532
  goto st8;
533
- goto st1;
533
+ goto st0;
534
534
  st8:
535
535
  if ( ++p == pe )
536
536
  goto _out8;
537
537
  case 8:
538
538
  if ( (*p) == 108 )
539
- goto tr5;
540
- goto st1;
539
+ goto tr14;
540
+ goto st0;
541
541
  st9:
542
542
  if ( ++p == pe )
543
543
  goto _out9;
544
544
  case 9:
545
545
  if ( (*p) == 114 )
546
546
  goto st10;
547
- goto st1;
547
+ goto st0;
548
548
  st10:
549
549
  if ( ++p == pe )
550
550
  goto _out10;
551
551
  case 10:
552
552
  if ( (*p) == 117 )
553
553
  goto st11;
554
- goto st1;
554
+ goto st0;
555
555
  st11:
556
556
  if ( ++p == pe )
557
557
  goto _out11;
558
558
  case 11:
559
559
  if ( (*p) == 101 )
560
- goto tr7;
561
- goto st1;
560
+ goto tr17;
561
+ goto st0;
562
562
  }
563
- _out1: cs = 1; goto _out;
563
+ _out0: cs = 0; goto _out;
564
564
  _out12: cs = 12; goto _out;
565
565
  _out2: cs = 2; goto _out;
566
566
  _out3: cs = 3; goto _out;
@@ -586,11 +586,11 @@ case 11:
586
586
 
587
587
 
588
588
  #line 589 "parser.c"
589
- static const int JSON_integer_start = 0;
590
-
589
+ static const int JSON_integer_start = 1;
591
590
  static const int JSON_integer_first_final = 5;
591
+ static const int JSON_integer_error = 0;
592
592
 
593
- static const int JSON_integer_error = 1;
593
+ static const int JSON_integer_en_main = 1;
594
594
 
595
595
  #line 191 "parser.rl"
596
596
 
@@ -613,16 +613,16 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
613
613
  goto _out;
614
614
  switch ( cs )
615
615
  {
616
- case 0:
616
+ case 1:
617
617
  switch( (*p) ) {
618
618
  case 45: goto st2;
619
619
  case 48: goto st3;
620
620
  }
621
621
  if ( 49 <= (*p) && (*p) <= 57 )
622
622
  goto st4;
623
- goto st1;
624
- st1:
625
- goto _out1;
623
+ goto st0;
624
+ st0:
625
+ goto _out0;
626
626
  st2:
627
627
  if ( ++p == pe )
628
628
  goto _out2;
@@ -631,13 +631,13 @@ case 2:
631
631
  goto st3;
632
632
  if ( 49 <= (*p) && (*p) <= 57 )
633
633
  goto st4;
634
- goto st1;
634
+ goto st0;
635
635
  st3:
636
636
  if ( ++p == pe )
637
637
  goto _out3;
638
638
  case 3:
639
639
  if ( 48 <= (*p) && (*p) <= 57 )
640
- goto st1;
640
+ goto st0;
641
641
  goto tr4;
642
642
  tr4:
643
643
  #line 188 "parser.rl"
@@ -648,7 +648,7 @@ st5:
648
648
  goto _out5;
649
649
  case 5:
650
650
  #line 651 "parser.c"
651
- goto st1;
651
+ goto st0;
652
652
  st4:
653
653
  if ( ++p == pe )
654
654
  goto _out4;
@@ -657,7 +657,7 @@ case 4:
657
657
  goto st4;
658
658
  goto tr4;
659
659
  }
660
- _out1: cs = 1; goto _out;
660
+ _out0: cs = 0; goto _out;
661
661
  _out2: cs = 2; goto _out;
662
662
  _out3: cs = 3; goto _out;
663
663
  _out5: cs = 5; goto _out;
@@ -678,11 +678,11 @@ case 4:
678
678
 
679
679
 
680
680
  #line 681 "parser.c"
681
- static const int JSON_float_start = 0;
682
-
681
+ static const int JSON_float_start = 1;
683
682
  static const int JSON_float_first_final = 10;
683
+ static const int JSON_float_error = 0;
684
684
 
685
- static const int JSON_float_error = 1;
685
+ static const int JSON_float_en_main = 1;
686
686
 
687
687
  #line 222 "parser.rl"
688
688
 
@@ -705,16 +705,16 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
705
705
  goto _out;
706
706
  switch ( cs )
707
707
  {
708
- case 0:
708
+ case 1:
709
709
  switch( (*p) ) {
710
710
  case 45: goto st2;
711
711
  case 48: goto st3;
712
712
  }
713
713
  if ( 49 <= (*p) && (*p) <= 57 )
714
714
  goto st9;
715
- goto st1;
716
- st1:
717
- goto _out1;
715
+ goto st0;
716
+ st0:
717
+ goto _out0;
718
718
  st2:
719
719
  if ( ++p == pe )
720
720
  goto _out2;
@@ -723,21 +723,24 @@ case 2:
723
723
  goto st3;
724
724
  if ( 49 <= (*p) && (*p) <= 57 )
725
725
  goto st9;
726
- goto st1;
726
+ goto st0;
727
727
  st3:
728
728
  if ( ++p == pe )
729
729
  goto _out3;
730
730
  case 3:
731
- if ( (*p) == 46 )
732
- goto st4;
733
- goto st1;
731
+ switch( (*p) ) {
732
+ case 46: goto st4;
733
+ case 69: goto st6;
734
+ case 101: goto st6;
735
+ }
736
+ goto st0;
734
737
  st4:
735
738
  if ( ++p == pe )
736
739
  goto _out4;
737
740
  case 4:
738
741
  if ( 48 <= (*p) && (*p) <= 57 )
739
742
  goto st5;
740
- goto st1;
743
+ goto st0;
741
744
  st5:
742
745
  if ( ++p == pe )
743
746
  goto _out5;
@@ -750,9 +753,9 @@ case 5:
750
753
  if ( 48 <= (*p) && (*p) <= 57 )
751
754
  goto st5;
752
755
  } else if ( (*p) >= 45 )
753
- goto st1;
754
- goto tr8;
755
- tr8:
756
+ goto st0;
757
+ goto tr7;
758
+ tr7:
756
759
  #line 216 "parser.rl"
757
760
  { goto _out10; }
758
761
  goto st10;
@@ -760,8 +763,8 @@ st10:
760
763
  if ( ++p == pe )
761
764
  goto _out10;
762
765
  case 10:
763
- #line 764 "parser.c"
764
- goto st1;
766
+ #line 767 "parser.c"
767
+ goto st0;
765
768
  st6:
766
769
  if ( ++p == pe )
767
770
  goto _out6;
@@ -772,28 +775,28 @@ case 6:
772
775
  }
773
776
  if ( 48 <= (*p) && (*p) <= 57 )
774
777
  goto st8;
775
- goto st1;
778
+ goto st0;
776
779
  st7:
777
780
  if ( ++p == pe )
778
781
  goto _out7;
779
782
  case 7:
780
783
  if ( 48 <= (*p) && (*p) <= 57 )
781
784
  goto st8;
782
- goto st1;
785
+ goto st0;
783
786
  st8:
784
787
  if ( ++p == pe )
785
788
  goto _out8;
786
789
  case 8:
787
790
  switch( (*p) ) {
788
- case 69: goto st1;
789
- case 101: goto st1;
791
+ case 69: goto st0;
792
+ case 101: goto st0;
790
793
  }
791
794
  if ( (*p) > 46 ) {
792
795
  if ( 48 <= (*p) && (*p) <= 57 )
793
796
  goto st8;
794
797
  } else if ( (*p) >= 45 )
795
- goto st1;
796
- goto tr8;
798
+ goto st0;
799
+ goto tr7;
797
800
  st9:
798
801
  if ( ++p == pe )
799
802
  goto _out9;
@@ -805,9 +808,9 @@ case 9:
805
808
  }
806
809
  if ( 48 <= (*p) && (*p) <= 57 )
807
810
  goto st9;
808
- goto st1;
811
+ goto st0;
809
812
  }
810
- _out1: cs = 1; goto _out;
813
+ _out0: cs = 0; goto _out;
811
814
  _out2: cs = 2; goto _out;
812
815
  _out3: cs = 3; goto _out;
813
816
  _out4: cs = 4; goto _out;
@@ -833,12 +836,12 @@ case 9:
833
836
 
834
837
 
835
838
 
836
- #line 837 "parser.c"
837
- static const int JSON_array_start = 0;
838
-
839
+ #line 840 "parser.c"
840
+ static const int JSON_array_start = 1;
839
841
  static const int JSON_array_first_final = 17;
842
+ static const int JSON_array_error = 0;
840
843
 
841
- static const int JSON_array_error = 1;
844
+ static const int JSON_array_en_main = 1;
842
845
 
843
846
  #line 267 "parser.rl"
844
847
 
@@ -849,24 +852,24 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
849
852
  *result = rb_ary_new();
850
853
 
851
854
 
852
- #line 853 "parser.c"
855
+ #line 856 "parser.c"
853
856
  {
854
857
  cs = JSON_array_start;
855
858
  }
856
859
  #line 275 "parser.rl"
857
860
 
858
- #line 859 "parser.c"
861
+ #line 862 "parser.c"
859
862
  {
860
863
  if ( p == pe )
861
864
  goto _out;
862
865
  switch ( cs )
863
866
  {
864
- case 0:
867
+ case 1:
865
868
  if ( (*p) == 91 )
866
869
  goto st2;
867
- goto st1;
868
- st1:
869
- goto _out1;
870
+ goto st0;
871
+ st0:
872
+ goto _out0;
870
873
  st2:
871
874
  if ( ++p == pe )
872
875
  goto _out2;
@@ -874,23 +877,23 @@ case 2:
874
877
  switch( (*p) ) {
875
878
  case 13: goto st2;
876
879
  case 32: goto st2;
877
- case 34: goto tr8;
878
- case 45: goto tr8;
880
+ case 34: goto tr2;
881
+ case 45: goto tr2;
879
882
  case 47: goto st13;
880
- case 91: goto tr8;
881
- case 93: goto tr7;
882
- case 102: goto tr8;
883
- case 110: goto tr8;
884
- case 116: goto tr8;
885
- case 123: goto tr8;
883
+ case 91: goto tr2;
884
+ case 93: goto tr4;
885
+ case 102: goto tr2;
886
+ case 110: goto tr2;
887
+ case 116: goto tr2;
888
+ case 123: goto tr2;
886
889
  }
887
890
  if ( (*p) > 10 ) {
888
891
  if ( 48 <= (*p) && (*p) <= 57 )
889
- goto tr8;
892
+ goto tr2;
890
893
  } else if ( (*p) >= 9 )
891
894
  goto st2;
892
- goto st1;
893
- tr8:
895
+ goto st0;
896
+ tr2:
894
897
  #line 248 "parser.rl"
895
898
  {
896
899
  VALUE v = Qnil;
@@ -907,17 +910,17 @@ st3:
907
910
  if ( ++p == pe )
908
911
  goto _out3;
909
912
  case 3:
910
- #line 911 "parser.c"
913
+ #line 914 "parser.c"
911
914
  switch( (*p) ) {
912
915
  case 13: goto st3;
913
916
  case 32: goto st3;
914
917
  case 44: goto st4;
915
918
  case 47: goto st9;
916
- case 93: goto tr7;
919
+ case 93: goto tr4;
917
920
  }
918
921
  if ( 9 <= (*p) && (*p) <= 10 )
919
922
  goto st3;
920
- goto st1;
923
+ goto st0;
921
924
  st4:
922
925
  if ( ++p == pe )
923
926
  goto _out4;
@@ -925,21 +928,21 @@ case 4:
925
928
  switch( (*p) ) {
926
929
  case 13: goto st4;
927
930
  case 32: goto st4;
928
- case 34: goto tr8;
929
- case 45: goto tr8;
931
+ case 34: goto tr2;
932
+ case 45: goto tr2;
930
933
  case 47: goto st5;
931
- case 91: goto tr8;
932
- case 102: goto tr8;
933
- case 110: goto tr8;
934
- case 116: goto tr8;
935
- case 123: goto tr8;
934
+ case 91: goto tr2;
935
+ case 102: goto tr2;
936
+ case 110: goto tr2;
937
+ case 116: goto tr2;
938
+ case 123: goto tr2;
936
939
  }
937
940
  if ( (*p) > 10 ) {
938
941
  if ( 48 <= (*p) && (*p) <= 57 )
939
- goto tr8;
942
+ goto tr2;
940
943
  } else if ( (*p) >= 9 )
941
944
  goto st4;
942
- goto st1;
945
+ goto st0;
943
946
  st5:
944
947
  if ( ++p == pe )
945
948
  goto _out5;
@@ -948,7 +951,7 @@ case 5:
948
951
  case 42: goto st6;
949
952
  case 47: goto st8;
950
953
  }
951
- goto st1;
954
+ goto st0;
952
955
  st6:
953
956
  if ( ++p == pe )
954
957
  goto _out6;
@@ -980,7 +983,7 @@ case 9:
980
983
  case 42: goto st10;
981
984
  case 47: goto st12;
982
985
  }
983
- goto st1;
986
+ goto st0;
984
987
  st10:
985
988
  if ( ++p == pe )
986
989
  goto _out10;
@@ -1004,7 +1007,7 @@ case 12:
1004
1007
  if ( (*p) == 10 )
1005
1008
  goto st3;
1006
1009
  goto st12;
1007
- tr7:
1010
+ tr4:
1008
1011
  #line 259 "parser.rl"
1009
1012
  { goto _out17; }
1010
1013
  goto st17;
@@ -1012,8 +1015,8 @@ st17:
1012
1015
  if ( ++p == pe )
1013
1016
  goto _out17;
1014
1017
  case 17:
1015
- #line 1016 "parser.c"
1016
- goto st1;
1018
+ #line 1019 "parser.c"
1019
+ goto st0;
1017
1020
  st13:
1018
1021
  if ( ++p == pe )
1019
1022
  goto _out13;
@@ -1022,7 +1025,7 @@ case 13:
1022
1025
  case 42: goto st14;
1023
1026
  case 47: goto st16;
1024
1027
  }
1025
- goto st1;
1028
+ goto st0;
1026
1029
  st14:
1027
1030
  if ( ++p == pe )
1028
1031
  goto _out14;
@@ -1047,7 +1050,7 @@ case 16:
1047
1050
  goto st2;
1048
1051
  goto st16;
1049
1052
  }
1050
- _out1: cs = 1; goto _out;
1053
+ _out0: cs = 0; goto _out;
1051
1054
  _out2: cs = 2; goto _out;
1052
1055
  _out3: cs = 3; goto _out;
1053
1056
  _out4: cs = 4; goto _out;
@@ -1129,12 +1132,12 @@ static VALUE json_string_escape(char *p, char *pe)
1129
1132
  }
1130
1133
 
1131
1134
 
1132
- #line 1133 "parser.c"
1133
- static const int JSON_string_start = 0;
1134
-
1135
+ #line 1136 "parser.c"
1136
+ static const int JSON_string_start = 1;
1135
1137
  static const int JSON_string_first_final = 8;
1138
+ static const int JSON_string_error = 0;
1136
1139
 
1137
- static const int JSON_string_error = 1;
1140
+ static const int JSON_string_en_main = 1;
1138
1141
 
1139
1142
  #line 350 "parser.rl"
1140
1143
 
@@ -1145,37 +1148,37 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
1145
1148
 
1146
1149
  *result = rb_str_new("", 0);
1147
1150
 
1148
- #line 1149 "parser.c"
1151
+ #line 1152 "parser.c"
1149
1152
  {
1150
1153
  cs = JSON_string_start;
1151
1154
  }
1152
1155
  #line 358 "parser.rl"
1153
1156
  json->memo = p;
1154
1157
 
1155
- #line 1156 "parser.c"
1158
+ #line 1159 "parser.c"
1156
1159
  {
1157
1160
  if ( p == pe )
1158
1161
  goto _out;
1159
1162
  switch ( cs )
1160
1163
  {
1161
- case 0:
1164
+ case 1:
1162
1165
  if ( (*p) == 34 )
1163
1166
  goto st2;
1164
- goto st1;
1165
- st1:
1166
- goto _out1;
1167
+ goto st0;
1168
+ st0:
1169
+ goto _out0;
1167
1170
  st2:
1168
1171
  if ( ++p == pe )
1169
1172
  goto _out2;
1170
1173
  case 2:
1171
1174
  switch( (*p) ) {
1172
- case 34: goto tr4;
1175
+ case 34: goto tr2;
1173
1176
  case 92: goto st3;
1174
1177
  }
1175
1178
  if ( 0 <= (*p) && (*p) <= 31 )
1176
- goto st1;
1179
+ goto st0;
1177
1180
  goto st2;
1178
- tr4:
1181
+ tr2:
1179
1182
  #line 342 "parser.rl"
1180
1183
  {
1181
1184
  *result = json_string_escape(json->memo + 1, p);
@@ -1188,8 +1191,8 @@ st8:
1188
1191
  if ( ++p == pe )
1189
1192
  goto _out8;
1190
1193
  case 8:
1191
- #line 1192 "parser.c"
1192
- goto st1;
1194
+ #line 1195 "parser.c"
1195
+ goto st0;
1193
1196
  st3:
1194
1197
  if ( ++p == pe )
1195
1198
  goto _out3;
@@ -1205,7 +1208,7 @@ case 3:
1205
1208
  case 116: goto st2;
1206
1209
  case 117: goto st4;
1207
1210
  }
1208
- goto st1;
1211
+ goto st0;
1209
1212
  st4:
1210
1213
  if ( ++p == pe )
1211
1214
  goto _out4;
@@ -1218,7 +1221,7 @@ case 4:
1218
1221
  goto st5;
1219
1222
  } else
1220
1223
  goto st5;
1221
- goto st1;
1224
+ goto st0;
1222
1225
  st5:
1223
1226
  if ( ++p == pe )
1224
1227
  goto _out5;
@@ -1231,7 +1234,7 @@ case 5:
1231
1234
  goto st6;
1232
1235
  } else
1233
1236
  goto st6;
1234
- goto st1;
1237
+ goto st0;
1235
1238
  st6:
1236
1239
  if ( ++p == pe )
1237
1240
  goto _out6;
@@ -1244,7 +1247,7 @@ case 6:
1244
1247
  goto st7;
1245
1248
  } else
1246
1249
  goto st7;
1247
- goto st1;
1250
+ goto st0;
1248
1251
  st7:
1249
1252
  if ( ++p == pe )
1250
1253
  goto _out7;
@@ -1257,9 +1260,9 @@ case 7:
1257
1260
  goto st2;
1258
1261
  } else
1259
1262
  goto st2;
1260
- goto st1;
1263
+ goto st0;
1261
1264
  }
1262
- _out1: cs = 1; goto _out;
1265
+ _out0: cs = 0; goto _out;
1263
1266
  _out2: cs = 2; goto _out;
1264
1267
  _out8: cs = 8; goto _out;
1265
1268
  _out3: cs = 3; goto _out;
@@ -1281,12 +1284,12 @@ case 7:
1281
1284
 
1282
1285
 
1283
1286
 
1284
- #line 1285 "parser.c"
1285
- static const int JSON_start = 0;
1286
-
1287
+ #line 1288 "parser.c"
1288
+ static const int JSON_start = 1;
1287
1289
  static const int JSON_first_final = 10;
1290
+ static const int JSON_error = 0;
1288
1291
 
1289
- static const int JSON_error = 1;
1292
+ static const int JSON_en_main = 1;
1290
1293
 
1291
1294
  #line 390 "parser.rl"
1292
1295
 
@@ -1352,7 +1355,7 @@ static VALUE cParser_parse(VALUE self)
1352
1355
  VALUE result = Qnil;
1353
1356
 
1354
1357
 
1355
- #line 1356 "parser.c"
1358
+ #line 1359 "parser.c"
1356
1359
  {
1357
1360
  cs = JSON_start;
1358
1361
  }
@@ -1360,28 +1363,28 @@ static VALUE cParser_parse(VALUE self)
1360
1363
  p = json->source;
1361
1364
  pe = p + json->len;
1362
1365
 
1363
- #line 1364 "parser.c"
1366
+ #line 1367 "parser.c"
1364
1367
  {
1365
1368
  if ( p == pe )
1366
1369
  goto _out;
1367
1370
  switch ( cs )
1368
1371
  {
1369
- st0:
1372
+ st1:
1370
1373
  if ( ++p == pe )
1371
- goto _out0;
1372
- case 0:
1374
+ goto _out1;
1375
+ case 1:
1373
1376
  switch( (*p) ) {
1374
- case 13: goto st0;
1375
- case 32: goto st0;
1377
+ case 13: goto st1;
1378
+ case 32: goto st1;
1376
1379
  case 47: goto st2;
1377
- case 91: goto tr7;
1378
- case 123: goto tr8;
1380
+ case 91: goto tr3;
1381
+ case 123: goto tr4;
1379
1382
  }
1380
1383
  if ( 9 <= (*p) && (*p) <= 10 )
1381
- goto st0;
1382
- goto st1;
1383
- st1:
1384
- goto _out1;
1384
+ goto st1;
1385
+ goto st0;
1386
+ st0:
1387
+ goto _out0;
1385
1388
  st2:
1386
1389
  if ( ++p == pe )
1387
1390
  goto _out2;
@@ -1390,7 +1393,7 @@ case 2:
1390
1393
  case 42: goto st3;
1391
1394
  case 47: goto st5;
1392
1395
  }
1393
- goto st1;
1396
+ goto st0;
1394
1397
  st3:
1395
1398
  if ( ++p == pe )
1396
1399
  goto _out3;
@@ -1404,7 +1407,7 @@ st4:
1404
1407
  case 4:
1405
1408
  switch( (*p) ) {
1406
1409
  case 42: goto st4;
1407
- case 47: goto st0;
1410
+ case 47: goto st1;
1408
1411
  }
1409
1412
  goto st3;
1410
1413
  st5:
@@ -1412,16 +1415,16 @@ st5:
1412
1415
  goto _out5;
1413
1416
  case 5:
1414
1417
  if ( (*p) == 10 )
1415
- goto st0;
1418
+ goto st1;
1416
1419
  goto st5;
1417
- tr7:
1420
+ tr3:
1418
1421
  #line 381 "parser.rl"
1419
1422
  {
1420
1423
  char *np = JSON_parse_array(json, p, pe, &result);
1421
1424
  if (np == NULL) goto _out10; else {p = (( np))-1;}
1422
1425
  }
1423
1426
  goto st10;
1424
- tr8:
1427
+ tr4:
1425
1428
  #line 376 "parser.rl"
1426
1429
  {
1427
1430
  char *np = JSON_parse_object(json, p, pe, &result);
@@ -1432,7 +1435,7 @@ st10:
1432
1435
  if ( ++p == pe )
1433
1436
  goto _out10;
1434
1437
  case 10:
1435
- #line 1436 "parser.c"
1438
+ #line 1439 "parser.c"
1436
1439
  switch( (*p) ) {
1437
1440
  case 13: goto st10;
1438
1441
  case 32: goto st10;
@@ -1440,7 +1443,7 @@ case 10:
1440
1443
  }
1441
1444
  if ( 9 <= (*p) && (*p) <= 10 )
1442
1445
  goto st10;
1443
- goto st1;
1446
+ goto st0;
1444
1447
  st6:
1445
1448
  if ( ++p == pe )
1446
1449
  goto _out6;
@@ -1449,7 +1452,7 @@ case 6:
1449
1452
  case 42: goto st7;
1450
1453
  case 47: goto st9;
1451
1454
  }
1452
- goto st1;
1455
+ goto st0;
1453
1456
  st7:
1454
1457
  if ( ++p == pe )
1455
1458
  goto _out7;
@@ -1474,8 +1477,8 @@ case 9:
1474
1477
  goto st10;
1475
1478
  goto st9;
1476
1479
  }
1477
- _out0: cs = 0; goto _out;
1478
1480
  _out1: cs = 1; goto _out;
1481
+ _out0: cs = 0; goto _out;
1479
1482
  _out2: cs = 2; goto _out;
1480
1483
  _out3: cs = 3; goto _out;
1481
1484
  _out4: cs = 4; goto _out;
@@ -217,7 +217,7 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
217
217
 
218
218
  main := '-'? (
219
219
  (('0' | [1-9][0-9]*) '.' [0-9]+ ([Ee] [+\-]?[0-9]+)?)
220
- | ([1-9][0-9]* ([Ee] [+\-]?[0-9]+))
220
+ | (('0' | [1-9][0-9]*) ([Ee] [+\-]?[0-9]+))
221
221
  ) (^[0-9Ee.\-] @exit );
222
222
  }%%
223
223
 
data/lib/json/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/tests/test_json.rb CHANGED
@@ -48,6 +48,7 @@ class TC_JSON < Test::Unit::TestCase
48
48
  assert_equal([-23], parse('[-23]'))
49
49
  assert_equal([23], parse('[23]'))
50
50
  assert_equal([0.23], parse('[0.23]'))
51
+ assert_equal([0.0], parse('[0e0]'))
51
52
  assert_raises(JSON::ParserError) { parse('[+23.2]') }
52
53
  assert_raises(JSON::ParserError) { parse('[+23]') }
53
54
  assert_raises(JSON::ParserError) { parse('[.23]') }
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: json_pure
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.1
7
- date: 2007-03-27 00:00:00 +02:00
6
+ version: 1.0.2
7
+ date: 2007-04-02 00:00:00 +02:00
8
8
  summary: A JSON implementation in Ruby
9
9
  require_paths:
10
10
  - lib
@@ -29,101 +29,102 @@ post_install_message:
29
29
  authors:
30
30
  - Florian Frank
31
31
  files:
32
- - bin
33
- - VERSION
34
- - TODO
35
- - tests
36
- - GPL
37
- - install.rb
38
32
  - ext
33
+ - tools
34
+ - tests
35
+ - lib
39
36
  - diagrams
37
+ - bin
38
+ - data
40
39
  - benchmarks
40
+ - GPL
41
41
  - Rakefile
42
- - data
43
- - lib
44
- - README
45
- - tools
42
+ - TODO
43
+ - VERSION
46
44
  - CHANGES
47
- - bin/edit_json.rb
48
- - tests/test_json_fixtures.rb
49
- - tests/runner.rb
50
- - tests/test_json.rb
45
+ - install.rb
46
+ - README
47
+ - ext/json
48
+ - ext/json/ext
49
+ - ext/json/ext/generator
50
+ - ext/json/ext/parser
51
+ - ext/json/ext/generator/generator.c
52
+ - ext/json/ext/generator/unicode.c
53
+ - ext/json/ext/generator/extconf.rb
54
+ - ext/json/ext/generator/unicode.h
55
+ - ext/json/ext/parser/unicode.c
56
+ - ext/json/ext/parser/extconf.rb
57
+ - ext/json/ext/parser/parser.rl
58
+ - ext/json/ext/parser/unicode.h
59
+ - ext/json/ext/parser/parser.c
60
+ - tools/fuzz.rb
61
+ - tools/server.rb
51
62
  - tests/fixtures
52
63
  - tests/test_json_unicode.rb
64
+ - tests/test_json_fixtures.rb
53
65
  - tests/test_json_generate.rb
54
66
  - tests/test_json_addition.rb
55
- - tests/fixtures/fail27.json
56
- - tests/fixtures/fail22.json
57
- - tests/fixtures/fail26.json
58
- - tests/fixtures/fail16.json
59
- - tests/fixtures/fail28.json
60
- - tests/fixtures/fail25.json
61
- - tests/fixtures/pass18.json
62
- - tests/fixtures/fail9.json
63
- - tests/fixtures/fail20.json
64
- - tests/fixtures/fail24.json
65
- - tests/fixtures/fail14.json
66
- - tests/fixtures/fail4.json
67
- - tests/fixtures/fail7.json
67
+ - tests/test_json.rb
68
+ - tests/runner.rb
68
69
  - tests/fixtures/fail10.json
69
- - tests/fixtures/fail13.json
70
- - tests/fixtures/fail6.json
71
- - tests/fixtures/fail21.json
72
- - tests/fixtures/fail23.json
73
- - tests/fixtures/fail3.json
74
- - tests/fixtures/fail1.json
70
+ - tests/fixtures/fail20.json
75
71
  - tests/fixtures/fail11.json
76
- - tests/fixtures/fail5.json
77
- - tests/fixtures/pass1.json
72
+ - tests/fixtures/fail21.json
78
73
  - tests/fixtures/fail12.json
74
+ - tests/fixtures/fail22.json
75
+ - tests/fixtures/fail13.json
76
+ - tests/fixtures/pass18.json
77
+ - tests/fixtures/fail23.json
78
+ - tests/fixtures/fail14.json
79
+ - tests/fixtures/fail24.json
79
80
  - tests/fixtures/fail15.json
80
- - tests/fixtures/pass3.json
81
- - tests/fixtures/fail8.json
81
+ - tests/fixtures/fail16.json
82
+ - tests/fixtures/fail25.json
82
83
  - tests/fixtures/fail17.json
84
+ - tests/fixtures/fail26.json
85
+ - tests/fixtures/fail27.json
83
86
  - tests/fixtures/fail19.json
87
+ - tests/fixtures/fail28.json
88
+ - tests/fixtures/pass1.json
84
89
  - tests/fixtures/pass2.json
90
+ - tests/fixtures/pass3.json
91
+ - tests/fixtures/fail1.json
85
92
  - tests/fixtures/fail2.json
86
- - ext/json
87
- - ext/json/ext
88
- - ext/json/ext/generator
89
- - ext/json/ext/parser
90
- - ext/json/ext/generator/unicode.c
91
- - ext/json/ext/generator/unicode.h
92
- - ext/json/ext/generator/extconf.rb
93
- - ext/json/ext/generator/generator.c
94
- - ext/json/ext/parser/parser.c
95
- - ext/json/ext/parser/unicode.c
96
- - ext/json/ext/parser/parser.rl
97
- - ext/json/ext/parser/unicode.h
98
- - ext/json/ext/parser/extconf.rb
99
- - benchmarks/benchmark_generator.rb
100
- - benchmarks/benchmark.txt
101
- - benchmarks/benchmark_parser.rb
102
- - benchmarks/benchmark_rails.rb
103
- - data/example.json
104
- - data/prototype.js
105
- - data/index.html
93
+ - tests/fixtures/fail3.json
94
+ - tests/fixtures/fail4.json
95
+ - tests/fixtures/fail5.json
96
+ - tests/fixtures/fail6.json
97
+ - tests/fixtures/fail7.json
98
+ - tests/fixtures/fail8.json
99
+ - tests/fixtures/fail9.json
106
100
  - lib/json
107
101
  - lib/json.rb
108
- - lib/json/FalseClass.xpm
109
- - lib/json/TrueClass.xpm
110
- - lib/json/ext.rb
111
- - lib/json/common.rb
112
- - lib/json/Hash.xpm
113
102
  - lib/json/pure
114
- - lib/json/Key.xpm
115
- - lib/json/Numeric.xpm
116
103
  - lib/json/Array.xpm
104
+ - lib/json/ext.rb
105
+ - lib/json/FalseClass.xpm
106
+ - lib/json/Numeric.xpm
107
+ - lib/json/Hash.xpm
108
+ - lib/json/version.rb
109
+ - lib/json/TrueClass.xpm
117
110
  - lib/json/editor.rb
118
111
  - lib/json/String.xpm
119
- - lib/json/pure.rb
112
+ - lib/json/common.rb
113
+ - lib/json/Key.xpm
120
114
  - lib/json/NilClass.xpm
121
- - lib/json/version.rb
122
115
  - lib/json/json.xpm
123
- - lib/json/pure/parser.rb
116
+ - lib/json/pure.rb
124
117
  - lib/json/pure/generator.rb
125
- - tools/server.rb
126
- - tools/fuzz.rb
118
+ - lib/json/pure/parser.rb
119
+ - bin/edit_json.rb
120
+ - bin/prettify_json.rb
121
+ - data/prototype.js
122
+ - data/example.json
123
+ - data/index.html
124
+ - benchmarks/benchmark_generator.rb
125
+ - benchmarks/benchmark_rails.rb
126
+ - benchmarks/benchmark.txt
127
+ - benchmarks/benchmark_parser.rb
127
128
  test_files:
128
129
  - tests/runner.rb
129
130
  rdoc_options: