edn_turbo 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 695a3c68e9f69b9423a4da07056dfd8f264f62b39896c938938e56d1e28c395f
4
- data.tar.gz: a370c5b31f462288fd340771c901d47f27e45e2308ef98728cb6abe59596631a
3
+ metadata.gz: 873b791ab9878f7b9bd616689fbfbef2eacb3fd1d6d8ede55a71f182fcf3b9f4
4
+ data.tar.gz: a6ff013825a135846e1e3988e17a86d58ca0dd244fcde0a9b73f3eb22218e8cb
5
5
  SHA512:
6
- metadata.gz: 9b9b5aeb7c5b62d4add2ff2faa190138cf1baf0e902bdf3a28468c382ef0e94f6c95f93e3e05c48d7deb31e708d92f41607da60183b510593aa741eb68817be5
7
- data.tar.gz: 39fb3b6b18cf3593fd537843aa2a08089552cb8900691ca88e3d8a86d05706e5f5ef557c8f3521c0b68b812652d1770f5f3a4621ca30087fa06299266a330352
6
+ metadata.gz: aa606e1bc5da4be831d70052415f3c217343e334390de2e72bb141dd18986f6ef3379c03c6f1adec2de86af65951bf2902dc3fcb09fae29874ad448323a7361d
7
+ data.tar.gz: 0cf810e71d6a3a3d2cabc798bed067d0826512149ef503d4f2940816e1f3cc15e71d9cffef5eb504b44efa70f597f274decc5147be878c515c3624f5a558854f
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
3
3
 
4
+ ## 0.6.2 - 2019-05-21
5
+ ### Fixed
6
+ - Handling of ##Inf, ##Nan, et al.
7
+
4
8
  ## 0.6.1 - 2019-05-20
5
9
  ### Added
6
10
  - Implement parsing of Ratio literals, represented as a ruby Rational.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- edn_turbo 0.6.1
1
+ edn_turbo 0.6.2
2
2
  ===============
3
3
 
4
4
  Fast [Ragel](http://www.colm.net/open-source/ragel/)-based EDN parser for Ruby.
@@ -103,6 +103,12 @@ Or instantiate and reuse an instance of a parser:
103
103
 
104
104
  Differences with edn gem
105
105
  ========================
106
- `edn_turbo` reads `String` and core IO types using C-api calls.
106
+ - `edn_turbo` reads `String` and core IO types using C-api calls.
107
107
  However, data from `StringIO` sources is extracted using `read()`
108
108
  calls into the ruby side.
109
+
110
+ - As of v0.6.1, `edn_turbo` supports EDN ratio literals, returning a
111
+ ruby Rational representation for them. See https://github.com/edn-format/edn/issues/64.
112
+
113
+ - As of v0.6.2, `edn_turbo` supports representation of `##Inf` as
114
+ `Float::INFINITY` and `##NaN` as `Float::NAN`.
@@ -2727,8 +2727,6 @@ case 3:
2727
2727
  #line 753 "edn_parser.rl"
2728
2728
 
2729
2729
  if (cs >= EDN_list_first_final) {
2730
- //v = elems;
2731
- // TODO: replace with this but first figure out why array is not unrolled by EDN::list()
2732
2730
  v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_LIST_METHOD, elems);
2733
2731
  return p + 1;
2734
2732
  }
@@ -2746,7 +2744,7 @@ case 3:
2746
2744
  // hash parsing
2747
2745
  //
2748
2746
 
2749
- #line 2750 "edn_parser.cc"
2747
+ #line 2748 "edn_parser.cc"
2750
2748
  static const int EDN_map_start = 1;
2751
2749
  static const int EDN_map_first_final = 4;
2752
2750
  static const int EDN_map_error = 0;
@@ -2754,7 +2752,7 @@ static const int EDN_map_error = 0;
2754
2752
  static const int EDN_map_en_main = 1;
2755
2753
 
2756
2754
 
2757
- #line 785 "edn_parser.rl"
2755
+ #line 783 "edn_parser.rl"
2758
2756
 
2759
2757
 
2760
2758
 
@@ -2768,14 +2766,14 @@ const char* edn::Parser::parse_map(const char *p, const char *pe, VALUE& v)
2768
2766
  VALUE elems;
2769
2767
 
2770
2768
 
2771
- #line 2772 "edn_parser.cc"
2769
+ #line 2770 "edn_parser.cc"
2772
2770
  {
2773
2771
  cs = EDN_map_start;
2774
2772
  }
2775
2773
 
2776
- #line 798 "edn_parser.rl"
2774
+ #line 796 "edn_parser.rl"
2777
2775
 
