tomlrb 2.0.1 → 2.0.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: 629b0c5e56e0d5978b6038fba1e1ac597cfd2932b6379fe84d09508defe7ce65
4
- data.tar.gz: 5a018444a9506276d874c43d3a2b9a234f54350fb732dd5ec5c4fac901917757
3
+ metadata.gz: 2a8a3589f6ef91d165e62d34308f5f1bf2ed585070b03656e269d80fdfbc4dd2
4
+ data.tar.gz: bb4cbc74b2c808bf4815de048cb276212fc6581ee0dc0eb0e59bb9160c8baf3e
5
5
  SHA512:
6
- metadata.gz: 8960f08241d02b8a36d600587d148d034a229588dbb96e4738aab0c30355def92bcbf4280da4ad9966e0e3a676aff01dd8faeb0c62f16c595c4bccc32c9d3e77
7
- data.tar.gz: 4e4179cbf1c9f88ff86ecbf15f23e2a964cd7cc3449bf420f7e8242aa125de08b7b0be9658c55d4a8c7d5c805654926144d0a30ed7d03b0d328fdb1db6a456b6
6
+ metadata.gz: 6d7e549ec02ad832a3e8a03f89825ee39b829ba810379feca4c9eee9171fec269f37fa3daad40af3ff5ed11d0024f3afda8796add4e2777a0d80a03098eb89fd
7
+ data.tar.gz: dca4a16c0e642797dae73d898bea0980d47f19800f832837e554b1a8291d3cb20fed6c164506a70aaa64dc8f36976ae1c5feb5381c975f3b54d35b2c4b6bd59e
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.5.1
3
+ # This file is automatically generated by Racc 1.6.0
4
4
  # from Racc grammar file "".
5
5
  #
6
6
 
@@ -10,94 +10,100 @@ module Tomlrb
10
10
  ##### State transition tables begin ###
11
11
 
12
12
  racc_action_table = [
13
- 2, 43, 16, 41, 17, 42, 18, 44, 45, 19,
14
- 20, 14, 21, 22, 8, 4, 10, 48, 49, 12,
15
- 23, 39, 69, 70, 71, 72, 67, 68, 64, 65,
16
- 62, 63, 66, 52, 36, 56, 46, 53, 12, 69,
17
- 70, 71, 72, 67, 68, 64, 65, 62, 63, 66,
18
- 84, 83, 56, 39, 75, 12, 69, 70, 71, 72,
19
- 67, 68, 64, 65, 62, 63, 66, 88, 80, 56,
20
- 86, 81, 12, 69, 70, 71, 72, 67, 68, 64,
21
- 65, 62, 63, 66, 88, 41, 56, 86, nil, 12,
22
- 69, 70, 71, 72, 67, 68, 64, 65, 62, 63,
23
- 66, 88, nil, 56, 86, nil, 12, 69, 70, 71,
24
- 72, 67, 68, 64, 65, 62, 63, 66, 88, nil,
25
- 56, 86, 29, 12, 30, nil, 31, nil, nil, 32,
26
- 33, 27, 34, 35, 29, nil, 30, 25, 31, nil,
27
- nil, 32, 33, 78, 34, 35, 16, nil, 17, 25,
28
- 18, nil, nil, 19, 20, 74, 21, 22, 93, nil,
29
- nil, 91, nil, nil, nil, 92 ]
13
+ 2, 45, 16, 56, 17, 44, 18, 55, 23, 19,
14
+ 20, 14, 21, 22, 8, 4, 10, 36, 16, 12,
15
+ 17, 48, 18, 46, 47, 19, 20, 42, 21, 22,
16
+ 50, 51, 87, 86, 39, 54, 39, 72, 73, 74,
17
+ 75, 70, 71, 67, 68, 65, 66, 69, 78, nil,
18
+ 59, nil, nil, 12, 72, 73, 74, 75, 70, 71,
19
+ 67, 68, 65, 66, 69, nil, nil, 59, nil, nil,
20
+ 12, 72, 73, 74, 75, 70, 71, 67, 68, 65,
21
+ 66, 69, 91, nil, 59, 89, nil, 12, 72, 73,
22
+ 74, 75, 70, 71, 67, 68, 65, 66, 69, 91,
23
+ nil, 59, 89, nil, 12, 72, 73, 74, 75, 70,
24
+ 71, 67, 68, 65, 66, 69, 91, nil, 59, 89,
25
+ nil, 12, 72, 73, 74, 75, 70, 71, 67, 68,
26
+ 65, 66, 69, 91, nil, 59, 89, 29, 12, 30,
27
+ nil, 31, nil, nil, 32, 33, 27, 34, 35, 29,
28
+ nil, 30, 25, 31, nil, nil, 32, 33, 81, 34,
29
+ 35, 16, nil, 17, 25, 18, nil, nil, 19, 20,
30
+ 77, 21, 22, 16, nil, 17, nil, 18, nil, nil,
31
+ 19, 20, 42, 21, 22, 16, nil, 17, nil, 18,
32
+ nil, nil, 19, 20, 85, 21, 22, 95, nil, nil,
33
+ 93, nil, nil, nil, 94 ]
30
34
 
