cddlc 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/cddlc.gemspec +1 -1
  3. data/lib/parser/cddlgrammar.rb +535 -12
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1b9a4aa1c2c8b9ba3310cdca0201947f6bd08c7d229443d462ac2881e3d0768
4
- data.tar.gz: 7873a339b9f98917635e0d9e5bd6a1a62ce096b2ba6fb39d1daced9eb328209b
3
+ metadata.gz: 441f617191e302fe38e2a0622ab0cc7e218ab88b5753565b7d156e0d4648da8e
4
+ data.tar.gz: 4a79ff5132f0a0c92a011a50ea238f9c58472cea52f27c7edd502e057f4dd570
5
5
  SHA512:
6
- metadata.gz: ac5068f18dc4881e9b52edeb0e262d806f788d72835ca3bfd020911f1414bc60a8a35fe18b7ede71d56bee3c25e263afa16e81f7d8fabee349fe9c0e9c57218a
7
- data.tar.gz: 3676274ba515d3ec01677a2e0db3e988659e692c9457e01566122dc672f00ec0d1490d602139d13e962ebd31544a6d90ae88842f466edbc65d3c2373d2b9a948
6
+ metadata.gz: 631b1d41853d7b8f6a1df2a0ba47c8a474d3142daa8282bb83dbc86434a824b188a033cebdb892b8e7e5b4c08fec7e24dd88933e6de11e210b077a5ff666ce88
7
+ data.tar.gz: 1c2f44dbc2a98c1716b0758be614f8872b8a1921a2ffd9061099425d5e84d8861785204f1c80d1f9dd5f77f8583138a95d44489978834e0df83e4dacd7686624
data/cddlc.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cddlc"
3
- s.version = "0.0.2"
3
+ s.version = "0.0.3"
4
4
  s.summary = "CDDL (Concise Data Definition Language) converters and miscellaneous tools"
5
5
  s.description = %q{cddlc implements converters and miscellaneous tools for CDDL, RFC 8610}
6
6
  s.author = "Carsten Bormann"
@@ -3106,9 +3106,15 @@ module CDDLGRAMMAR
3106
3106
  end
3107
3107
 
3108
3108
  module SESC0
3109
+ def hexchar
3110
+ elements[1]
3111
+ end
3109
3112
  end
3110
3113
 
3111
3114
  module SESC1
3115
+ end
3116
+
3117
+ module SESC2
3112
3118
  def ast() JSON.load("\"\\#{elements[1].text_value}\"") end
3113
3119
  end
3114
3120
 
@@ -3134,38 +3140,135 @@ module CDDLGRAMMAR
3134
3140
  s0 << r1
3135
3141
  if r1
3136
3142
  i2 = index
3137
- if has_terminal?(@regexps[gr = '\A[\\ -~]'] ||= Regexp.new(gr), :regexp, index)
3143
+ if (match_len = has_terminal?("\"", false, index))
3138
3144
  r3 = true
3139
- @index += 1
3145
+ @index += match_len
3140
3146
  else
3141
- terminal_parse_failure('[\\ -~]')
3147
+ terminal_parse_failure('"\\""')
3142
3148
  r3 = nil
3143
3149
  end
3144
3150
  if r3
3145
3151
  r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
3146
3152
  r2 = r3
3147
3153
  else
3148
- if has_terminal?(@regexps[gr = '\A[€-􏿽]'] ||= Regexp.new(gr), :regexp, index)
3154
+ if (match_len = has_terminal?("/", false, index))
3149
3155
  r4 = true
3150
- @index += 1
3156
+ @index += match_len
3151
3157
  else
3152
- terminal_parse_failure('[€-􏿽]')
3158
+ terminal_parse_failure('"/"')
3153
3159
  r4 = nil
3154
3160
  end
3155
3161
  if r4
3156
3162
  r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
3157
3163
  r2 = r4
3158
3164
  else
