tomlrb 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tomlrb/generated_parser.rb +279 -365
- data/lib/tomlrb/handler.rb +5 -0
- data/lib/tomlrb/local_date.rb +1 -1
- data/lib/tomlrb/local_date_time.rb +1 -1
- data/lib/tomlrb/local_time.rb +1 -1
- data/lib/tomlrb/parser.y +38 -27
- data/lib/tomlrb/scanner.rb +12 -36
- data/lib/tomlrb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 629b0c5e56e0d5978b6038fba1e1ac597cfd2932b6379fe84d09508defe7ce65
|
4
|
+
data.tar.gz: 5a018444a9506276d874c43d3a2b9a234f54350fb732dd5ec5c4fac901917757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8960f08241d02b8a36d600587d148d034a229588dbb96e4738aab0c30355def92bcbf4280da4ad9966e0e3a676aff01dd8faeb0c62f16c595c4bccc32c9d3e77
|
7
|
+
data.tar.gz: 4e4179cbf1c9f88ff86ecbf15f23e2a964cd7cc3449bf420f7e8242aa125de08b7b0be9658c55d4a8c7d5c805654926144d0a30ed7d03b0d328fdb1db6a456b6
|
@@ -10,215 +10,177 @@ module Tomlrb
|
|
10
10
|
##### State transition tables begin ###
|
11
11
|
|
12
12
|
racc_action_table = [
|
13
|
-
2,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
77, 78, 79, 80, 71, 72, 73, 74, 68, 69,
|
31
|
-
70, 75, 76, 100, nil, 62, 98, 33, 12, 34,
|
32
|
-
nil, 35, nil, nil, nil, nil, 36, 37, 38, 39,
|
33
|
-
31, 40, 41, 42, 43, 33, nil, 34, 29, 35,
|
34
|
-
nil, nil, nil, nil, 36, 37, 38, 39, 90, 40,
|
35
|
-
41, 42, 43, 16, nil, 17, 29, 18, nil, nil,
|
36
|
-
nil, nil, 19, 20, 21, 22, 86, 23, 24, 25,
|
37
|
-
26, 105, nil, nil, 103, nil, nil, nil, 104 ]
|
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 ]
|
38
30
|
|
39
31
|
racc_action_check = [
|
40
|
-
1, 13, 1, 11, 1, 13, 1,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
|
58
|
-
107, 107, 107, 107, nil, 107, 107, 9, 107, 9,
|
59
|
-
nil, 9, nil, nil, nil, nil, 9, 9, 9, 9,
|
60
|
-
9, 9, 9, 9, 9, 55, nil, 55, 9, 55,
|
61
|
-
nil, nil, nil, nil, 55, 55, 55, 55, 55, 55,
|
62
|
-
55, 55, 55, 51, nil, 51, 55, 51, nil, nil,
|
63
|
-
nil, nil, 51, 51, 51, 51, 51, 51, 51, 51,
|
64
|
-
51, 99, nil, nil, 99, nil, nil, nil, 99 ]
|
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 ]
|
65
49
|
|
66
50
|
racc_action_pointer = [
|
67
|
-
nil, 0,
|
68
|
-
|
69
|
-
nil, nil, nil, nil,
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
-11, 71, nil, nil, nil, nil, nil, nil, nil, nil,
|
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,
|
74
57
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
75
58
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
76
|
-
nil, nil,
|
77
|
-
|
78
|
-
nil ]
|
59
|
+
83, nil, nil, nil, nil, nil, nil, 144, 70, nil,
|
60
|
+
nil, nil, 87, 104, nil, nil, nil ]
|
79
61
|
|
80
62
|
racc_action_default = [
|
81
|
-
-1, -
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-73, -38, -61, -63, -73, -73, -62, -73, -64, -65,
|
92
|
-
-62 ]
|
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 ]
|
93
73
|
|
94
74
|
racc_goto_table = [
|
95
|
-
|
96
|
-
7,
|
75
|
+
38, 15, 24, 85, 28, 37, 54, 1, 3, 5,
|
76
|
+
6, 7, 9, 47, 51, 79, 13, 82, 90, nil,
|
97
77
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
98
|
-
nil, nil,
|
99
|
-
|
100
|
-
106, 85, nil, nil, 108, 109, nil, 110, nil, nil,
|
78
|
+
nil, nil, 50, nil, nil, nil, 94, nil, nil, nil,
|
79
|
+
95, 96, 76, 73, 77, nil, nil, nil, nil, nil,
|
101
80
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
102
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
103
|
-
nil, 101 ]
|
81
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 89 ]
|
104
82
|
|
105
83
|
racc_goto_check = [
|
106
|
-
13, 19, 7, 10, 12, 17, 1, 2, 3,
|
107
|
-
5,
|
108
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
109
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil, 12,
|
110
|
-
nil, nil, nil, nil, nil, nil, nil, nil, 7, 10,
|
111
|
-
22, 19, nil, nil, 22, 22, nil, 22, nil, nil,
|
84
|
+
13, 19, 7, 22, 10, 12, 17, 1, 2, 3,
|
85
|
+
4, 5, 6, 9, 15, 16, 18, 17, 23, nil,
|
112
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,
|
113
89
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
114
|
-
nil, 13 ]
|
90
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 13 ]
|
115
91
|
|
116
92
|
racc_goto_pointer = [
|
117
|
-
nil,
|
118
|
-
-
|
119
|
-
nil, nil, -
|
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 ]
|
120
96
|
|
121
97
|
racc_goto_default = [
|
122
|
-
nil, nil, nil, nil, nil,
|
123
|
-
nil, 11, nil, nil,
|
124
|
-
|
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 ]
|
125
101
|
|
126
102
|
racc_reduce_table = [
|
127
103
|
0, 0, :racc_error,
|
128
|
-
0,
|
104
|
+
0, 24, :_reduce_none,
|
105
|
+
2, 24, :_reduce_none,
|
106
|
+
2, 24, :_reduce_none,
|
107
|
+
1, 25, :_reduce_none,
|
108
|
+
1, 25, :_reduce_none,
|
109
|
+
1, 25, :_reduce_none,
|
110
|
+
1, 25, :_reduce_none,
|
111
|
+
3, 26, :_reduce_none,
|
112
|
+
3, 26, :_reduce_none,
|
113
|
+
2, 29, :_reduce_10,
|
114
|
+
1, 29, :_reduce_11,
|
115
|
+
2, 30, :_reduce_12,
|
116
|
+
1, 30, :_reduce_13,
|
129
117
|
2, 30, :_reduce_none,
|
130
|
-
2,
|
131
|
-
1,
|
132
|
-
1, 31, :_reduce_none,
|
133
|
-
1, 31, :_reduce_none,
|
134
|
-
1, 31, :_reduce_none,
|
118
|
+
2, 32, :_reduce_15,
|
119
|
+
1, 32, :_reduce_16,
|
135
120
|
2, 32, :_reduce_none,
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
1,
|
121
|
+
3, 31, :_reduce_18,
|
122
|
+
3, 31, :_reduce_19,
|
123
|
+
1, 31, :_reduce_20,
|
124
|
+
1, 31, :_reduce_21,
|
125
|
+
1, 33, :_reduce_none,
|
126
|
+
1, 33, :_reduce_none,
|
127
|
+
1, 33, :_reduce_none,
|
128
|
+
1, 33, :_reduce_none,
|
129
|
+
1, 33, :_reduce_none,
|
130
|
+
1, 33, :_reduce_none,
|
131
|
+
1, 33, :_reduce_none,
|
132
|
+
2, 28, :_reduce_none,
|
133
|
+
3, 28, :_reduce_none,
|
134
|
+
1, 34, :_reduce_31,
|
135
|
+
1, 35, :_reduce_32,
|
140
136
|
2, 36, :_reduce_none,
|
141
|
-
|
142
|
-
|
137
|
+
3, 36, :_reduce_none,
|
138
|
+
2, 39, :_reduce_none,
|
139
|
+
3, 37, :_reduce_36,
|
140
|
+
1, 37, :_reduce_37,
|
143
141
|
2, 38, :_reduce_none,
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
1,
|
149
|
-
1,
|
150
|
-
1,
|
151
|
-
1,
|
152
|
-
1,
|
153
|
-
1,
|
154
|
-
1,
|
155
|
-
1,
|
156
|
-
1,
|
157
|
-
|
158
|
-
1,
|
159
|
-
2,
|
160
|
-
3, 34, :_reduce_none,
|
161
|
-
1, 40, :_reduce_34,
|
162
|
-
1, 41, :_reduce_35,
|
163
|
-
2, 42, :_reduce_none,
|
164
|
-
3, 42, :_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,
|
155
|
+
2, 43, :_reduce_none,
|
156
|
+
1, 45, :_reduce_53,
|
157
|
+
2, 45, :_reduce_none,
|
165
158
|
2, 45, :_reduce_none,
|
166
|
-
|
167
|
-
|
168
|
-
2,
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
1, 47, :
|
174
|
-
1, 47, :
|
175
|
-
|
176
|
-
1,
|
177
|
-
1,
|
178
|
-
1,
|
179
|
-
1,
|
180
|
-
1,
|
181
|
-
1,
|
182
|
-
1,
|
183
|
-
1, 48, :
|
184
|
-
1, 48, :
|
185
|
-
1, 48, :
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
2, 52, :_reduce_none,
|
192
|
-
2, 52, :_reduce_none,
|
193
|
-
3, 52, :_reduce_none,
|
194
|
-
1, 50, :_reduce_67,
|
195
|
-
1, 46, :_reduce_68,
|
196
|
-
1, 46, :_reduce_none,
|
197
|
-
1, 46, :_reduce_none,
|
198
|
-
1, 53, :_reduce_none,
|
199
|
-
1, 53, :_reduce_none,
|
200
|
-
0, 55, :_reduce_none,
|
201
|
-
1, 55, :_reduce_74,
|
202
|
-
1, 55, :_reduce_75,
|
203
|
-
1, 55, :_reduce_76,
|
204
|
-
1, 55, :_reduce_77,
|
205
|
-
1, 55, :_reduce_78,
|
206
|
-
1, 55, :_reduce_79,
|
207
|
-
1, 55, :_reduce_80,
|
208
|
-
1, 55, :_reduce_81,
|
209
|
-
1, 55, :_reduce_82,
|
210
|
-
1, 55, :_reduce_83,
|
211
|
-
1, 55, :_reduce_84,
|
212
|
-
1, 55, :_reduce_85,
|
213
|
-
1, 55, :_reduce_86,
|
214
|
-
1, 54, :_reduce_87,
|
215
|
-
1, 54, :_reduce_88,
|
216
|
-
1, 54, :_reduce_89,
|
217
|
-
1, 54, :_reduce_90 ]
|
218
|
-
|
219
|
-
racc_reduce_n = 91
|
220
|
-
|
221
|
-
racc_shift_n = 111
|
159
|
+
1, 46, :_reduce_56,
|
160
|
+
2, 46, :_reduce_none,
|
161
|
+
2, 46, :_reduce_none,
|
162
|
+
1, 44, :_reduce_59,
|
163
|
+
1, 40, :_reduce_60,
|
164
|
+
1, 40, :_reduce_none,
|
165
|
+
1, 40, :_reduce_none,
|
166
|
+
1, 47, :_reduce_none,
|
167
|
+
1, 47, :_reduce_none,
|
168
|
+
0, 49, :_reduce_none,
|
169
|
+
1, 49, :_reduce_66,
|
170
|
+
1, 49, :_reduce_67,
|
171
|
+
1, 49, :_reduce_68,
|
172
|
+
1, 49, :_reduce_69,
|
173
|
+
1, 49, :_reduce_70,
|
174
|
+
1, 49, :_reduce_71,
|
175
|
+
1, 49, :_reduce_72,
|
176
|
+
1, 48, :_reduce_73,
|
177
|
+
1, 48, :_reduce_74,
|
178
|
+
1, 48, :_reduce_75,
|
179
|
+
1, 48, :_reduce_76 ]
|
180
|
+
|
181
|
+
racc_reduce_n = 77
|
182
|
+
|
183
|
+
racc_shift_n = 97
|
222
184
|
|
223
185
|
racc_token_table = {
|
224
186
|
false => 0,
|
@@ -229,29 +191,23 @@ racc_token_table = {
|
|
229
191
|
:STRING_LITERAL_MULTI => 5,
|
230
192
|
:STRING_LITERAL => 6,
|
231
193
|
:DATETIME => 7,
|
232
|
-
:
|
233
|
-
:
|
234
|
-
:
|
235
|
-
:
|
236
|
-
:
|
237
|
-
:
|
238
|
-
:
|
239
|
-
:
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
"
|
247
|
-
|
248
|
-
|
249
|
-
"{" => 25,
|
250
|
-
"}" => 26,
|
251
|
-
"," => 27,
|
252
|
-
"=" => 28 }
|
253
|
-
|
254
|
-
racc_nt_base = 29
|
194
|
+
:LOCAL_TIME => 8,
|
195
|
+
:INTEGER => 9,
|
196
|
+
:NON_DEC_INTEGER => 10,
|
197
|
+
:FLOAT => 11,
|
198
|
+
:FLOAT_KEYWORD => 12,
|
199
|
+
:BOOLEAN => 13,
|
200
|
+
:NEWLINE => 14,
|
201
|
+
:EOS => 15,
|
202
|
+
"[" => 16,
|
203
|
+
"]" => 17,
|
204
|
+
"." => 18,
|
205
|
+
"{" => 19,
|
206
|
+
"}" => 20,
|
207
|
+
"," => 21,
|
208
|
+
"=" => 22 }
|
209
|
+
|
210
|
+
racc_nt_base = 23
|
255
211
|
|
256
212
|
racc_use_result_var = true
|
257
213
|
|
@@ -280,18 +236,12 @@ Racc_token_to_s_table = [
|
|
280
236
|
"STRING_LITERAL_MULTI",
|
281
237
|
"STRING_LITERAL",
|
282
238
|
"DATETIME",
|
283
|
-
"LOCAL_DATETIME",
|
284
|
-
"LOCAL_DATE",
|
285
239
|
"LOCAL_TIME",
|
286
240
|
"INTEGER",
|
287
|
-
"
|
288
|
-
"OCT_INTEGER",
|
289
|
-
"BIN_INTEGER",
|
241
|
+
"NON_DEC_INTEGER",
|
290
242
|
"FLOAT",
|
291
|
-
"
|
292
|
-
"
|
293
|
-
"TRUE",
|
294
|
-
"FALSE",
|
243
|
+
"FLOAT_KEYWORD",
|
244
|
+
"BOOLEAN",
|
295
245
|
"NEWLINE",
|
296
246
|
"EOS",
|
297
247
|
"\"[\"",
|
@@ -351,68 +301,70 @@ Racc_debug_parser = false
|
|
351
301
|
|
352
302
|
# reduce 8 omitted
|
353
303
|
|
354
|
-
|
355
|
-
|
304
|
+
# reduce 9 omitted
|
305
|
+
|
306
|
+
module_eval(<<'.,.,', 'parser.y', 18)
|
307
|
+
def _reduce_10(val, _values, result)
|
356
308
|
@handler.start_(:array_of_tables)
|
357
309
|
result
|
358
310
|
end
|
359
311
|
.,.,
|
360
312
|
|
361
|
-
module_eval(<<'.,.,', 'parser.y',
|
362
|
-
def
|
313
|
+
module_eval(<<'.,.,', 'parser.y', 19)
|
314
|
+
def _reduce_11(val, _values, result)
|
363
315
|
@handler.start_(:table)
|
364
316
|
result
|
365
317
|
end
|
366
318
|
.,.,
|
367
319
|
|
368
|
-
module_eval(<<'.,.,', 'parser.y',
|
369
|
-
def
|
320
|
+
module_eval(<<'.,.,', 'parser.y', 22)
|
321
|
+
def _reduce_12(val, _values, result)
|
370
322
|
array = @handler.end_(:array_of_tables); @handler.set_context(array, is_array_of_tables: true)
|
371
323
|
result
|
372
324
|
end
|
373
325
|
.,.,
|
374
326
|
|
375
|
-
module_eval(<<'.,.,', 'parser.y',
|
376
|
-
def
|
327
|
+
module_eval(<<'.,.,', 'parser.y', 23)
|
328
|
+
def _reduce_13(val, _values, result)
|
377
329
|
array = @handler.end_(:table); @handler.set_context(array)
|
378
330
|
result
|
379
331
|
end
|
380
332
|
.,.,
|
381
333
|
|
382
|
-
# reduce
|
334
|
+
# reduce 14 omitted
|
383
335
|
|
384
|
-
module_eval(<<'.,.,', 'parser.y',
|
385
|
-
def
|
336
|
+
module_eval(<<'.,.,', 'parser.y', 27)
|
337
|
+
def _reduce_15(val, _values, result)
|
386
338
|
array = @handler.end_(:array_of_tables); @handler.set_context(array, is_array_of_tables: true)
|
387
339
|
result
|
388
340
|
end
|
389
341
|
.,.,
|
390
342
|
|
391
|
-
module_eval(<<'.,.,', 'parser.y',
|
392
|
-
def
|
343
|
+
module_eval(<<'.,.,', 'parser.y', 28)
|
344
|
+
def _reduce_16(val, _values, result)
|
393
345
|
array = @handler.end_(:table); @handler.set_context(array)
|
394
346
|
result
|
395
347
|
end
|
396
348
|
.,.,
|
397
349
|
|
398
|
-
# reduce
|
350
|
+
# reduce 17 omitted
|
399
351
|
|
400
|
-
module_eval(<<'.,.,', 'parser.y',
|
401
|
-
def
|
352
|
+
module_eval(<<'.,.,', 'parser.y', 32)
|
353
|
+
def _reduce_18(val, _values, result)
|
402
354
|
@handler.push(val[2])
|
403
355
|
result
|
404
356
|
end
|
405
357
|
.,.,
|
406
358
|
|
407
|
-
module_eval(<<'.,.,', 'parser.y',
|
408
|
-
def
|
359
|
+
module_eval(<<'.,.,', 'parser.y', 33)
|
360
|
+
def _reduce_19(val, _values, result)
|
409
361
|
val[2].split('.').each { |k| @handler.push(k) }
|
410
362
|
result
|
411
363
|
end
|
412
364
|
.,.,
|
413
365
|
|
414
|
-
module_eval(<<'.,.,', 'parser.y',
|
415
|
-
def
|
366
|
+
module_eval(<<'.,.,', 'parser.y', 35)
|
367
|
+
def _reduce_20(val, _values, result)
|
416
368
|
keys = val[0].split('.')
|
417
369
|
@handler.start_(:table)
|
418
370
|
keys.each { |key| @handler.push(key) }
|
@@ -421,15 +373,13 @@ module_eval(<<'.,.,', 'parser.y', 34)
|
|
421
373
|
end
|
422
374
|
.,.,
|
423
375
|
|
424
|
-
module_eval(<<'.,.,', 'parser.y',
|
425
|
-
def
|
376
|
+
module_eval(<<'.,.,', 'parser.y', 39)
|
377
|
+
def _reduce_21(val, _values, result)
|
426
378
|
@handler.push(val[0])
|
427
379
|
result
|
428
380
|
end
|
429
381
|
.,.,
|
430
382
|
|
431
|
-
# reduce 21 omitted
|
432
|
-
|
433
383
|
# reduce 22 omitted
|
434
384
|
|
435
385
|
# reduce 23 omitted
|
@@ -448,21 +398,15 @@ module_eval(<<'.,.,', 'parser.y', 38)
|
|
448
398
|
|
449
399
|
# reduce 30 omitted
|
450
400
|
|
451
|
-
|
452
|
-
|
453
|
-
# reduce 32 omitted
|
454
|
-
|
455
|
-
# reduce 33 omitted
|
456
|
-
|
457
|
-
module_eval(<<'.,.,', 'parser.y', 58)
|
458
|
-
def _reduce_34(val, _values, result)
|
401
|
+
module_eval(<<'.,.,', 'parser.y', 55)
|
402
|
+
def _reduce_31(val, _values, result)
|
459
403
|
@handler.start_(:inline)
|
460
404
|
result
|
461
405
|
end
|
462
406
|
.,.,
|
463
407
|
|
464
|
-
module_eval(<<'.,.,', 'parser.y',
|
465
|
-
def
|
408
|
+
module_eval(<<'.,.,', 'parser.y', 59)
|
409
|
+
def _reduce_32(val, _values, result)
|
466
410
|
array = @handler.end_(:inline)
|
467
411
|
array.map!.with_index{ |n,i| i.even? ? n.to_sym : n } if @handler.symbolize_keys
|
468
412
|
@handler.push(Hash[*array])
|
@@ -471,14 +415,14 @@ module_eval(<<'.,.,', 'parser.y', 62)
|
|
471
415
|
end
|
472
416
|
.,.,
|
473
417
|
|
474
|
-
# reduce
|
418
|
+
# reduce 33 omitted
|
475
419
|
|
476
|
-
# reduce
|
420
|
+
# reduce 34 omitted
|
477
421
|
|
478
|
-
# reduce
|
422
|
+
# reduce 35 omitted
|
479
423
|
|
480
|
-
module_eval(<<'.,.,', 'parser.y',
|
481
|
-
def
|
424
|
+
module_eval(<<'.,.,', 'parser.y', 73)
|
425
|
+
def _reduce_36(val, _values, result)
|
482
426
|
array = @handler.end_(:inline)
|
483
427
|
array.each { |key| @handler.push(key) }
|
484
428
|
@handler.start_(:inline)
|
@@ -488,17 +432,17 @@ module_eval(<<'.,.,', 'parser.y', 76)
|
|
488
432
|
end
|
489
433
|
.,.,
|
490
434
|
|
491
|
-
module_eval(<<'.,.,', 'parser.y',
|
492
|
-
def
|
435
|
+
module_eval(<<'.,.,', 'parser.y', 78)
|
436
|
+
def _reduce_37(val, _values, result)
|
493
437
|
@handler.push(val[0])
|
494
438
|
result
|
495
439
|
end
|
496
440
|
.,.,
|
497
441
|
|
498
|
-
# reduce
|
442
|
+
# reduce 38 omitted
|
499
443
|
|
500
|
-
module_eval(<<'.,.,', 'parser.y',
|
501
|
-
def
|
444
|
+
module_eval(<<'.,.,', 'parser.y', 85)
|
445
|
+
def _reduce_39(val, _values, result)
|
502
446
|
keys = @handler.end_(:keys)
|
503
447
|
@handler.push(keys.pop)
|
504
448
|
@handler.assign(keys)
|
@@ -507,8 +451,8 @@ module_eval(<<'.,.,', 'parser.y', 88)
|
|
507
451
|
end
|
508
452
|
.,.,
|
509
453
|
|
510
|
-
module_eval(<<'.,.,', 'parser.y',
|
511
|
-
def
|
454
|
+
module_eval(<<'.,.,', 'parser.y', 90)
|
455
|
+
def _reduce_40(val, _values, result)
|
512
456
|
keys = @handler.end_(:keys)
|
513
457
|
@handler.push(keys.pop)
|
514
458
|
@handler.assign(keys)
|
@@ -517,22 +461,22 @@ module_eval(<<'.,.,', 'parser.y', 93)
|
|
517
461
|
end
|
518
462
|
.,.,
|
519
463
|
|
520
|
-
module_eval(<<'.,.,', 'parser.y',
|
521
|
-
def
|
464
|
+
module_eval(<<'.,.,', 'parser.y', 96)
|
465
|
+
def _reduce_41(val, _values, result)
|
522
466
|
@handler.push(val[2])
|
523
467
|
result
|
524
468
|
end
|
525
469
|
.,.,
|
526
470
|
|
527
|
-
module_eval(<<'.,.,', 'parser.y',
|
528
|
-
def
|
471
|
+
module_eval(<<'.,.,', 'parser.y', 97)
|
472
|
+
def _reduce_42(val, _values, result)
|
529
473
|
val[2].split('.').each { |k| @handler.push(k) }
|
530
474
|
result
|
531
475
|
end
|
532
476
|
.,.,
|
533
477
|
|
534
|
-
module_eval(<<'.,.,', 'parser.y',
|
535
|
-
def
|
478
|
+
module_eval(<<'.,.,', 'parser.y', 99)
|
479
|
+
def _reduce_43(val, _values, result)
|
536
480
|
keys = val[0].split('.')
|
537
481
|
@handler.start_(:keys)
|
538
482
|
keys.each { |key| @handler.push(key) }
|
@@ -541,13 +485,19 @@ module_eval(<<'.,.,', 'parser.y', 102)
|
|
541
485
|
end
|
542
486
|
.,.,
|
543
487
|
|
544
|
-
module_eval(<<'.,.,', 'parser.y',
|
545
|
-
def
|
488
|
+
module_eval(<<'.,.,', 'parser.y', 103)
|
489
|
+
def _reduce_44(val, _values, result)
|
546
490
|
@handler.start_(:keys); @handler.push(val[0])
|
547
491
|
result
|
548
492
|
end
|
549
493
|
.,.,
|
550
494
|
|
495
|
+
# reduce 45 omitted
|
496
|
+
|
497
|
+
# reduce 46 omitted
|
498
|
+
|
499
|
+
# reduce 47 omitted
|
500
|
+
|
551
501
|
# reduce 48 omitted
|
552
502
|
|
553
503
|
# reduce 49 omitted
|
@@ -558,182 +508,146 @@ module_eval(<<'.,.,', 'parser.y', 106)
|
|
558
508
|
|
559
509
|
# reduce 52 omitted
|
560
510
|
|
561
|
-
|
562
|
-
|
563
|
-
# reduce 54 omitted
|
564
|
-
|
565
|
-
# reduce 55 omitted
|
566
|
-
|
567
|
-
# reduce 56 omitted
|
568
|
-
|
569
|
-
# reduce 57 omitted
|
570
|
-
|
571
|
-
# reduce 58 omitted
|
572
|
-
|
573
|
-
# reduce 59 omitted
|
574
|
-
|
575
|
-
module_eval(<<'.,.,', 'parser.y', 125)
|
576
|
-
def _reduce_60(val, _values, result)
|
511
|
+
module_eval(<<'.,.,', 'parser.y', 118)
|
512
|
+
def _reduce_53(val, _values, result)
|
577
513
|
array = @handler.end_(:array); @handler.push(array)
|
578
514
|
result
|
579
515
|
end
|
580
516
|
.,.,
|
581
517
|
|
582
|
-
# reduce
|
518
|
+
# reduce 54 omitted
|
583
519
|
|
584
|
-
# reduce
|
520
|
+
# reduce 55 omitted
|
585
521
|
|
586
|
-
module_eval(<<'.,.,', 'parser.y',
|
587
|
-
def
|
522
|
+
module_eval(<<'.,.,', 'parser.y', 123)
|
523
|
+
def _reduce_56(val, _values, result)
|
588
524
|
array = @handler.end_(:array); @handler.push(array)
|
589
525
|
result
|
590
526
|
end
|
591
527
|
.,.,
|
592
528
|
|
593
|
-
# reduce
|
594
|
-
|
595
|
-
# reduce 65 omitted
|
529
|
+
# reduce 57 omitted
|
596
530
|
|
597
|
-
# reduce
|
531
|
+
# reduce 58 omitted
|
598
532
|
|
599
|
-
module_eval(<<'.,.,', 'parser.y',
|
600
|
-
def
|
533
|
+
module_eval(<<'.,.,', 'parser.y', 128)
|
534
|
+
def _reduce_59(val, _values, result)
|
601
535
|
@handler.start_(:array)
|
602
536
|
result
|
603
537
|
end
|
604
538
|
.,.,
|
605
539
|
|
606
|
-
module_eval(<<'.,.,', 'parser.y',
|
607
|
-
def
|
540
|
+
module_eval(<<'.,.,', 'parser.y', 131)
|
541
|
+
def _reduce_60(val, _values, result)
|
608
542
|
@handler.push(val[0])
|
609
543
|
result
|
610
544
|
end
|
611
545
|
.,.,
|
612
546
|
|
613
|
-
# reduce
|
547
|
+
# reduce 61 omitted
|
614
548
|
|
615
|
-
# reduce
|
549
|
+
# reduce 62 omitted
|
616
550
|
|
617
|
-
# reduce
|
551
|
+
# reduce 63 omitted
|
618
552
|
|
619
|
-
# reduce
|
553
|
+
# reduce 64 omitted
|
620
554
|
|
621
|
-
# reduce
|
555
|
+
# reduce 65 omitted
|
622
556
|
|
623
|
-
module_eval(<<'.,.,', 'parser.y',
|
624
|
-
def
|
557
|
+
module_eval(<<'.,.,', 'parser.y', 140)
|
558
|
+
def _reduce_66(val, _values, result)
|
625
559
|
result = val[0].to_f
|
626
560
|
result
|
627
561
|
end
|
628
562
|
.,.,
|
629
563
|
|
630
|
-
module_eval(<<'.,.,', 'parser.y',
|
631
|
-
def
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
564
|
+
module_eval(<<'.,.,', 'parser.y', 142)
|
565
|
+
def _reduce_67(val, _values, result)
|
566
|
+
v = val[0]
|
567
|
+
result = if v.end_with?('nan')
|
568
|
+
Float::NAN
|
569
|
+
else
|
570
|
+
(v[0] == '-' ? -1 : 1) * Float::INFINITY
|
571
|
+
end
|
636
572
|
|
637
|
-
module_eval(<<'.,.,', 'parser.y', 150)
|
638
|
-
def _reduce_76(val, _values, result)
|
639
|
-
result = Float::NAN
|
640
573
|
result
|
641
574
|
end
|
642
575
|
.,.,
|
643
576
|
|
644
|
-
module_eval(<<'.,.,', 'parser.y',
|
645
|
-
def
|
577
|
+
module_eval(<<'.,.,', 'parser.y', 149)
|
578
|
+
def _reduce_68(val, _values, result)
|
646
579
|
result = val[0].to_i
|
647
580
|
result
|
648
581
|
end
|
649
582
|
.,.,
|
650
583
|
|
651
|
-
module_eval(<<'.,.,', 'parser.y',
|
652
|
-
def
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
def _reduce_79(val, _values, result)
|
660
|
-
result = val[0].to_i(8)
|
661
|
-
result
|
662
|
-
end
|
663
|
-
.,.,
|
664
|
-
|
665
|
-
module_eval(<<'.,.,', 'parser.y', 154)
|
666
|
-
def _reduce_80(val, _values, result)
|
667
|
-
result = val[0].to_i(2)
|
668
|
-
result
|
669
|
-
end
|
670
|
-
.,.,
|
671
|
-
|
672
|
-
module_eval(<<'.,.,', 'parser.y', 155)
|
673
|
-
def _reduce_81(val, _values, result)
|
674
|
-
result = true
|
675
|
-
result
|
676
|
-
end
|
677
|
-
.,.,
|
678
|
-
|
679
|
-
module_eval(<<'.,.,', 'parser.y', 156)
|
680
|
-
def _reduce_82(val, _values, result)
|
681
|
-
result = false
|
682
|
-
result
|
683
|
-
end
|
684
|
-
.,.,
|
584
|
+
module_eval(<<'.,.,', 'parser.y', 151)
|
585
|
+
def _reduce_69(val, _values, result)
|
586
|
+
base = case val[0][1]
|
587
|
+
when "x" then 16
|
588
|
+
when "o" then 8
|
589
|
+
when "b" then 2
|
590
|
+
end
|
591
|
+
result = val[0].to_i(base)
|
685
592
|
|
686
|
-
module_eval(<<'.,.,', 'parser.y', 157)
|
687
|
-
def _reduce_83(val, _values, result)
|
688
|
-
result = Time.new(*val[0])
|
689
593
|
result
|
690
594
|
end
|
691
595
|
.,.,
|
692
596
|
|
693
597
|
module_eval(<<'.,.,', 'parser.y', 158)
|
694
|
-
def
|
695
|
-
result =
|
598
|
+
def _reduce_70(val, _values, result)
|
599
|
+
result = val[0] == 'true' ? true : false
|
696
600
|
result
|
697
601
|
end
|
698
602
|
.,.,
|
699
603
|
|
700
|
-
module_eval(<<'.,.,', 'parser.y',
|
701
|
-
def
|
702
|
-
|
604
|
+
module_eval(<<'.,.,', 'parser.y', 160)
|
605
|
+
def _reduce_71(val, _values, result)
|
606
|
+
v = val[0]
|
607
|
+
result = if v[6].nil?
|
608
|
+
if v[4].nil?
|
609
|
+
LocalDate.new(v[0], v[1], v[2])
|
610
|
+
else
|
611
|
+
LocalDateTime.new(v[0], v[1], v[2], v[3] || 0, v[4] || 0, v[5].to_f)
|
612
|
+
end
|
613
|
+
else
|
614
|
+
Time.new(v[0], v[1], v[2], v[3] || 0, v[4] || 0, v[5].to_f, v[6])
|
615
|
+
end
|
616
|
+
|
703
617
|
result
|
704
618
|
end
|
705
619
|
.,.,
|
706
620
|
|
707
|
-
module_eval(<<'.,.,', 'parser.y',
|
708
|
-
def
|
621
|
+
module_eval(<<'.,.,', 'parser.y', 171)
|
622
|
+
def _reduce_72(val, _values, result)
|
709
623
|
result = LocalTime.new(*val[0])
|
710
624
|
result
|
711
625
|
end
|
712
626
|
.,.,
|
713
627
|
|
714
|
-
module_eval(<<'.,.,', 'parser.y',
|
715
|
-
def
|
628
|
+
module_eval(<<'.,.,', 'parser.y', 174)
|
629
|
+
def _reduce_73(val, _values, result)
|
716
630
|
result = StringUtils.replace_escaped_chars(StringUtils.multiline_replacements(val[0]))
|
717
631
|
result
|
718
632
|
end
|
719
633
|
.,.,
|
720
634
|
|
721
|
-
module_eval(<<'.,.,', 'parser.y',
|
722
|
-
def
|
635
|
+
module_eval(<<'.,.,', 'parser.y', 175)
|
636
|
+
def _reduce_74(val, _values, result)
|
723
637
|
result = StringUtils.replace_escaped_chars(val[0])
|
724
638
|
result
|
725
639
|
end
|
726
640
|
.,.,
|
727
641
|
|
728
|
-
module_eval(<<'.,.,', 'parser.y',
|
729
|
-
def
|
642
|
+
module_eval(<<'.,.,', 'parser.y', 176)
|
643
|
+
def _reduce_75(val, _values, result)
|
730
644
|
result = StringUtils.strip_spaces(val[0])
|
731
645
|
result
|
732
646
|
end
|
733
647
|
.,.,
|
734
648
|
|
735
|
-
module_eval(<<'.,.,', 'parser.y',
|
736
|
-
def
|
649
|
+
module_eval(<<'.,.,', 'parser.y', 177)
|
650
|
+
def _reduce_76(val, _values, result)
|
737
651
|
result = val[0]
|
738
652
|
result
|
739
653
|
end
|
data/lib/tomlrb/handler.rb
CHANGED
@@ -125,6 +125,7 @@ module Tomlrb
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
current.clear_children if is_array_of_tables
|
128
129
|
current
|
129
130
|
end
|
130
131
|
|
@@ -191,6 +192,10 @@ module Tomlrb
|
|
191
192
|
@children[key] = existed || self.class.new(key, type, declared)
|
192
193
|
end
|
193
194
|
|
195
|
+
def clear_children
|
196
|
+
@children.clear
|
197
|
+
end
|
198
|
+
|
194
199
|
private
|
195
200
|
|
196
201
|
def validate_already_declared_as_different_key(type, declared, existed)
|
data/lib/tomlrb/local_date.rb
CHANGED
data/lib/tomlrb/local_time.rb
CHANGED
data/lib/tomlrb/parser.y
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Tomlrb::GeneratedParser
|
2
|
-
token IDENTIFIER STRING_MULTI STRING_BASIC STRING_LITERAL_MULTI STRING_LITERAL DATETIME
|
2
|
+
token IDENTIFIER STRING_MULTI STRING_BASIC STRING_LITERAL_MULTI STRING_LITERAL DATETIME LOCAL_TIME INTEGER NON_DEC_INTEGER FLOAT FLOAT_KEYWORD BOOLEAN NEWLINE EOS
|
3
3
|
rule
|
4
4
|
expressions
|
5
5
|
| expressions expression
|
@@ -12,7 +12,8 @@ rule
|
|
12
12
|
| NEWLINE
|
13
13
|
;
|
14
14
|
table
|
15
|
-
: table_start table_continued
|
15
|
+
: table_start table_continued NEWLINE
|
16
|
+
| table_start table_continued EOS
|
16
17
|
;
|
17
18
|
table_start
|
18
19
|
: '[' '[' { @handler.start_(:array_of_tables) }
|
@@ -43,13 +44,9 @@ rule
|
|
43
44
|
| STRING_BASIC
|
44
45
|
| STRING_LITERAL
|
45
46
|
| INTEGER
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
| FLOAT_INF
|
50
|
-
| FLOAT_NAN
|
51
|
-
| TRUE
|
52
|
-
| FALSE
|
47
|
+
| NON_DEC_INTEGER
|
48
|
+
| FLOAT_KEYWORD
|
49
|
+
| BOOLEAN
|
53
50
|
;
|
54
51
|
inline_table
|
55
52
|
: inline_table_start inline_table_end
|
@@ -111,13 +108,9 @@ rule
|
|
111
108
|
| STRING_BASIC
|
112
109
|
| STRING_LITERAL
|
113
110
|
| INTEGER
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
| FLOAT_INF
|
118
|
-
| FLOAT_NAN
|
119
|
-
| TRUE
|
120
|
-
| FALSE
|
111
|
+
| NON_DEC_INTEGER
|
112
|
+
| FLOAT_KEYWORD
|
113
|
+
| BOOLEAN
|
121
114
|
;
|
122
115
|
array
|
123
116
|
: start_array array_continued
|
@@ -131,7 +124,6 @@ rule
|
|
131
124
|
: ']' { array = @handler.end_(:array); @handler.push(array) }
|
132
125
|
| ',' array_continued
|
133
126
|
| NEWLINE array_continued
|
134
|
-
| ',' NEWLINE array_continued
|
135
127
|
;
|
136
128
|
start_array
|
137
129
|
: '[' { @handler.start_(:array) }
|
@@ -147,17 +139,36 @@ rule
|
|
147
139
|
;
|
148
140
|
literal
|
149
141
|
| FLOAT { result = val[0].to_f }
|
150
|
-
|
|
151
|
-
|
142
|
+
| FLOAT_KEYWORD {
|
143
|
+
v = val[0]
|
144
|
+
result = if v.end_with?('nan')
|
145
|
+
Float::NAN
|
146
|
+
else
|
147
|
+
(v[0] == '-' ? -1 : 1) * Float::INFINITY
|
148
|
+
end
|
149
|
+
}
|
152
150
|
| INTEGER { result = val[0].to_i }
|
153
|
-
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
151
|
+
| NON_DEC_INTEGER {
|
152
|
+
base = case val[0][1]
|
153
|
+
when "x" then 16
|
154
|
+
when "o" then 8
|
155
|
+
when "b" then 2
|
156
|
+
end
|
157
|
+
result = val[0].to_i(base)
|
158
|
+
}
|
159
|
+
| BOOLEAN { result = val[0] == 'true' ? true : false }
|
160
|
+
| DATETIME {
|
161
|
+
v = val[0]
|
162
|
+
result = if v[6].nil?
|
163
|
+
if v[4].nil?
|
164
|
+
LocalDate.new(v[0], v[1], v[2])
|
165
|
+
else
|
166
|
+
LocalDateTime.new(v[0], v[1], v[2], v[3] || 0, v[4] || 0, v[5].to_f)
|
167
|
+
end
|
168
|
+
else
|
169
|
+
Time.new(v[0], v[1], v[2], v[3] || 0, v[4] || 0, v[5].to_f, v[6])
|
170
|
+
end
|
171
|
+
}
|
161
172
|
| LOCAL_TIME { result = LocalTime.new(*val[0]) }
|
162
173
|
;
|
163
174
|
string
|
data/lib/tomlrb/scanner.rb
CHANGED
@@ -5,24 +5,18 @@ module Tomlrb
|
|
5
5
|
COMMENT = /#[^\u0000-\u0008\u000A-\u001F\u007F]*/
|
6
6
|
IDENTIFIER = /[A-Za-z0-9_-]+/
|
7
7
|
SPACE = /[ \t]/
|
8
|
-
NEWLINE = /(\r?\n)
|
8
|
+
NEWLINE = /(?:[ \t]*(?:\r?\n)[ \t]*)+/
|
9
9
|
STRING_BASIC = /(["])(?:\\?[^\u0000-\u0008\u000A-\u001F\u007F])*?\1/
|
10
10
|
STRING_MULTI = /"{3}([^\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]*?(?<!\\)"{3,5})/m
|
11
11
|
STRING_LITERAL = /(['])(?:\\?[^\u0000-\u0008\u000A-\u001F\u007F])*?\1/
|
12
12
|
STRING_LITERAL_MULTI = /'{3}([^\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]*?'{3,5})/m
|
13
|
-
DATETIME = /(-?\d{4})-(\d{2})-(\d{2})(?:(?:t|\s)(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?))?(z|[-+]\d{2}:\d{2})
|
14
|
-
LOCAL_DATETIME = /(-?\d{4})-(\d{2})-(\d{2})(?:t|\s)(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?)/i
|
15
|
-
LOCAL_DATE = /(-?\d{4})-(\d{2})-(\d{2})/
|
13
|
+
DATETIME = /(-?\d{4})-(\d{2})-(\d{2})(?:(?:t|\s)(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?))?(z|[-+]\d{2}:\d{2})?/i
|
16
14
|
LOCAL_TIME = /(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?)/
|
17
15
|
FLOAT = /[+-]?(?:(?:\d|[1-9](?:_?\d)*)\.\d(?:_?\d)*|\d+(?=[eE]))(?:[eE][+-]?[0-9_]+)?(?!\w)/
|
18
|
-
|
19
|
-
FLOAT_NAN = /[+-]?nan\b/
|
16
|
+
FLOAT_KEYWORD = /[+-]?(?:inf|nan)\b/
|
20
17
|
INTEGER = /[+-]?([1-9](_?\d)*|0)(?![A-Za-z0-9_-]+)/
|
21
|
-
|
22
|
-
|
23
|
-
BIN_INTEGER = /0b[01][01_]*/
|
24
|
-
TRUE = /true/
|
25
|
-
FALSE = /false/
|
18
|
+
NON_DEC_INTEGER = /0(?:x[0-9A-Fa-f][0-9A-Fa-f_]*|o[0-7][0-7_]*|b[01][01_]*)/
|
19
|
+
BOOLEAN = /true|false/
|
26
20
|
|
27
21
|
def initialize(io)
|
28
22
|
@ss = StringScanner.new(io.read)
|
@@ -31,52 +25,34 @@ module Tomlrb
|
|
31
25
|
|
32
26
|
def next_token
|
33
27
|
case
|
34
|
-
when @ss.
|
28
|
+
when @ss.scan(NEWLINE) then [:NEWLINE, nil]
|
35
29
|
when @ss.scan(SPACE) then next_token
|
36
30
|
when @ss.scan(COMMENT) then next_token
|
37
31
|
when @ss.scan(DATETIME) then process_datetime
|
38
|
-
when @ss.scan(LOCAL_DATETIME) then process_local_datetime
|
39
|
-
when @ss.scan(LOCAL_DATE) then process_local_date
|
40
32
|
when @ss.scan(LOCAL_TIME) then process_local_time
|
41
33
|
when text = @ss.scan(STRING_MULTI) then [:STRING_MULTI, text[3..-4]]
|
42
34
|
when text = @ss.scan(STRING_BASIC) then [:STRING_BASIC, text[1..-2]]
|
43
35
|
when text = @ss.scan(STRING_LITERAL_MULTI) then [:STRING_LITERAL_MULTI, text[3..-4]]
|
44
36
|
when text = @ss.scan(STRING_LITERAL) then [:STRING_LITERAL, text[1..-2]]
|
45
37
|
when text = @ss.scan(FLOAT) then [:FLOAT, text]
|
46
|
-
when text = @ss.scan(
|
47
|
-
when text = @ss.scan(FLOAT_NAN) then [:FLOAT_NAN, text]
|
38
|
+
when text = @ss.scan(FLOAT_KEYWORD) then [:FLOAT_KEYWORD, text]
|
48
39
|
when text = @ss.scan(INTEGER) then [:INTEGER, text]
|
49
|
-
when text = @ss.scan(
|
50
|
-
when text = @ss.scan(
|
51
|
-
when text = @ss.scan(BIN_INTEGER) then [:BIN_INTEGER, text]
|
52
|
-
when text = @ss.scan(TRUE) then [:TRUE, text]
|
53
|
-
when text = @ss.scan(FALSE) then [:FALSE, text]
|
54
|
-
when text = @ss.scan(NEWLINE) then [:NEWLINE, text]
|
40
|
+
when text = @ss.scan(NON_DEC_INTEGER) then [:NON_DEC_INTEGER, text]
|
41
|
+
when text = @ss.scan(BOOLEAN) then [:BOOLEAN, text]
|
55
42
|
when text = @ss.scan(IDENTIFIER) then [:IDENTIFIER, text]
|
43
|
+
when @ss.eos? then process_eos
|
56
44
|
else x = @ss.getch; [x, x]
|
57
45
|
end
|
58
46
|
end
|
59
47
|
|
60
48
|
def process_datetime
|
61
|
-
if @ss[7]
|
62
|
-
offset = '+00:00'
|
63
|
-
else
|
49
|
+
if @ss[7]
|
64
50
|
offset = @ss[7].gsub('Z', '+00:00')
|
65
51
|
end
|
66
|
-
args = [@ss[1], @ss[2], @ss[3], @ss[4]
|
52
|
+
args = [@ss[1], @ss[2], @ss[3], @ss[4], @ss[5], @ss[6], offset]
|
67
53
|
[:DATETIME, args]
|
68
54
|
end
|
69
55
|
|
70
|
-
def process_local_datetime
|
71
|
-
args = [@ss[1], @ss[2], @ss[3], @ss[4] || 0, @ss[5] || 0, @ss[6].to_f]
|
72
|
-
[:LOCAL_DATETIME, args]
|
73
|
-
end
|
74
|
-
|
75
|
-
def process_local_date
|
76
|
-
args = [@ss[1], @ss[2], @ss[3]]
|
77
|
-
[:LOCAL_DATE, args]
|
78
|
-
end
|
79
|
-
|
80
56
|
def process_local_time
|
81
57
|
args = [@ss[1], @ss[2], @ss[3].to_f]
|
82
58
|
[:LOCAL_TIME, args]
|
data/lib/tomlrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomlrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
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-
|
11
|
+
date: 2020-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A racc based toml parser
|
14
14
|
email:
|