31
35
  racc_action_check = [
32
- 1, 13, 1, 11, 1, 13, 1, 24, 24, 1,
33
- 1, 1, 1, 1, 1, 1, 1, 26, 26, 1,
34
- 2, 11, 42, 42, 42, 42, 42, 42, 42, 42,
35
- 42, 42, 42, 40, 10, 42, 25, 40, 42, 53,
36
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
37
- 54, 54, 53, 38, 48, 53, 55, 55, 55, 55,
38
- 55, 55, 55, 55, 55, 55, 55, 55, 51, 55,
39
- 55, 52, 55, 88, 88, 88, 88, 88, 88, 88,
40
- 88, 88, 88, 88, 88, 80, 88, 88, nil, 88,
41
- 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
42
- 92, 92, nil, 92, 92, nil, 92, 93, 93, 93,
43
- 93, 93, 93, 93, 93, 93, 93, 93, 93, nil,
44
- 93, 93, 9, 93, 9, nil, 9, nil, nil, 9,
45
- 9, 9, 9, 9, 49, nil, 49, 9, 49, nil,
46
- nil, 49, 49, 49, 49, 49, 43, nil, 43, 49,
47
- 43, nil, nil, 43, 43, 43, 43, 43, 87, nil,
48
- nil, 87, nil, nil, nil, 87 ]
36
+ 1, 13, 1, 41, 1, 13, 1, 41, 2, 1,
37
+ 1, 1, 1, 1, 1, 1, 1, 10, 11, 1,
38
+ 11, 25, 11, 24, 24, 11, 11, 11, 11, 11,
39
+ 26, 26, 57, 57, 38, 40, 11, 44, 44, 44,
40
+ 44, 44, 44, 44, 44, 44, 44, 44, 50, nil,
41
+ 44, nil, nil, 44, 55, 55, 55, 55, 55, 55,
42
+ 55, 55, 55, 55, 55, nil, nil, 55, nil, nil,
43
+ 55, 58, 58, 58, 58, 58, 58, 58, 58, 58,
44
+ 58, 58, 58, nil, 58, 58, nil, 58, 91, 91,
45
+ 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
46
+ nil, 91, 91, nil, 91, 94, 94, 94, 94, 94,
47
+ 94, 94, 94, 94, 94, 94, 94, nil, 94, 94,
48
+ nil, 94, 95, 95, 95, 95, 95, 95, 95, 95,
49
+ 95, 95, 95, 95, nil, 95, 95, 9, 95, 9,
50
+ nil, 9, nil, nil, 9, 9, 9, 9, 9, 51,
51
+ nil, 51, 9, 51, nil, nil, 51, 51, 51, 51,
52
+ 51, 45, nil, 45, 51, 45, nil, nil, 45, 45,
53
+ 45, 45, 45, 54, nil, 54, nil, 54, nil, nil,
54
+ 54, 54, 54, 54, 54, 56, nil, 56, nil, 56,
55
+ nil, nil, 56, 56, 56, 56, 56, 90, nil, nil,
56
+ 90, nil, nil, nil, 90 ]
49
57
 
50
58
  racc_action_pointer = [
51
- nil, 0, 20, nil, nil, nil, nil, nil, nil, 120,
52
- 18, 1, nil, -17, nil, nil, nil, nil, nil, nil,
53
- nil, nil, nil, nil, -7, 19, 0, nil, nil, nil,
54
- nil, nil, nil, nil, nil, nil, nil, nil, 33, nil,
55
- 15, nil, 19, 144, nil, nil, nil, nil, 37, 132,
56
- nil, 47, 69, 36, 36, 53, nil, nil, nil, nil,
59
+ nil, 0, 8, nil, nil, nil, nil, nil, nil, 135,
60
+ 1, 16, nil, -17, nil, nil, nil, nil, nil, nil,
61
+ nil, nil, nil, nil, 9, 4, 13, nil, nil, nil,
62
+ nil, nil, nil, nil, nil, nil, nil, nil, 14, nil,
63
+ 14, -15, nil, nil, 34, 159, nil, nil, nil, nil,
64
+ 31, 147, nil, nil, 171, 51, 183, 18, 68, nil,
57
65
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
58
66
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
59
- 83, nil, nil, nil, nil, nil, nil, 144, 70, nil,
60
- nil, nil, 87, 104, nil, nil, nil ]
67
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
68
+ 183, 85, nil, nil, 102, 119, nil, nil, nil ]
61
69
 
62
70
  racc_action_default = [
63
- -1, -77, -77, -2, -3, -4, -5, -6, -7, -77,
64
- -11, -77, -31, -77, -43, -44, -45, -46, -47, -48,
65
- -49, -50, -51, 97, -77, -13, -77, -20, -21, -22,
66
- -23, -24, -25, -26, -27, -28, -10, -29, -77, -32,
67
- -77, -37, -65, -77, -8, -9, -12, -14, -16, -77,
68
- -30, -33, -77, -65, -77, -65, -59, -60, -61, -62,
69
- -63, -64, -66, -67, -68, -69, -70, -71, -72, -73,
70
- -74, -75, -76, -41, -42, -15, -17, -18, -19, -34,
71
- -77, -36, -38, -39, -40, -52, -53, -77, -65, -35,
72
- -54, -56, -65, -65, -55, -57, -58 ]
71
+ -1, -79, -79, -2, -3, -4, -5, -6, -7, -79,
72
+ -11, -79, -31, -79, -45, -46, -47, -48, -49, -50,
73
+ -51, -52, -53, 99, -79, -13, -79, -20, -21, -22,
74
+ -23, -24, -25, -26, -27, -28, -10, -29, -79, -32,
75
+ -33, -79, -39, -40, -67, -79, -8, -9, -12, -14,
76
+ -16, -79, -30, -34, -79, -67, -79, -79, -67, -61,
77
+ -62, -63, -64, -65, -66, -68, -69, -70, -71, -72,
78
+ -73, -74, -75, -76, -77, -78, -43, -44, -15, -17,
79
+ -18, -19, -35, -36, -37, -38, -41, -42, -54, -55,
80
+ -79, -67, -56, -58, -67, -67, -57, -59, -60 ]
73
81
 
74
82
  racc_goto_table = [
75
- 38, 15, 24, 85, 28, 37, 54, 1, 3, 5,
76
- 6, 7, 9, 47, 51, 79, 13, 82, 90, nil,
77
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
78
- nil, nil, 50, nil, nil, nil, 94, nil, nil, nil,
79
- 95, 96, 76, 73, 77, nil, nil, nil, nil, nil,
83
+ 15, 24, 38, 88, 28, 37, 57, 1, 3, 5,
84
+ 6, 7, 9, 49, 53, 13, 92, 83, nil, nil,
80
85
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
81
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 89 ]
86
+ nil, nil, 52, nil, nil, nil, 96, nil, nil, 97,
87
+ 98, nil, nil, 79, 76, 82, 80, nil, nil, nil,
88
+ nil, nil, nil, nil, nil, 84 ]
82
89
 
83
90
  racc_goto_check = [
84
- 13, 19, 7, 22, 10, 12, 17, 1, 2, 3,
85
- 4, 5, 6, 9, 15, 16, 18, 17, 23, nil,
86
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
87
- nil, nil, 12, nil, nil, nil, 22, nil, nil, nil,
88
- 22, 22, 7, 19, 10, nil, nil, nil, nil, nil,
91
+ 18, 7, 13, 22, 10, 12, 17, 1, 2, 3,
92
+ 4, 5, 6, 9, 15, 19, 23, 17, nil, nil,
89
93
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
90
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 13 ]
94
+ nil, nil, 12, nil, nil, nil, 22, nil, nil, 22,
95
+ 22, nil, nil, 7, 18, 13, 10, nil, nil, nil,
96
+ nil, nil, nil, nil, nil, 18 ]
91
97
 
92
98
  racc_goto_pointer = [
93
- nil, 7, 7, 8, 9, 10, 11, -7, nil, -13,
94
- -5, nil, -6, -11, nil, -26, -36, -36, 15, 0,
95
- nil, nil, -52, -69, nil, nil, nil ]
99
+ nil, 7, 7, 8, 9, 10, 11, -8, nil, -13,
100
+ -5, nil, -6, -9, nil, -26, nil, -38, -1, 14,
101
+ nil, nil, -55, -74, nil, nil, nil ]
96
102
 
97
103
  racc_goto_default = [
98
- nil, nil, nil, nil, nil, 59, nil, nil, 26, nil,
99
- nil, 11, nil, nil, 40, nil, nil, 87, nil, nil,
100
- 58, 55, nil, nil, 57, 60, 61 ]
104
+ nil, nil, nil, nil, nil, 62, nil, nil, 26, nil,
105
+ nil, 11, nil, nil, 40, nil, 41, 90, 43, nil,
106
+ 61, 58, nil, nil, 60, 63, 64 ]
101
107
 
102
108
  racc_reduce_table = [
103
109
  0, 0, :racc_error,
@@ -123,7 +129,7 @@ racc_reduce_table = [
123
129
  1, 31, :_reduce_20,
124
130
  1, 31, :_reduce_21,
125
131
  1, 33, :_reduce_none,
126
- 1, 33, :_reduce_none,
132
+ 1, 33, :_reduce_23,
127
133
  1, 33, :_reduce_none,
128
134
  1, 33, :_reduce_none,
129
135
  1, 33, :_reduce_none,
@@ -133,54 +139,56 @@ racc_reduce_table = [
133
139
  3, 28, :_reduce_none,
134
140
  1, 34, :_reduce_31,
135
141
  1, 35, :_reduce_32,
142
+ 1, 36, :_reduce_none,
136
143
  2, 36, :_reduce_none,
137
- 3, 36, :_reduce_none,
138
- 2, 39, :_reduce_none,
139
- 3, 37, :_reduce_36,
140
- 1, 37, :_reduce_37,
141
144
  2, 38, :_reduce_none,
142
- 4, 27, :_reduce_39,
143
- 4, 27, :_reduce_40,
144
- 3, 41, :_reduce_41,
145
- 3, 41, :_reduce_42,
146
- 1, 41, :_reduce_43,
147
- 1, 41, :_reduce_44,
148
- 1, 42, :_reduce_none,
149
- 1, 42, :_reduce_none,
150
- 1, 42, :_reduce_none,
151
- 1, 42, :_reduce_none,
152
- 1, 42, :_reduce_none,
153
- 1, 42, :_reduce_none,
154
- 1, 42, :_reduce_none,
145
+ 3, 37, :_reduce_36,
146
+ 3, 39, :_reduce_37,
147
+ 3, 39, :_reduce_38,
148
+ 1, 39, :_reduce_39,
149
+ 1, 39, :_reduce_40,
150
+ 4, 27, :_reduce_41,
151
+ 4, 27, :_reduce_42,
152
+ 3, 42, :_reduce_43,
153
+ 3, 42, :_reduce_44,
154
+ 1, 42, :_reduce_45,
155
+ 1, 42, :_reduce_46,
156
+ 1, 41, :_reduce_none,
157
+ 1, 41, :_reduce_48,
158
+ 1, 41, :_reduce_none,
159
+ 1, 41, :_reduce_none,
160
+ 1, 41, :_reduce_none,
161
+ 1, 41, :_reduce_none,
162
+ 1, 41, :_reduce_none,
155
163
  2, 43, :_reduce_none,
156
- 1, 45, :_reduce_53,
164
+ 1, 45, :_reduce_55,
157
165
  2, 45, :_reduce_none,
158
166
  2, 45, :_reduce_none,
159
- 1, 46, :_reduce_56,
167
+ 1, 46, :_reduce_58,
160
168
  2, 46, :_reduce_none,
161
169
  2, 46, :_reduce_none,
162
- 1, 44, :_reduce_59,
163
- 1, 40, :_reduce_60,
170
+ 1, 44, :_reduce_61,
171
+ 1, 40, :_reduce_62,
164
172
  1, 40, :_reduce_none,
165
173
  1, 40, :_reduce_none,
166
174
  1, 47, :_reduce_none,
167
175
  1, 47, :_reduce_none,
168
176
  0, 49, :_reduce_none,
169
- 1, 49, :_reduce_66,
170
- 1, 49, :_reduce_67,
171
177
  1, 49, :_reduce_68,
172
178
  1, 49, :_reduce_69,
173
179
  1, 49, :_reduce_70,
174
180
  1, 49, :_reduce_71,
175
181
  1, 49, :_reduce_72,
176
- 1, 48, :_reduce_73,
177
- 1, 48, :_reduce_74,
182
+ 1, 49, :_reduce_73,
183
+ 1, 49, :_reduce_74,
178
184
  1, 48, :_reduce_75,
179
- 1, 48, :_reduce_76 ]
185
+ 1, 48, :_reduce_76,
186
+ 1, 48, :_reduce_77,
187
+ 1, 48, :_reduce_78 ]
180
188
 
181
- racc_reduce_n = 77
189
+ racc_reduce_n = 79
182
190
 
183
- racc_shift_n = 97
191
+ racc_shift_n = 99
184
192
 
185
193
  racc_token_table = {
186
194
  false => 0,
@@ -265,12 +273,12 @@ Racc_token_to_s_table = [
265
273
  "inline_table_start",
266
274
  "inline_table_end",
267
275
  "inline_continued",
268
- "inline_assignment_key",
269
- "inline_assignment_value",
276
+ "inline_assignment",
270
277
  "inline_next",
278
+ "inline_assignment_key",
271
279
  "value",
272
- "assignment_key",
273
280
  "assignment_key_component",
281
+ "assignment_key",
274
282
  "array",
275
283
  "start_array",
276
284
  "array_continued",
@@ -382,7 +390,12 @@ module_eval(<<'.,.,', 'parser.y', 39)
382
390
 
383
391
  # reduce 22 omitted
384
392
 
385
- # reduce 23 omitted
393
+ module_eval(<<'.,.,', 'parser.y', 43)
394
+ def _reduce_23(val, _values, result)
395
+ result = StringUtils.replace_escaped_chars(val[0])
396
+ result
397
+ end
398
+ .,.,
386
399
 
387
400
  # reduce 24 omitted
388
401
 
@@ -408,8 +421,7 @@ module_eval(<<'.,.,', 'parser.y', 55)
408
421
  module_eval(<<'.,.,', 'parser.y', 59)
409
422
  def _reduce_32(val, _values, result)
410
423
  array = @handler.end_(:inline)
411
- array.map!.with_index{ |n,i| i.even? ? n.to_sym : n } if @handler.symbolize_keys
412
- @handler.push(Hash[*array])
424
+ @handler.push_inline(array)
413
425
 
414
426
  result
415
427
  end
@@ -421,12 +433,10 @@ module_eval(<<'.,.,', 'parser.y', 59)
421
433
 
422
434
  # reduce 35 omitted
423
435
 
424
- module_eval(<<'.,.,', 'parser.y', 73)
436
+ module_eval(<<'.,.,', 'parser.y', 72)
425
437
  def _reduce_36(val, _values, result)
426
- array = @handler.end_(:inline)
427
- array.each { |key| @handler.push(key) }
428
- @handler.start_(:inline)
429
- @handler.push(val[2])
438
+ keys = @handler.end_(:inline_keys)
439
+ @handler.push(keys)
430
440
 
431
441
  result
432
442
  end
@@ -434,49 +444,78 @@ module_eval(<<'.,.,', 'parser.y', 73)
434
444
 
435
445
  module_eval(<<'.,.,', 'parser.y', 78)
436
446
  def _reduce_37(val, _values, result)
437
- @handler.push(val[0])
447
+ @handler.push(val[2])
448
+
438
449
  result
439
450
  end
440
451
  .,.,
441
452
 
442
- # reduce 38 omitted
453
+ module_eval(<<'.,.,', 'parser.y', 80)
454
+ def _reduce_38(val, _values, result)
455
+ val[2].split('.').each { |k| @handler.push(k) }
456
+ result
457
+ end
458
+ .,.,
443
459
 
444
- module_eval(<<'.,.,', 'parser.y', 85)
460
+ module_eval(<<'.,.,', 'parser.y', 82)
445
461
  def _reduce_39(val, _values, result)
462
+ keys = val[0].split('.')
463
+ @handler.start_(:inline_keys)
464
+ keys.each { |key| @handler.push(key) }
465
+
466
+ result
467
+ end
468
+ .,.,
469
+
470
+ module_eval(<<'.,.,', 'parser.y', 87)
471
+ def _reduce_40(val, _values, result)
472
+ @handler.start_(:inline_keys)
473
+ @handler.push(val[0])
474
+
475
+ result
476
+ end
477
+ .,.,
478
+
479
+ module_eval(<<'.,.,', 'parser.y', 93)
480
+ def _reduce_41(val, _values, result)
446
481
  keys = @handler.end_(:keys)
447
- @handler.push(keys.pop)
482
+ value = keys.pop
483
+ @handler.validate_value(value)
484
+ @handler.push(value)
448
485
  @handler.assign(keys)
449
486
 
450
487
  result
451
488
  end
452
489
  .,.,
453
490
 
454
- module_eval(<<'.,.,', 'parser.y', 90)
455
- def _reduce_40(val, _values, result)
491
+ module_eval(<<'.,.,', 'parser.y', 100)
492
+ def _reduce_42(val, _values, result)
456
493
  keys = @handler.end_(:keys)
457
- @handler.push(keys.pop)
494
+ value = keys.pop
495
+ @handler.validate_value(value)
496
+ @handler.push(value)
458
497
  @handler.assign(keys)
459
498
 
460
499
  result
461
500
  end
462
501
  .,.,
463
502
 
464
- module_eval(<<'.,.,', 'parser.y', 96)
465
- def _reduce_41(val, _values, result)
503
+ module_eval(<<'.,.,', 'parser.y', 108)
504
+ def _reduce_43(val, _values, result)
466
505
  @handler.push(val[2])
467
506
  result
468
507
  end
469
508
  .,.,
470
509
 
471
- module_eval(<<'.,.,', 'parser.y', 97)
472
- def _reduce_42(val, _values, result)
510
+ module_eval(<<'.,.,', 'parser.y', 109)
511
+ def _reduce_44(val, _values, result)
473
512
  val[2].split('.').each { |k| @handler.push(k) }
474
513
  result
475
514
  end
476
515
  .,.,
477
516
 
478
- module_eval(<<'.,.,', 'parser.y', 99)
479
- def _reduce_43(val, _values, result)
517
+ module_eval(<<'.,.,', 'parser.y', 111)
518
+ def _reduce_45(val, _values, result)
480
519
  keys = val[0].split('.')
481
520
  @handler.start_(:keys)
482
521
  keys.each { |key| @handler.push(key) }
@@ -485,20 +524,21 @@ module_eval(<<'.,.,', 'parser.y', 99)
485
524
  end
486
525
  .,.,
487
526
 
488
- module_eval(<<'.,.,', 'parser.y', 103)
489
- def _reduce_44(val, _values, result)
527
+ module_eval(<<'.,.,', 'parser.y', 115)
528
+ def _reduce_46(val, _values, result)
490
529
  @handler.start_(:keys); @handler.push(val[0])
491
530
  result
492
531
  end
493
532
  .,.,
494
533
 
495
- # reduce 45 omitted
496
-
497
- # reduce 46 omitted
498
-
499
534
  # reduce 47 omitted
500
535
 
501
- # reduce 48 omitted
536
+ module_eval(<<'.,.,', 'parser.y', 119)
537
+ def _reduce_48(val, _values, result)
538
+ result = StringUtils.replace_escaped_chars(val[0])
539
+ result
540
+ end
541
+ .,.,
502
542
 
503
543
  # reduce 49 omitted
504
544
 
@@ -508,61 +548,65 @@ module_eval(<<'.,.,', 'parser.y', 103)
508
548
 
509
549
  # reduce 52 omitted
510
550
 
511
- module_eval(<<'.,.,', 'parser.y', 118)
512
- def _reduce_53(val, _values, result)
513
- array = @handler.end_(:array); @handler.push(array)
551
+ # reduce 53 omitted
552
+
553
+ # reduce 54 omitted
554
+
555
+ module_eval(<<'.,.,', 'parser.y', 130)
556
+ def _reduce_55(val, _values, result)
557
+ array = @handler.end_(:array); @handler.push(array.compact)
514
558
  result
515
559
  end
516
560
  .,.,
517
561
 
518
- # reduce 54 omitted
562
+ # reduce 56 omitted
519
563
 
520
- # reduce 55 omitted
564
+ # reduce 57 omitted
521
565
 
522
- module_eval(<<'.,.,', 'parser.y', 123)
523
- def _reduce_56(val, _values, result)
524
- array = @handler.end_(:array); @handler.push(array)
566
+ module_eval(<<'.,.,', 'parser.y', 135)
567
+ def _reduce_58(val, _values, result)
568
+ array = @handler.end_(:array); @handler.push(array.compact)
525
569
  result
526
570
  end
527
571
  .,.,
528
572
 
529
- # reduce 57 omitted
573
+ # reduce 59 omitted
530
574
 
531
- # reduce 58 omitted
575
+ # reduce 60 omitted
532
576
 
533
- module_eval(<<'.,.,', 'parser.y', 128)
534
- def _reduce_59(val, _values, result)
577
+ module_eval(<<'.,.,', 'parser.y', 140)
578
+ def _reduce_61(val, _values, result)
535
579
  @handler.start_(:array)
536
580
  result
537
581
  end
538
582
  .,.,
539
583
 
540
- module_eval(<<'.,.,', 'parser.y', 131)
541
- def _reduce_60(val, _values, result)
584
+ module_eval(<<'.,.,', 'parser.y', 143)
585
+ def _reduce_62(val, _values, result)
542
586
  @handler.push(val[0])
543
587
  result
544
588
  end
545
589
  .,.,
546
590
 
547
- # reduce 61 omitted
548
-
549
- # reduce 62 omitted
550
-
551
591
  # reduce 63 omitted
552
592
 
553
593
  # reduce 64 omitted
554
594
 
555
595
  # reduce 65 omitted
556
596
 
557
- module_eval(<<'.,.,', 'parser.y', 140)
558
- def _reduce_66(val, _values, result)
597
+ # reduce 66 omitted
598
+
599
+ # reduce 67 omitted
600
+
601
+ module_eval(<<'.,.,', 'parser.y', 152)
602
+ def _reduce_68(val, _values, result)
559
603
  result = val[0].to_f
560
604
  result
561
605
  end
562
606
  .,.,
563
607
 
564
- module_eval(<<'.,.,', 'parser.y', 142)
565
- def _reduce_67(val, _values, result)
608
+ module_eval(<<'.,.,', 'parser.y', 154)
609
+ def _reduce_69(val, _values, result)
566
610
  v = val[0]
567
611
  result = if v.end_with?('nan')
568
612
  Float::NAN
@@ -574,15 +618,15 @@ module_eval(<<'.,.,', 'parser.y', 142)
574
618
  end
575
619
  .,.,
576
620
 
577
- module_eval(<<'.,.,', 'parser.y', 149)
578
- def _reduce_68(val, _values, result)
621
+ module_eval(<<'.,.,', 'parser.y', 161)
622
+ def _reduce_70(val, _values, result)
579
623
  result = val[0].to_i
580
624
  result
581
625
  end
582
626
  .,.,
583
627
 
584
- module_eval(<<'.,.,', 'parser.y', 151)
585
- def _reduce_69(val, _values, result)
628
+ module_eval(<<'.,.,', 'parser.y', 163)
629
+ def _reduce_71(val, _values, result)
586
630
  base = case val[0][1]
587
631
  when "x" then 16
588
632
  when "o" then 8
@@ -594,15 +638,15 @@ module_eval(<<'.,.,', 'parser.y', 151)
594
638
  end
595
639
  .,.,
596
640
 
597
- module_eval(<<'.,.,', 'parser.y', 158)
598
- def _reduce_70(val, _values, result)
641
+ module_eval(<<'.,.,', 'parser.y', 170)
642
+ def _reduce_72(val, _values, result)
599
643
  result = val[0] == 'true' ? true : false
600
644
  result
601
645
  end
602
646
  .,.,
603
647
 
604
- module_eval(<<'.,.,', 'parser.y', 160)
605
- def _reduce_71(val, _values, result)
648
+ module_eval(<<'.,.,', 'parser.y', 172)
649
+ def _reduce_73(val, _values, result)
606
650
  v = val[0]
607
651
  result = if v[6].nil?
608
652
  if v[4].nil?
@@ -611,6 +655,11 @@ module_eval(<<'.,.,', 'parser.y', 160)
611
655
  LocalDateTime.new(v[0], v[1], v[2], v[3] || 0, v[4] || 0, v[5].to_f)
612
656
  end
613
657
  else
658
+ # Patch for 24:00:00 which Ruby parses
659
+ if v[3].to_i == 24 && v[4].to_i == 0 && v[5].to_i == 0
660
+ v[3] = (v[3].to_i + 1).to_s
661
+ end
662
+
614
663
  Time.new(v[0], v[1], v[2], v[3] || 0, v[4] || 0, v[5].to_f, v[6])
615
664
  end
616
665
 
@@ -618,36 +667,36 @@ module_eval(<<'.,.,', 'parser.y', 160)
618
667
  end
619
668
  .,.,
620
669
 
621
- module_eval(<<'.,.,', 'parser.y', 171)
622
- def _reduce_72(val, _values, result)
670
+ module_eval(<<'.,.,', 'parser.y', 188)
671
+ def _reduce_74(val, _values, result)
623
672
  result = LocalTime.new(*val[0])
624
673
  result
625
674
  end
626
675
  .,.,
627
676
 
628
- module_eval(<<'.,.,', 'parser.y', 174)
629
- def _reduce_73(val, _values, result)
677
+ module_eval(<<'.,.,', 'parser.y', 191)
678
+ def _reduce_75(val, _values, result)
630
679
  result = StringUtils.replace_escaped_chars(StringUtils.multiline_replacements(val[0]))
631
680
  result
632
681
  end
633
682
  .,.,
634
683
 
635
- module_eval(<<'.,.,', 'parser.y', 175)
636
- def _reduce_74(val, _values, result)
684
+ module_eval(<<'.,.,', 'parser.y', 192)
685
+ def _reduce_76(val, _values, result)
637
686
  result = StringUtils.replace_escaped_chars(val[0])
638
687
  result
639
688
  end
640
689
  .,.,
641
690
 
642
- module_eval(<<'.,.,', 'parser.y', 176)
643
- def _reduce_75(val, _values, result)
691
+ module_eval(<<'.,.,', 'parser.y', 193)
692
+ def _reduce_77(val, _values, result)
644
693
  result = StringUtils.strip_spaces(val[0])
645
694
  result
646
695
  end
647
696
  .,.,
648
697
 
649
- module_eval(<<'.,.,', 'parser.y', 177)
650
- def _reduce_76(val, _values, result)
698
+ module_eval(<<'.,.,', 'parser.y', 194)
699
+ def _reduce_78(val, _values, result)
651
700
  result = val[0]
652
701
  result
653
702
  end
@@ -13,6 +13,10 @@ module Tomlrb
13
13
  end
14
14
 
15
15
  def set_context(identifiers, is_array_of_tables: false)
16
+ if identifiers.empty?
17
+ raise ParseError, 'Array needs a name'
18
+ end
19
+
16
20
  @current_table = identifiers.dup
17
21
  @keys.add_table_key identifiers, is_array_of_tables
18
22
  @current = @output
@@ -21,7 +25,6 @@ module Tomlrb
21
25
  identifierz.each do |k|
22
26
  k = k.to_sym if @symbolize_keys
23
27
  if @current[k].is_a?(Array)
24
- @current[k] << {} if @current[k].empty?
25
28
  @current = @current[k].last
26
29
  else
27
30
  @current[k] ||= {}
@@ -32,7 +35,6 @@ module Tomlrb
32
35
  end
33
36
 
34
37
  def deal_with_array_of_tables(identifiers, is_array_of_tables)
35
- identifiers.map!{|n| n.gsub("\"", '')}
36
38
  stringified_identifier = identifiers.join('.')
37
39
 
38
40
  if is_array_of_tables
@@ -66,6 +68,31 @@ module Tomlrb
66
68
  @stack << o
67
69
  end
68
70
 
71
+ def push_inline(inline_arrays)
72
+ merged_inline = {}
73
+
74
+ inline_arrays.each do |inline_array|
75
+ current = merged_inline
76
+ value = inline_array.pop
77
+ inline_array.each_with_index do |inline_key, inline_index|
78
+ last_key = inline_index == inline_array.size - 1
79
+
80
+ if last_key
81
+ if current[inline_key].nil?
82
+ current[inline_key] = value
83
+ else
84
+ raise Key::KeyConflict, "Inline key #{inline_key} is already used"
85
+ end
86
+ else
87
+ current[inline_key] ||= {}
88
+ current = current[inline_key]
89
+ end
90
+ end
91
+ end
92
+
93
+ push(merged_inline)
94
+ end
95
+
69
96
  def start_(type)
70
97
  push([type])
71
98
  end
@@ -73,16 +100,23 @@ module Tomlrb
73
100
  def end_(type)
74
101
  array = []
75
102
  while (value = @stack.pop) != [type]
76
- raise ParseError, 'Unclosed table' if value.nil?
103
+ raise ParseError, 'Unclosed table' if @stack.empty?
77
104
  array.unshift(value)
78
105
  end
79
106
  array
80
107
  end
81
108
 
109
+ def validate_value(value)
110
+ if value.nil?
111
+ raise ParseError, 'Value must be present'
112
+ end
113
+ end
114
+
82
115
  private
83
116
 
84
117
  def assign_key_path(current, key, key_emptied)
85
118
  if key_emptied
119
+
86
120
  raise ParseError, "Cannot overwrite value with key #{key}" unless current.kind_of?(Hash)
87
121
  current[key] = @stack.pop
88
122
  return current
@@ -156,7 +190,7 @@ module Tomlrb
156
190
 
157
191
  def find_or_create_first_pair_key(current, key, declared, table_keys_empty)
158
192
  existed = current[key]
159
- if existed && existed.declared? && (existed.type == :pair) && declared && table_keys_empty
193
+ if existed && (existed.type == :pair) && declared && table_keys_empty
160
194
  raise Key::KeyConflict, "Key #{key} is already used"
161
195
  end
162
196
  k = Key.new(key, :pair, declared)
@@ -199,7 +233,7 @@ module Tomlrb
199
233
  private
200
234
 
201
235
  def validate_already_declared_as_different_key(type, declared, existed)
202
- if declared && existed && existed.declared? && existed.type != type
236
+ if existed && existed.declared? && existed.type != type
203
237
  raise KeyConflict, "Key #{existed.key} is already used as #{existed.type} key"
204
238
  end
205
239
  end
data/lib/tomlrb/parser.y CHANGED
@@ -41,7 +41,7 @@ rule
41
41
  ;
42
42
  table_identifier_component
43
43
  : IDENTIFIER
44
- | STRING_BASIC
44
+ | STRING_BASIC { result = StringUtils.replace_escaped_chars(val[0]) }
45
45
  | STRING_LITERAL
46
46
  | INTEGER
47
47
  | NON_DEC_INTEGER
@@ -58,38 +58,50 @@ rule
58
58
  inline_table_end
59
59
  : '}' {
60
60
  array = @handler.end_(:inline)
61
- array.map!.with_index{ |n,i| i.even? ? n.to_sym : n } if @handler.symbolize_keys
62
- @handler.push(Hash[*array])
61
+ @handler.push_inline(array)
63
62
  }
64
63
  ;
65
64
  inline_continued
66
- : inline_assignment_key inline_assignment_value
67
- | inline_assignment_key inline_assignment_value inline_next
65
+ : inline_assignment
66
+ | inline_assignment inline_next
68
67
  ;
69
68
  inline_next
70
69
  : ',' inline_continued
71
70
  ;
72
- inline_assignment_key
73
- : inline_assignment_key '.' IDENTIFIER {
74
- array = @handler.end_(:inline)
75
- array.each { |key| @handler.push(key) }
76
- @handler.start_(:inline)
77
- @handler.push(val[2])
71
+ inline_assignment
72
+ : inline_assignment_key '=' value {
73
+ keys = @handler.end_(:inline_keys)
74
+ @handler.push(keys)
78
75
  }
79
- | IDENTIFIER { @handler.push(val[0]) }
80
76
  ;
81
- inline_assignment_value
82
- : '=' value
77
+ inline_assignment_key
78
+ : inline_assignment_key '.' assignment_key_component {
79
+ @handler.push(val[2])
80
+ }
81
+ | inline_assignment_key '.' FLOAT { val[2].split('.').each { |k| @handler.push(k) } }
82
+ | FLOAT {
83
+ keys = val[0].split('.')
84
+ @handler.start_(:inline_keys)
85
+ keys.each { |key| @handler.push(key) }
86
+ }
87
+ | assignment_key_component {
88
+ @handler.start_(:inline_keys)
89
+ @handler.push(val[0])
90
+ }
83
91
  ;
84
92
  assignment
85
93
  : assignment_key '=' value EOS {
86
94
  keys = @handler.end_(:keys)
87
- @handler.push(keys.pop)
95
+ value = keys.pop
96
+ @handler.validate_value(value)
97
+ @handler.push(value)
88
98
  @handler.assign(keys)
89
99
  }
90
100
  | assignment_key '=' value NEWLINE {
91
101
  keys = @handler.end_(:keys)
92
- @handler.push(keys.pop)
102
+ value = keys.pop
103
+ @handler.validate_value(value)
104
+ @handler.push(value)
93
105
  @handler.assign(keys)
94
106
  }
95
107
  ;
@@ -105,7 +117,7 @@ rule
105
117
  ;
106
118
  assignment_key_component
107
119
  : IDENTIFIER
108
- | STRING_BASIC
120
+ | STRING_BASIC { result = StringUtils.replace_escaped_chars(val[0]) }
109
121
  | STRING_LITERAL
110
122
  | INTEGER
111
123
  | NON_DEC_INTEGER
@@ -116,12 +128,12 @@ rule
116
128
  : start_array array_continued
117
129
  ;
118
130
  array_continued
119
- : ']' { array = @handler.end_(:array); @handler.push(array) }
131
+ : ']' { array = @handler.end_(:array); @handler.push(array.compact) }
120
132
  | value array_next
121
133
  | NEWLINE array_continued
122
134
  ;
123
135
  array_next
124
- : ']' { array = @handler.end_(:array); @handler.push(array) }
136
+ : ']' { array = @handler.end_(:array); @handler.push(array.compact) }
125
137
  | ',' array_continued
126
138
  | NEWLINE array_continued
127
139
  ;
@@ -166,6 +178,11 @@ rule
166
178
  LocalDateTime.new(v[0], v[1], v[2], v[3] || 0, v[4] || 0, v[5].to_f)
167
179
  end
168
180
  else
181
+ # Patch for 24:00:00 which Ruby parses
182
+ if v[3].to_i == 24 && v[4].to_i == 0 && v[5].to_i == 0
183
+ v[3] = (v[3].to_i + 1).to_s
184
+ end
185
+
169
186
  Time.new(v[0], v[1], v[2], v[3] || 0, v[4] || 0, v[5].to_f, v[6])
170
187
  end
171
188
  }
@@ -12,11 +12,14 @@ module Tomlrb
12
12
  STRING_LITERAL_MULTI = /'{3}([^\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]*?'{3,5})/m
13
13
  DATETIME = /(-?\d{4})-(\d{2})-(\d{2})(?:(?:t|\s)(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?))?(z|[-+]\d{2}:\d{2})?/i
14
14
  LOCAL_TIME = /(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?)/
15
- FLOAT = /[+-]?(?:(?:\d|[1-9](?:_?\d)*)\.\d(?:_?\d)*|\d+(?=[eE]))(?:[eE][+-]?[0-9_]+)?(?!\w)/
15
+ FLOAT = /[+-]?(?:(?:\d|[1-9](?:_?\d)*)\.\d(?:_?\d)*|\d+(?=[eE]))(?:[eE][+-]?[0-9]+(_[0-9])*[0-9]*)?(?!\w)/
16
16
  FLOAT_KEYWORD = /[+-]?(?:inf|nan)\b/
17
17
  INTEGER = /[+-]?([1-9](_?\d)*|0)(?![A-Za-z0-9_-]+)/
18
- NON_DEC_INTEGER = /0(?:x[0-9A-Fa-f][0-9A-Fa-f_]*|o[0-7][0-7_]*|b[01][01_]*)/
18
+ NON_DEC_INTEGER = /0(?:x[0-9A-Fa-f]+(?:_[0-9A-Fa-f])*[0-9A-Fa-f]*|o[0-7]+(?:_[0-7])*[0-7]*|b[01]+(?:_[01])*[01]*)/
19
19
  BOOLEAN = /true|false/
20
+ SPACED_ARRAY_OF_TABLES_START = /^\[[ \t]+\[(#{IDENTIFIER}|#{STRING_BASIC}|#{STRING_LITERAL}|#{INTEGER}|#{NON_DEC_INTEGER}|#{FLOAT_KEYWORD}|#{BOOLEAN})\]\]$/
21
+ SPACED_ARRAY_OF_TABLES_END = /^\[\[(#{IDENTIFIER}|#{STRING_BASIC}|#{STRING_LITERAL}|#{INTEGER}|#{NON_DEC_INTEGER}|#{FLOAT_KEYWORD}|#{BOOLEAN})\][ \t]+\]$/
22
+ SPACED_ARRAY_OF_TABLES_BOTH = /^\[[ \t]+\[(#{IDENTIFIER}|#{STRING_BASIC}|#{STRING_LITERAL}|#{INTEGER}|#{NON_DEC_INTEGER}|#{FLOAT_KEYWORD}|#{BOOLEAN})\][ \t]+\]$/
20
23
 
21
24
  def initialize(io)
22
25
  @ss = StringScanner.new(io.read)
@@ -26,6 +29,9 @@ module Tomlrb
26
29
  def next_token
27
30
  case
28
31
  when @ss.scan(NEWLINE) then [:NEWLINE, nil]
32
+ when @ss.scan(SPACED_ARRAY_OF_TABLES_START) then raise ParseError.new("Array of tables has spaces in starting brackets")
33
+ when @ss.scan(SPACED_ARRAY_OF_TABLES_END) then raise ParseError.new("Array of tables has spaces in ending brackets")
34
+ when @ss.scan(SPACED_ARRAY_OF_TABLES_BOTH) then raise ParseError.new("Array of tables has spaces in starting and ending brackets")
29
35
  when @ss.scan(SPACE) then next_token
30
36
  when @ss.scan(COMMENT) then next_token
31
37
  when @ss.scan(DATETIME) then process_datetime
@@ -47,7 +53,7 @@ module Tomlrb
47
53
 
48
54
  def process_datetime
49
55
  if @ss[7]
50
- offset = @ss[7].gsub('Z', '+00:00')
56
+ offset = @ss[7].gsub(/[zZ]/, '+00:00')
51
57
  end
52
58
  args = [@ss[1], @ss[2], @ss[3], @ss[4], @ss[5], @ss[6], offset]
53
59
  [:DATETIME, args]
@@ -1,3 +1,3 @@
1
1
  module Tomlrb
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomlrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francois Bernier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-20 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: psych
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
13
27
  description: A racc based toml parser
14
28
  email:
15
29
  - frankbernier@gmail.com
@@ -48,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
62
  - !ruby/object:Gem::Version
49
63
  version: '0'
50
64
  requirements: []
51
- rubygems_version: 3.1.4
65
+ rubygems_version: 3.3.7
52
66
  signing_key:
53
67
  specification_version: 4
54
68
  summary: A racc based toml parser