3159
- @index = i2
3160
- r2 = nil
3165
+ if (match_len = has_terminal?("\\", false, index))
3166
+ r5 = true
3167
+ @index += match_len
3168
+ else
3169
+ terminal_parse_failure('"\\\\"')
3170
+ r5 = nil
3171
+ end
3172
+ if r5
3173
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
3174
+ r2 = r5
3175
+ else
3176
+ if (match_len = has_terminal?("b", false, index))
3177
+ r6 = true
3178
+ @index += match_len
3179
+ else
3180
+ terminal_parse_failure('"b"')
3181
+ r6 = nil
3182
+ end
3183
+ if r6
3184
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
3185
+ r2 = r6
3186
+ else
3187
+ if (match_len = has_terminal?("f", false, index))
3188
+ r7 = true
3189
+ @index += match_len
3190
+ else
3191
+ terminal_parse_failure('"f"')
3192
+ r7 = nil
3193
+ end
3194
+ if r7
3195
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
3196
+ r2 = r7
3197
+ else
3198
+ if (match_len = has_terminal?("n", false, index))
3199
+ r8 = true
3200
+ @index += match_len
3201
+ else
3202
+ terminal_parse_failure('"n"')
3203
+ r8 = nil
3204
+ end
3205
+ if r8
3206
+ r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
3207
+ r2 = r8
3208
+ else
3209
+ if (match_len = has_terminal?("r", false, index))
3210
+ r9 = true
3211
+ @index += match_len
3212
+ else
3213
+ terminal_parse_failure('"r"')
3214
+ r9 = nil
3215
+ end
3216
+ if r9
3217
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
3218
+ r2 = r9
3219
+ else
3220
+ if (match_len = has_terminal?("t", false, index))
3221
+ r10 = true
3222
+ @index += match_len
3223
+ else
3224
+ terminal_parse_failure('"t"')
3225
+ r10 = nil
3226
+ end
3227
+ if r10
3228
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
3229
+ r2 = r10
3230
+ else
3231
+ i11, s11 = index, []
3232
+ if (match_len = has_terminal?("u", false, index))
3233
+ r12 = true
3234
+ @index += match_len
3235
+ else
3236
+ terminal_parse_failure('"u"')
3237
+ r12 = nil
3238
+ end
3239
+ s11 << r12
3240
+ if r12
3241
+ r13 = _nt_hexchar
3242
+ s11 << r13
3243
+ end
3244
+ if s11.last
3245
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
3246
+ r11.extend(SESC0)
3247
+ else
3248
+ @index = i11
3249
+ r11 = nil
3250
+ end
3251
+ if r11
3252
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
3253
+ r2 = r11
3254
+ else
3255
+ @index = i2
3256
+ r2 = nil
3257
+ end
3258
+ end
3259
+ end
3260
+ end
3261
+ end
3262
+ end
3263
+ end
3161
3264
  end
3162
3265
  end
3163
3266
  s0 << r2
3164
3267
  end
3165
3268
  if s0.last
3166
3269
  r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
3167
- r0.extend(SESC0)
3168
3270
  r0.extend(SESC1)
3271
+ r0.extend(SESC2)
3169
3272
  else
3170
3273
  @index = i0
3171
3274
  r0 = nil
@@ -3176,6 +3279,414 @@ module CDDLGRAMMAR
3176
3279
  r0
3177
3280
  end
3178
3281
 