2778
- #line 2779 "edn_parser.cc"
2776
+ #line 2777 "edn_parser.cc"
2779
2777
  {
2780
2778
  if ( p == pe )
2781
2779
  goto _test_eof;
@@ -2794,7 +2792,7 @@ tr2:
2794
2792
  p--; {p++; cs = 0; goto _out;}
2795
2793
  }
2796
2794
  goto st0;
2797
- #line 2798 "edn_parser.cc"
2795
+ #line 2796 "edn_parser.cc"
2798
2796
  st0:
2799
2797
  cs = 0;
2800
2798
  goto _out;
@@ -2853,7 +2851,7 @@ st2:
2853
2851
  if ( ++p == pe )
2854
2852
  goto _test_eof2;
2855
2853
  case 2:
2856
- #line 2857 "edn_parser.cc"
2854
+ #line 2855 "edn_parser.cc"
2857
2855
  switch( (*p) ) {
2858
2856
  case 10: goto tr4;
2859
2857
  case 32: goto st2;
@@ -2899,7 +2897,7 @@ st4:
2899
2897
  if ( ++p == pe )
2900
2898
  goto _test_eof4;
2901
2899
  case 4:
2902
- #line 2903 "edn_parser.cc"
2900
+ #line 2901 "edn_parser.cc"
2903
2901
  goto st0;
2904
2902
  }
2905
2903
  _test_eof2: cs = 2; goto _test_eof;
@@ -2920,14 +2918,14 @@ case 4:
2920
2918
  p--; {p++; cs = 0; goto _out;}
2921
2919
  }
2922
2920
  break;
2923
- #line 2924 "edn_parser.cc"
2921
+ #line 2922 "edn_parser.cc"
2924
2922
  }
2925
2923
  }
2926
2924
 
2927
2925
  _out: {}
2928
2926
  }
2929
2927
 
2930
- #line 799 "edn_parser.rl"
2928
+ #line 797 "edn_parser.rl"
2931
2929
 
2932
2930
  if (cs >= EDN_map_first_final) {
2933
2931
  // hash parsing is done. Make sure we have an even count
@@ -2962,7 +2960,7 @@ case 4:
2962
2960
  // the remaining data to the correct parser
2963
2961
  //
2964
2962
 
2965
- #line 2966 "edn_parser.cc"
2963
+ #line 2964 "edn_parser.cc"
2966
2964
  static const int EDN_dispatch_start = 1;
2967
2965
  static const int EDN_dispatch_first_final = 2;
2968
2966
  static const int EDN_dispatch_error = 0;
@@ -2970,7 +2968,7 @@ static const int EDN_dispatch_error = 0;
2970
2968
  static const int EDN_dispatch_en_main = 1;
2971
2969
 
2972
2970
 
2973
- #line 862 "edn_parser.rl"
2971
+ #line 879 "edn_parser.rl"
2974
2972
 
2975
2973
 
2976
2974
 
@@ -2979,14 +2977,14 @@ const char* edn::Parser::parse_dispatch(const char *p, const char *pe, VALUE& v)
2979
2977
  int cs;
2980
2978
 
2981
2979
 
2982
- #line 2983 "edn_parser.cc"
2980
+ #line 2981 "edn_parser.cc"
2983
2981
  {
2984
2982
  cs = EDN_dispatch_start;
2985
2983
  }
2986
2984
 
2987
- #line 870 "edn_parser.rl"
2985
+ #line 887 "edn_parser.rl"
2988
2986
 
2989
- #line 2990 "edn_parser.cc"
2987
+ #line 2988 "edn_parser.cc"
2990
2988
  {
2991
2989
  if ( p == pe )
2992
2990
  goto _test_eof;
@@ -2994,20 +2992,44 @@ const char* edn::Parser::parse_dispatch(const char *p, const char *pe, VALUE& v)
2994
2992
  {
2995
2993
  case 1:
2996
2994
  switch( (*p) ) {
2997
- case 95: goto tr2;
2998
- case 123: goto tr3;
2995
+ case 35: goto tr0;
2996
+ case 95: goto tr3;
2997
+ case 123: goto tr4;
2999
2998
  }
3000
2999
  if ( (*p) > 90 ) {
3001
3000
  if ( 97 <= (*p) && (*p) <= 122 )
3002
- goto tr0;
3001
+ goto tr2;
3003
3002
  } else if ( (*p) >= 65 )
3004
- goto tr0;
3003
+ goto tr2;
3005
3004
  goto st0;
3006
3005
  st0:
3007
3006
  cs = 0;
3008
3007
  goto _out;
3009
3008
  tr0:
3010
- #line 850 "edn_parser.rl"
3009
+ #line 854 "edn_parser.rl"
3010
+ {
3011
+ // ##Inf, ##NaN, etc.
3012
+ VALUE sym = Qnil;
3013
+ const char *np = parse_symbol(p+1, pe, sym);
3014
+ if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {
3015
+ if (std::strcmp(RSTRING_PTR(sym), "NaN") == 0) {
3016
+ v = RUBY_NAN_CONST;
3017
+ }
3018
+ else if (std::strcmp(RSTRING_PTR(sym), "Inf") == 0) {
3019
+ v = RUBY_INF_CONST;
3020
+ }
3021
+ else {
3022
+ v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
3023
+ }
3024
+
3025
+ {p = (( np))-1;}
3026
+ }
3027
+ }
3028
+ #line 80 "edn_parser.rl"
3029
+ { p--; {p++; cs = 2; goto _out;} }
3030
+ goto st2;
3031
+ tr2:
3032
+ #line 848 "edn_parser.rl"
3011
3033
  {
3012
3034
  // #inst, #uuid, or #user/tag
3013
3035
  const char *np = parse_tagged(p, pe, v);
@@ -3016,8 +3038,8 @@ tr0:
3016
3038
  #line 80 "edn_parser.rl"
3017
3039
  { p--; {p++; cs = 2; goto _out;} }
3018
3040
  goto st2;
3019
- tr2:
3020
- #line 844 "edn_parser.rl"
3041
+ tr3:
3042
+ #line 842 "edn_parser.rl"
3021
3043
  {
3022
3044
  // discard token #_
3023
3045
  const char *np = parse_discard(p, pe);
@@ -3026,8 +3048,8 @@ tr2:
3026
3048
  #line 80 "edn_parser.rl"
3027
3049
  { p--; {p++; cs = 2; goto _out;} }
3028
3050
  goto st2;
3029
- tr3:
3030
- #line 838 "edn_parser.rl"
3051
+ tr4:
3052
+ #line 836 "edn_parser.rl"
3031
3053
  {
3032
3054
  // #{ }
3033
3055
  const char *np = parse_set(p, pe, v);
@@ -3040,7 +3062,7 @@ st2:
3040
3062
  if ( ++p == pe )
3041
3063
  goto _test_eof2;
3042
3064
  case 2:
3043
- #line 3044 "edn_parser.cc"
3065
+ #line 3066 "edn_parser.cc"
3044
3066
  goto st0;
3045
3067
  }
3046
3068
  _test_eof2: cs = 2; goto _test_eof;
@@ -3049,7 +3071,7 @@ case 2:
3049
3071
  _out: {}
3050
3072
  }
3051
3073
 
3052
- #line 871 "edn_parser.rl"
3074
+ #line 888 "edn_parser.rl"
3053
3075
 
3054
3076
  if (cs >= EDN_dispatch_first_final) {
3055
3077
  return p + 1;
@@ -3067,7 +3089,7 @@ case 2:
3067
3089
  // set parsing machine
3068
3090
  //
3069
3091
 
3070
- #line 3071 "edn_parser.cc"
3092
+ #line 3093 "edn_parser.cc"
3071
3093
  static const int EDN_set_start = 1;
3072
3094
  static const int EDN_set_first_final = 4;
3073
3095
  static const int EDN_set_error = 0;
@@ -3075,7 +3097,7 @@ static const int EDN_set_error = 0;
3075
3097
  static const int EDN_set_en_main = 1;
3076
3098
 
3077
3099
 
3078
- #line 899 "edn_parser.rl"
3100
+ #line 916 "edn_parser.rl"
3079
3101
 
3080
3102
 
3081
3103
  //
@@ -3089,14 +3111,14 @@ const char* edn::Parser::parse_set(const char *p, const char *pe, VALUE& v)
3089
3111
  VALUE elems; // holds the set's elements as an array allocated in @open_seq
3090
3112
 
3091
3113
 
3092
- #line 3093 "edn_parser.cc"
3114
+ #line 3115 "edn_parser.cc"
3093
3115
  {
3094
3116
  cs = EDN_set_start;
3095
3117
  }
3096
3118
 
3097
- #line 912 "edn_parser.rl"
3119
+ #line 929 "edn_parser.rl"
3098
3120
 
3099
- #line 3100 "edn_parser.cc"
3121
+ #line 3122 "edn_parser.cc"
3100
3122
  {
3101
3123
  if ( p == pe )
3102
3124
  goto _test_eof;
@@ -3115,7 +3137,7 @@ tr2:
3115
3137
  p--; {p++; cs = 0; goto _out;}
3116
3138
  }
3117
3139
  goto st0;
3118
- #line 3119 "edn_parser.cc"
3140
+ #line 3141 "edn_parser.cc"
3119
3141
  st0:
3120
3142
  cs = 0;
3121
3143
  goto _out;
@@ -3174,7 +3196,7 @@ st2:
3174
3196
  if ( ++p == pe )
3175
3197
  goto _test_eof2;
3176
3198
  case 2:
3177
- #line 3178 "edn_parser.cc"
3199
+ #line 3200 "edn_parser.cc"
3178
3200
  switch( (*p) ) {
3179
3201
  case 10: goto tr4;
3180
3202
  case 32: goto st2;
@@ -3220,7 +3242,7 @@ st4:
3220
3242
  if ( ++p == pe )
3221
3243
  goto _test_eof4;
3222
3244
  case 4:
3223
- #line 3224 "edn_parser.cc"
3245
+ #line 3246 "edn_parser.cc"
3224
3246
  goto st0;
3225
3247
  }
3226
3248
  _test_eof2: cs = 2; goto _test_eof;
@@ -3241,14 +3263,14 @@ case 4:
3241
3263
  p--; {p++; cs = 0; goto _out;}
3242
3264
  }
3243
3265
  break;
3244
- #line 3245 "edn_parser.cc"
3266
+ #line 3267 "edn_parser.cc"
3245
3267
  }
3246
3268
  }
3247
3269
 
3248
3270
  _out: {}
3249
3271
  }
3250
3272
 
3251
- #line 913 "edn_parser.rl"
3273
+ #line 930 "edn_parser.rl"
3252
3274
 
3253
3275
  if (cs >= EDN_set_first_final) {
3254
3276
  // all elements collected; now convert to a set
@@ -3271,7 +3293,7 @@ case 4:
3271
3293
  // defining a machine to consume items within container delimiters
3272
3294
  //
3273
3295
 
3274
- #line 3275 "edn_parser.cc"
3296
+ #line 3297 "edn_parser.cc"
3275
3297
  static const int EDN_discard_start = 1;
3276
3298
  static const int EDN_discard_first_final = 4;
3277
3299
  static const int EDN_discard_error = 0;
@@ -3279,7 +3301,7 @@ static const int EDN_discard_error = 0;
3279
3301
  static const int EDN_discard_en_main = 1;
3280
3302
 
3281
3303
 
3282
- #line 963 "edn_parser.rl"
3304
+ #line 980 "edn_parser.rl"
3283
3305
 
3284
3306
 
3285
3307
 
@@ -3289,14 +3311,14 @@ const char* edn::Parser::parse_discard(const char *p, const char *pe)
3289
3311
  VALUE v;
3290
3312
 
3291
3313
 
3292
- #line 3293 "edn_parser.cc"
3314
+ #line 3315 "edn_parser.cc"
3293
3315
  {
3294
3316
  cs = EDN_discard_start;
3295
3317
  }
3296
3318
 
3297
- #line 972 "edn_parser.rl"
3319
+ #line 989 "edn_parser.rl"
3298
3320
 
3299
- #line 3300 "edn_parser.cc"
3321
+ #line 3322 "edn_parser.cc"
3300
3322
  {
3301
3323
  if ( p == pe )
3302
3324
  goto _test_eof;
@@ -3307,7 +3329,7 @@ case 1:
3307
3329
  goto st2;
3308
3330
  goto st0;
3309
3331
  tr2:
3310
- #line 953 "edn_parser.rl"
3332
+ #line 970 "edn_parser.rl"
3311
3333
  {
3312
3334
  std::stringstream s;
3313
3335
  s << "discard sequence without element to discard";
@@ -3315,7 +3337,7 @@ tr2:
3315
3337
  p--; {p++; cs = 0; goto _out;}
3316
3338
  }
3317
3339
  goto st0;
3318
- #line 3319 "edn_parser.cc"
3340
+ #line 3341 "edn_parser.cc"
3319
3341
  st0:
3320
3342
  cs = 0;
3321
3343
  goto _out;
@@ -3327,7 +3349,7 @@ st2:
3327
3349
  if ( ++p == pe )
3328
3350
  goto _test_eof2;
3329
3351
  case 2:
3330
- #line 3331 "edn_parser.cc"
3352
+ #line 3353 "edn_parser.cc"
3331
3353
  switch( (*p) ) {
3332
3354
  case 10: goto tr3;
3333
3355
  case 32: goto st2;
@@ -3353,7 +3375,7 @@ case 2:
3353
3375
  goto tr4;
3354
3376
  goto tr2;
3355
3377
  tr4:
3356
- #line 942 "edn_parser.rl"
3378
+ #line 959 "edn_parser.rl"
3357
3379
  {
3358
3380
  const char *np = parse_value(p, pe, v);
3359
3381
  if (np == nullptr) { p--; {p++; cs = 4; goto _out;} } else {
@@ -3371,7 +3393,7 @@ st4:
3371
3393
  if ( ++p == pe )
3372
3394
  goto _test_eof4;
3373
3395
  case 4:
3374
- #line 3375 "edn_parser.cc"
3396
+ #line 3397 "edn_parser.cc"
3375
3397
  goto st0;
3376
3398
  st3:
3377
3399
  if ( ++p == pe )
@@ -3390,7 +3412,7 @@ case 3:
3390
3412
  {
3391
3413
  switch ( cs ) {
3392
3414
  case 2:
3393
- #line 953 "edn_parser.rl"
3415
+ #line 970 "edn_parser.rl"
3394
3416
  {
3395
3417
  std::stringstream s;
3396
3418
  s << "discard sequence without element to discard";
@@ -3398,14 +3420,14 @@ case 3:
3398
3420
  p--; {p++; cs = 0; goto _out;}
3399
3421
  }
3400
3422
  break;
3401
- #line 3402 "edn_parser.cc"
3423
+ #line 3424 "edn_parser.cc"
3402
3424
  }
3403
3425
  }
3404
3426
 
3405
3427
  _out: {}
3406
3428
  }
3407
3429
 
3408
- #line 973 "edn_parser.rl"
3430
+ #line 990 "edn_parser.rl"
3409
3431
 
3410
3432
  if (cs >= EDN_discard_first_final) {
3411
3433
  return p + 1;
@@ -3435,7 +3457,7 @@ case 3:
3435
3457
  // 2. add parse checks for uuid and inst for better error reporting
3436
3458
  //
3437
3459
 
3438
- #line 3439 "edn_parser.cc"
3460
+ #line 3461 "edn_parser.cc"
3439
3461
  static const int EDN_tagged_start = 1;
3440
3462
  static const int EDN_tagged_first_final = 7;
3441
3463
  static const int EDN_tagged_error = 0;
@@ -3443,7 +3465,7 @@ static const int EDN_tagged_error = 0;
3443
3465
  static const int EDN_tagged_en_main = 1;
3444
3466
 
3445
3467
 
3446
- #line 1040 "edn_parser.rl"
3468
+ #line 1057 "edn_parser.rl"
3447
3469
 
3448
3470
 
3449
3471
 
@@ -3457,14 +3479,14 @@ const char* edn::Parser::parse_tagged(const char *p, const char *pe, VALUE& v)
3457
3479
  int cs;
3458
3480
 
3459
3481
 
3460
- #line 3461 "edn_parser.cc"
3482
+ #line 3483 "edn_parser.cc"
3461
3483
  {
3462
3484
  cs = EDN_tagged_start;
3463
3485
  }
3464
3486
 
3465
- #line 1053 "edn_parser.rl"
3487
+ #line 1070 "edn_parser.rl"
3466
3488
 
3467
- #line 3468 "edn_parser.cc"
3489
+ #line 3490 "edn_parser.cc"
3468
3490
  {
3469
3491
  if ( p == pe )
3470
3492
  goto _test_eof;
@@ -3481,7 +3503,7 @@ st0:
3481
3503
  cs = 0;
3482
3504
  goto _out;
3483
3505
  tr0:
3484
- #line 1019 "edn_parser.rl"
3506
+ #line 1036 "edn_parser.rl"
3485
3507
  {
3486
3508
  // parses the symbol portion of the pair
3487
3509
  const char *np = parse_symbol(p, pe, sym_name);
@@ -3495,7 +3517,7 @@ st2:
3495
3517
  if ( ++p == pe )
3496
3518
  goto _test_eof2;
3497
3519
  case 2:
3498
- #line 3499 "edn_parser.cc"
3520
+ #line 3521 "edn_parser.cc"
3499
3521
  switch( (*p) ) {
3500
3522
  case 10: goto tr3;
3501
3523
  case 32: goto st3;
@@ -3528,7 +3550,7 @@ st3:
3528
3550
  if ( ++p == pe )
3529
3551
  goto _test_eof3;
3530
3552
  case 3:
3531
- #line 3532 "edn_parser.cc"
3553
+ #line 3554 "edn_parser.cc"
3532
3554
  switch( (*p) ) {
3533
3555
  case 10: goto tr3;
3534
3556
  case 32: goto st3;
@@ -3554,7 +3576,7 @@ case 3:
3554
3576
  goto tr7;
3555
3577
  goto st0;
3556
3578
  tr7:
3557
- #line 1027 "edn_parser.rl"
3579
+ #line 1044 "edn_parser.rl"
3558
3580
  {
3559
3581
  // parses the value portion
3560
3582
  const char *np = parse_value(p, pe, data);
@@ -3570,7 +3592,7 @@ st7:
3570
3592
  if ( ++p == pe )
3571
3593
  goto _test_eof7;
3572
3594
  case 7:
3573
- #line 3574 "edn_parser.cc"
3595
+ #line 3596 "edn_parser.cc"
3574
3596
  goto st0;
3575
3597
  st4:
3576
3598
  if ( ++p == pe )
@@ -3648,7 +3670,7 @@ case 6:
3648
3670
  _out: {}
3649
3671
  }
3650
3672
 
3651
- #line 1054 "edn_parser.rl"
3673
+ #line 1071 "edn_parser.rl"
3652
3674
 
3653
3675
  if (cs >= EDN_tagged_first_final) {
3654
3676
  //std::cerr << __FUNCTION__ << " parse symbol name as '" << sym_name << "', value is: " << data << std::endl;
@@ -3684,7 +3706,7 @@ case 6:
3684
3706
  // useful?
3685
3707
  //
3686
3708
 
3687
- #line 3688 "edn_parser.cc"
3709
+ #line 3710 "edn_parser.cc"
3688
3710
  static const int EDN_meta_start = 1;
3689
3711
  static const int EDN_meta_first_final = 3;
3690
3712
  static const int EDN_meta_error = 0;
@@ -3692,7 +3714,7 @@ static const int EDN_meta_error = 0;
3692
3714
  static const int EDN_meta_en_main = 1;
3693
3715
 
3694
3716
 
3695
- #line 1102 "edn_parser.rl"
3717
+ #line 1119 "edn_parser.rl"
3696
3718
 
3697
3719
 
3698
3720
 
@@ -3702,14 +3724,14 @@ const char* edn::Parser::parse_meta(const char *p, const char *pe)
3702
3724
  VALUE v;
3703
3725
 
3704
3726
 
3705
- #line 3706 "edn_parser.cc"
3727
+ #line 3728 "edn_parser.cc"
3706
3728
  {
3707
3729
  cs = EDN_meta_start;
3708
3730
  }
3709
3731
 
3710
- #line 1111 "edn_parser.rl"
3732
+ #line 1128 "edn_parser.rl"
3711
3733
 
3712
- #line 3713 "edn_parser.cc"
3734
+ #line 3735 "edn_parser.cc"
3713
3735
  {
3714
3736
  if ( p == pe )
3715
3737
  goto _test_eof;
@@ -3748,7 +3770,7 @@ case 2:
3748
3770
  goto tr2;
3749
3771
  goto st0;
3750
3772
  tr2:
3751
- #line 1094 "edn_parser.rl"
3773
+ #line 1111 "edn_parser.rl"
3752
3774
  {
3753
3775
  const char *np = parse_value(p, pe, v);
3754
3776
  if (np == nullptr) { p--; {p++; cs = 3; goto _out;} } else { {p = (( np))-1;} }
@@ -3760,7 +3782,7 @@ st3:
3760
3782
  if ( ++p == pe )
3761
3783
  goto _test_eof3;
3762
3784
  case 3:
3763
- #line 3764 "edn_parser.cc"
3785
+ #line 3786 "edn_parser.cc"
3764
3786
  goto st0;
3765
3787
  }
3766
3788
  _test_eof2: cs = 2; goto _test_eof;
@@ -3770,7 +3792,7 @@ case 3:
3770
3792
  _out: {}
3771
3793
  }
3772
3794
 
3773
- #line 1112 "edn_parser.rl"
3795
+ #line 1129 "edn_parser.rl"
3774
3796
 
3775
3797
  if (cs >= EDN_meta_first_final) {
3776
3798
  append_to_meta(v);
@@ -3791,7 +3813,7 @@ case 3:
3791
3813
  // top-level, therefore, does not tokenize source stream
3792
3814
  //
3793
3815
 
3794
- #line 3795 "edn_parser.cc"
3816
+ #line 3817 "edn_parser.cc"
3795
3817
  static const int EDN_parser_start = 2;
3796
3818
  static const int EDN_parser_first_final = 2;
3797
3819
  static const int EDN_parser_error = 0;
@@ -3799,7 +3821,7 @@ static const int EDN_parser_error = 0;
3799
3821
  static const int EDN_parser_en_main = 2;
3800
3822
 
3801
3823
 
3802
- #line 1160 "edn_parser.rl"
3824
+ #line 1177 "edn_parser.rl"
3803
3825
 
3804
3826
 
3805
3827
 
@@ -3809,15 +3831,15 @@ VALUE edn::Parser::parse(const char* src, std::size_t len)
3809
3831
  VALUE result = EDN_EOF_CONST;
3810
3832
 
3811
3833
 
3812
- #line 3813 "edn_parser.cc"
3834
+ #line 3835 "edn_parser.cc"
3813
3835
  {
3814
3836
  cs = EDN_parser_start;
3815
3837
  }
3816
3838
 
3817
- #line 1169 "edn_parser.rl"
3839
+ #line 1186 "edn_parser.rl"
3818
3840
  set_source(src, len);
3819
3841
 
3820
- #line 3821 "edn_parser.cc"
3842
+ #line 3843 "edn_parser.cc"
3821
3843
  {
3822
3844
  if ( p == pe )
3823
3845
  goto _test_eof;
@@ -3828,7 +3850,7 @@ tr1:
3828
3850
  { line_number++; }
3829
3851
  goto st2;
3830
3852
  tr4:
3831
- #line 1137 "edn_parser.rl"
3853
+ #line 1154 "edn_parser.rl"
3832
3854
  {
3833
3855
  // save the count of metadata items before we parse this value
3834
3856
  // so we can determine if we've read another metadata value or
@@ -3851,7 +3873,7 @@ st2:
3851
3873
  if ( ++p == pe )
3852
3874
  goto _test_eof2;
3853
3875
  case 2:
3854
- #line 3855 "edn_parser.cc"
3876
+ #line 3877 "edn_parser.cc"
3855
3877
  switch( (*p) ) {
3856
3878
  case 10: goto tr1;
3857
3879
  case 32: goto st2;
@@ -3894,7 +3916,7 @@ case 1:
3894
3916
  _out: {}
3895
3917
  }
3896
3918
 
3897
- #line 1171 "edn_parser.rl"
3919
+ #line 1188 "edn_parser.rl"
3898
3920
 
3899
3921
  if (cs == EDN_parser_error) {
3900
3922
  error(__FUNCTION__, *p);
@@ -3912,13 +3934,13 @@ case 1:
3912
3934
  // token-by-token machine
3913
3935
  //
3914
3936
 
3915
- #line 3916 "edn_parser.cc"
3937
+ #line 3938 "edn_parser.cc"
3916
3938
  static const int EDN_tokens_start = 1;
3917
3939
 
3918
3940
  static const int EDN_tokens_en_main = 1;
3919
3941
 
3920
3942
 
3921
- #line 1225 "edn_parser.rl"
3943
+ #line 1242 "edn_parser.rl"
3922
3944
 
3923
3945
 
3924
3946
 
@@ -3937,14 +3959,14 @@ edn::Parser::eTokenState edn::Parser::parse_next(VALUE& value)
3937
3959
  discard.clear();
3938
3960
 
3939
3961
 
3940
- #line 3941 "edn_parser.cc"
3962
+ #line 3963 "edn_parser.cc"
3941
3963
  {
3942
3964
  cs = EDN_tokens_start;
3943
3965
  }
3944
3966
 
3945
- #line 1243 "edn_parser.rl"
3967
+ #line 1260 "edn_parser.rl"
3946
3968
 
3947
- #line 3948 "edn_parser.cc"
3969
+ #line 3970 "edn_parser.cc"
3948
3970
  {
3949
3971
  if ( p == pe )
3950
3972
  goto _test_eof;
@@ -3958,7 +3980,7 @@ st1:
3958
3980
  if ( ++p == pe )
3959
3981
  goto _test_eof1;
3960
3982
  case 1:
3961
- #line 3962 "edn_parser.cc"
3983
+ #line 3984 "edn_parser.cc"
3962
3984
  switch( (*p) ) {
3963
3985
  case 10: goto tr2;
3964
3986
  case 32: goto st1;
@@ -3991,7 +4013,7 @@ tr6:
3991
4013
  { line_number++; }
3992
4014
  goto st4;
3993
4015
  tr3:
3994
- #line 1193 "edn_parser.rl"
4016
+ #line 1210 "edn_parser.rl"
3995
4017
  {
3996
4018
  // we won't know if we've parsed a discard or a metadata until
3997
4019
  // after parse_value() is done. Save the current number of
@@ -4027,7 +4049,7 @@ st4:
4027
4049
  if ( ++p == pe )
4028
4050
  goto _test_eof4;
4029
4051
  case 4:
4030
- #line 4031 "edn_parser.cc"
4052
+ #line 4053 "edn_parser.cc"
4031
4053
  switch( (*p) ) {
4032
4054
  case 10: goto tr6;
4033
4055
  case 32: goto st4;
@@ -4061,7 +4083,7 @@ case 3:
4061
4083
  _out: {}
4062
4084
  }
4063
4085
 
4064
- #line 1244 "edn_parser.rl"
4086
+ #line 1261 "edn_parser.rl"
4065
4087
 
4066
4088
  if (cs == EDN_tokens_en_main) {} // silence ragel warning
4067
4089
  return state;
@@ -851,10 +851,29 @@ const char* edn::Parser::parse_map(const char *p, const char *pe, VALUE& v)
851
851
  if (np == nullptr) { fhold; fbreak; } else fexec np;
852
852
  }
853
853
 
854
+ action parse_disp_symbol {
855
+ // ##Inf, ##NaN, etc.
856
+ VALUE sym = Qnil;
857
+ const char *np = parse_symbol(fpc+1, pe, sym);
858
+ if (np == nullptr) { fhold; fbreak; } else {
859
+ if (std::strcmp(RSTRING_PTR(sym), "NaN") == 0) {
860
+ v = RUBY_NAN_CONST;
861
+ }
862
+ else if (std::strcmp(RSTRING_PTR(sym), "Inf") == 0) {
863
+ v = RUBY_INF_CONST;
864
+ }
865
+ else {
866
+ v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
867
+ }
868
+
869
+ fexec np;
870
+ }
871
+ }
854
872
 
855
873
  main := (
856
874
  ('{' >parse_disp_set |
857
875
  '_' >parse_disp_discard |
876
+ '#' >parse_disp_symbol |
858
877
  alpha >parse_disp_tagged)
859
878
  ) @exit;
860
879
  }%%
@@ -48,6 +48,9 @@ namespace edn {
48
48
  VALUE RUBY_STRING_TO_F_METHOD = Qnil;
49
49
  VALUE RUBY_READ_METHOD = Qnil;
50
50
 
51
+ VALUE RUBY_NAN_CONST = Qnil;
52
+ VALUE RUBY_INF_CONST = Qnil;
53
+
51
54
  // returned when EOF - defined as a constant in EDN module
52
55
  VALUE EDN_EOF_CONST = Qnil;
53
56
 
@@ -226,6 +229,10 @@ void Init_edn_turbo(void)
226
229
  edn::RUBY_STRING_TO_F_METHOD = rb_intern("to_f");
227
230
  edn::RUBY_READ_METHOD = rb_intern("read");
228
231
 
232
+ VALUE rb_mFloat = rb_const_get(rb_cObject, rb_intern("Float"));
233
+ edn::RUBY_NAN_CONST = rb_const_get(rb_mFloat, rb_intern("NAN"));
234
+ edn::RUBY_INF_CONST = rb_const_get(rb_mFloat, rb_intern("INFINITY"));
235
+
229
236
  // so we can return EOF directly
230
237
  edn::EDN_EOF_CONST = rb_const_get(edn::rb_mEDN, rb_intern("EOF"));
231
238
  }
data/ext/edn_turbo/util.h CHANGED
@@ -41,6 +41,9 @@ namespace edn
41
41
  extern VALUE RUBY_STRING_TO_F_METHOD;
42
42
  extern VALUE RUBY_READ_METHOD;
43
43
 
44
+ extern VALUE RUBY_NAN_CONST;
45
+ extern VALUE RUBY_INF_CONST;
46
+
44
47
  namespace util
45
48
  {
46
49
  // defined in edn_parser_util.cc
@@ -21,6 +21,6 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module EDNT
24
- VERSION = '0.6.1'.freeze
25
- RELEASE_DATE = '2019-05-20'.freeze
24
+ VERSION = '0.6.2'.freeze
25
+ RELEASE_DATE = '2019-05-21'.freeze
26
26
  end
@@ -352,6 +352,15 @@ module EDNT
352
352
  it 'with mathematical operators' do
353
353
  expect(subject.parse('>:FOuy/+')).to eq(EDN::Type::Symbol.new('>:FOuy/+'))
354
354
  end
355
+ it 'NaN' do
356
+ expect(subject.parse('##NaN').to_f.nan?).to be_truthy
357
+ end
358
+ it 'infinity' do
359
+ expect(subject.parse('##Inf')).to eq(Float::INFINITY)
360
+ end
361
+ it 'negative infinity' do
362
+ expect(subject.parse('##-Inf')).to eq(EDN::Type::Symbol.new('-Inf'))
363
+ end
355
364
  end
356
365
 
357
366
  context 'metadata' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edn_turbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Porras
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-20 00:00:00.000000000 Z
11
+ date: 2019-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: edn