3282
+ module Hexchar0
3283
+ end
3284
+
3285
+ module Hexchar1
3286
+ end
3287
+
3288
+ module Hexchar2
3289
+ end
3290
+
3291
+ module Hexchar3
3292
+ end
3293
+
3294
+ def _nt_hexchar
3295
+ start_index = index
3296
+ if node_cache[:hexchar].has_key?(index)
3297
+ cached = node_cache[:hexchar][index]
3298
+ if cached
3299
+ node_cache[:hexchar][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3300
+ @index = cached.interval.end
3301
+ end
3302
+ return cached
3303
+ end
3304
+
3305
+ i0 = index
3306
+ i1, s1 = index, []
3307
+ i2 = index
3308
+ r3 = _nt_DIGIT
3309
+ if r3
3310
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
3311
+ r2 = r3
3312
+ else
3313
+ if (match_len = has_terminal?("a", :insens, index))
3314
+ r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3315
+ @index += match_len
3316
+ else
3317
+ terminal_parse_failure('"A"')
3318
+ r4 = nil
3319
+ end
3320
+ if r4
3321
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
3322
+ r2 = r4
3323
+ else
3324
+ if (match_len = has_terminal?("b", :insens, index))
3325
+ r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3326
+ @index += match_len
3327
+ else
3328
+ terminal_parse_failure('"B"')
3329
+ r5 = nil
3330
+ end
3331
+ if r5
3332
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
3333
+ r2 = r5
3334
+ else
3335
+ if (match_len = has_terminal?("c", :insens, index))
3336
+ r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3337
+ @index += match_len
3338
+ else
3339
+ terminal_parse_failure('"C"')
3340
+ r6 = nil
3341
+ end
3342
+ if r6
3343
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
3344
+ r2 = r6
3345
+ else
3346
+ if (match_len = has_terminal?("e", :insens, index))
3347
+ r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3348
+ @index += match_len
3349
+ else
3350
+ terminal_parse_failure('"E"')
3351
+ r7 = nil
3352
+ end
3353
+ if r7
3354
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
3355
+ r2 = r7
3356
+ else
3357
+ if (match_len = has_terminal?("f", :insens, index))
3358
+ r8 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3359
+ @index += match_len
3360
+ else
3361
+ terminal_parse_failure('"F"')
3362
+ r8 = nil
3363
+ end
3364
+ if r8
3365
+ r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
3366
+ r2 = r8
3367
+ else
3368
+ @index = i2
3369
+ r2 = nil
3370
+ end
3371
+ end
3372
+ end
3373
+ end
3374
+ end
3375
+ end
3376
+ s1 << r2
3377
+ if r2
3378
+ s9, i9 = [], index
3379
+ loop do
3380
+ r10 = _nt_HEXDIG
3381
+ if r10
3382
+ s9 << r10
3383
+ else
3384
+ break
3385
+ end
3386
+ if s9.size == 3
3387
+ break
3388
+ end
3389
+ end
3390
+ if s9.size < 3
3391
+ @index = i9
3392
+ r9 = nil
3393
+ else
3394
+ if s9.size < 3
3395
+ @terminal_failures.pop
3396
+ end
3397
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
3398
+ end
3399
+ s1 << r9
3400
+ end
3401
+ if s1.last
3402
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
3403
+ r1.extend(Hexchar0)
3404
+ else
3405
+ @index = i1
3406
+ r1 = nil
3407
+ end
3408
+ if r1
3409
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
3410
+ r0 = r1
3411
+ else
3412
+ i11, s11 = index, []
3413
+ if (match_len = has_terminal?("d", :insens, index))
3414
+ r12 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3415
+ @index += match_len
3416
+ else
3417
+ terminal_parse_failure('"D"')
3418
+ r12 = nil
3419
+ end
3420
+ s11 << r12
3421
+ if r12
3422
+ i13 = index
3423
+ i14, s14 = index, []
3424
+ if has_terminal?(@regexps[gr = '\A[0-7]'] ||= Regexp.new(gr), :regexp, index)
3425
+ r15 = true
3426
+ @index += 1
3427
+ else
3428
+ terminal_parse_failure('[0-7]')
3429
+ r15 = nil
3430
+ end
3431
+ s14 << r15
3432
+ if r15
3433
+ s16, i16 = [], index
3434
+ loop do
3435
+ r17 = _nt_HEXDIG
3436
+ if r17
3437
+ s16 << r17
3438
+ else
3439
+ break
3440
+ end
3441
+ if s16.size == 2
3442
+ break
3443
+ end
3444
+ end
3445
+ if s16.size < 2
3446
+ @index = i16
3447
+ r16 = nil
3448
+ else
3449
+ if s16.size < 2
3450
+ @terminal_failures.pop
3451
+ end
3452
+ r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
3453
+ end
3454
+ s14 << r16
3455
+ end
3456
+ if s14.last
3457
+ r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
3458
+ r14.extend(Hexchar1)
3459
+ else
3460
+ @index = i14
3461
+ r14 = nil
3462
+ end
3463
+ if r14
3464
+ r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
3465
+ r13 = r14
3466
+ else
3467
+ i18, s18 = index, []
3468
+ i19 = index
3469
+ if (match_len = has_terminal?("8", false, index))
3470
+ r20 = true
3471
+ @index += match_len
3472
+ else
3473
+ terminal_parse_failure('"8"')
3474
+ r20 = nil
3475
+ end
3476
+ if r20
3477
+ r20 = SyntaxNode.new(input, (index-1)...index) if r20 == true
3478
+ r19 = r20
3479
+ else
3480
+ if (match_len = has_terminal?("9", false, index))
3481
+ r21 = true
3482
+ @index += match_len
3483
+ else
3484
+ terminal_parse_failure('"9"')
3485
+ r21 = nil
3486
+ end
3487
+ if r21
3488
+ r21 = SyntaxNode.new(input, (index-1)...index) if r21 == true
3489
+ r19 = r21
3490
+ else
3491
+ if (match_len = has_terminal?("a", :insens, index))
3492
+ r22 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3493
+ @index += match_len
3494
+ else
3495
+ terminal_parse_failure('"A"')
3496
+ r22 = nil
3497
+ end
3498
+ if r22
3499
+ r22 = SyntaxNode.new(input, (index-1)...index) if r22 == true
3500
+ r19 = r22
3501
+ else
3502
+ if (match_len = has_terminal?("b", :insens, index))
3503
+ r23 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3504
+ @index += match_len
3505
+ else
3506
+ terminal_parse_failure('"B"')
3507
+ r23 = nil
3508
+ end
3509
+ if r23
3510
+ r23 = SyntaxNode.new(input, (index-1)...index) if r23 == true
3511
+ r19 = r23
3512
+ else
3513
+ @index = i19
3514
+ r19 = nil
3515
+ end
3516
+ end
3517
+ end
3518
+ end
3519
+ s18 << r19
3520
+ if r19
3521
+ s24, i24 = [], index
3522
+ loop do
3523
+ r25 = _nt_HEXDIG
3524
+ if r25
3525
+ s24 << r25
3526
+ else
3527
+ break
3528
+ end
3529
+ if s24.size == 2
3530
+ break
3531
+ end
3532
+ end
3533
+ if s24.size < 2
3534
+ @index = i24
3535
+ r24 = nil
3536
+ else
3537
+ if s24.size < 2
3538
+ @terminal_failures.pop
3539
+ end
3540
+ r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
3541
+ end
3542
+ s18 << r24
3543
+ if r24
3544
+ if (match_len = has_terminal?("\\", false, index))
3545
+ r26 = true
3546
+ @index += match_len
3547
+ else
3548
+ terminal_parse_failure('"\\\\"')
3549
+ r26 = nil
3550
+ end
3551
+ s18 << r26
3552
+ if r26
3553
+ if (match_len = has_terminal?("u", false, index))
3554
+ r27 = true
3555
+ @index += match_len
3556
+ else
3557
+ terminal_parse_failure('"u"')
3558
+ r27 = nil
3559
+ end
3560
+ s18 << r27
3561
+ if r27
3562
+ if (match_len = has_terminal?("d", :insens, index))
3563
+ r28 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3564
+ @index += match_len
3565
+ else
3566
+ terminal_parse_failure('"D"')
3567
+ r28 = nil
3568
+ end
3569
+ s18 << r28
3570
+ if r28
3571
+ i29 = index
3572
+ if (match_len = has_terminal?("c", :insens, index))
3573
+ r30 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3574
+ @index += match_len
3575
+ else
3576
+ terminal_parse_failure('"C"')
3577
+ r30 = nil
3578
+ end
3579
+ if r30
3580
+ r30 = SyntaxNode.new(input, (index-1)...index) if r30 == true
3581
+ r29 = r30
3582
+ else
3583
+ if (match_len = has_terminal?("d", :insens, index))
3584
+ r31 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3585
+ @index += match_len
3586
+ else
3587
+ terminal_parse_failure('"D"')
3588
+ r31 = nil
3589
+ end
3590
+ if r31
3591
+ r31 = SyntaxNode.new(input, (index-1)...index) if r31 == true
3592
+ r29 = r31
3593
+ else
3594
+ if (match_len = has_terminal?("e", :insens, index))
3595
+ r32 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3596
+ @index += match_len
3597
+ else
3598
+ terminal_parse_failure('"E"')
3599
+ r32 = nil
3600
+ end
3601
+ if r32
3602
+ r32 = SyntaxNode.new(input, (index-1)...index) if r32 == true
3603
+ r29 = r32
3604
+ else
3605
+ if (match_len = has_terminal?("f", :insens, index))
3606
+ r33 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3607
+ @index += match_len
3608
+ else
3609
+ terminal_parse_failure('"F"')
3610
+ r33 = nil
3611
+ end
3612
+ if r33
3613
+ r33 = SyntaxNode.new(input, (index-1)...index) if r33 == true
3614
+ r29 = r33
3615
+ else
3616
+ @index = i29
3617
+ r29 = nil
3618
+ end
3619
+ end
3620
+ end
3621
+ end
3622
+ s18 << r29
3623
+ if r29
3624
+ s34, i34 = [], index
3625
+ loop do
3626
+ r35 = _nt_HEXDIG
3627
+ if r35
3628
+ s34 << r35
3629
+ else
3630
+ break
3631
+ end
3632
+ if s34.size == 2
3633
+ break
3634
+ end
3635
+ end
3636
+ if s34.size < 2
3637
+ @index = i34
3638
+ r34 = nil
3639
+ else
3640
+ if s34.size < 2
3641
+ @terminal_failures.pop
3642
+ end
3643
+ r34 = instantiate_node(SyntaxNode,input, i34...index, s34)
3644
+ end
3645
+ s18 << r34
3646
+ end
3647
+ end
3648
+ end
3649
+ end
3650
+ end
3651
+ end
3652
+ if s18.last
3653
+ r18 = instantiate_node(SyntaxNode,input, i18...index, s18)
3654
+ r18.extend(Hexchar2)
3655
+ else
3656
+ @index = i18
3657
+ r18 = nil
3658
+ end
3659
+ if r18
3660
+ r18 = SyntaxNode.new(input, (index-1)...index) if r18 == true
3661
+ r13 = r18
3662
+ else
3663
+ @index = i13
3664
+ r13 = nil
3665
+ end
3666
+ end
3667
+ s11 << r13
3668
+ end
3669
+ if s11.last
3670
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
3671
+ r11.extend(Hexchar3)
3672
+ else
3673
+ @index = i11
3674
+ r11 = nil
3675
+ end
3676
+ if r11
3677
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
3678
+ r0 = r11
3679
+ else
3680
+ @index = i0
3681
+ r0 = nil
3682
+ end
3683
+ end
3684
+
3685
+ node_cache[:hexchar][start_index] = r0
3686
+
3687
+ r0
3688
+ end
3689
+
3179
3690
  module Bytes0
3180
3691
  end
3181
3692
 
@@ -3299,13 +3810,25 @@ module CDDLGRAMMAR
3299
3810
  r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
3300
3811
  r0 = r4
3301
3812
  else
3302
- r5 = _nt_CRLF
3813
+ if (match_len = has_terminal?("\\'", false, index))
3814
+ r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
3815
+ @index += match_len
3816
+ else
3817
+ terminal_parse_failure('"\\\\\'"')
3818
+ r5 = nil
3819
+ end
3303
3820
  if r5
3304
3821
  r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
3305
3822
  r0 = r5
3306
3823
  else
3307
- @index = i0
3308
- r0 = nil
3824
+ r6 = _nt_CRLF
3825
+ if r6
3826
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
3827
+ r0 = r6
3828
+ else
3829
+ @index = i0
3830
+ r0 = nil
3831
+ end
3309
3832
  end
3310
3833
  end
3311
3834
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cddlc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler