kdl 1.0.0 → 1.0.3

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: 9ded4c2fceb98dde6ae4421034c52e2c26ca36894da75def6bc358de10339dce
4
- data.tar.gz: 00c0e2c08400aed4edddd124c337cd3a5169557bb74666d9cb5cbbc3821fd7aa
3
+ metadata.gz: 8be036a0955b8ac11ce122cd4515bcb4770d73f2228aaa2e27827705250c95e8
4
+ data.tar.gz: 56671b97653eb3c1857a6c1a9df7b427df8e4c486983033aff44e0f8f57b51bc
5
5
  SHA512:
6
- metadata.gz: 655e6cb06085648a3aab37298e1214ebda9cc64c8576e5b6ca8528f2d86e8376c14755fdcbd946999f30598189d95f31850de223f563a3c08099d71912714f61
7
- data.tar.gz: cb7e37ea4400ec877fa7c3cbb584d88eb6686194a0c1545b99c2331725195da826a62f33bfe2e01f3b5d371c1d0429db7f550d26ad8b15cbc84e2c7b6fc0a580
6
+ metadata.gz: d2c64169c11e46d89ff1e59350d03d88dd364a17e11e2a9e544cd861ab7d51023d3f2c9717f728970512b1072078d2aa3fb41fa83e534518f350d1d8ae2ee70c
7
+ data.tar.gz: 96a8ed2c9ea104ff480558e25e104cdbde98a1cab2c457b20022243d41f51e9a4839d5db5bb9bda320643aaafecd0a872e5ada80c25dc1a096ac5e6afabd7700
@@ -17,7 +17,7 @@ jobs:
17
17
  test:
18
18
  strategy:
19
19
  matrix:
20
- ruby: [2.4, 2.5, 2.6, 2.7, 3.0, head]
20
+ ruby: [2.4, 2.5, 2.6, 2.7, 3.0, 3.1, head]
21
21
 
22
22
  runs-on: ubuntu-latest
23
23
 
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  Gemfile.lock
11
11
 
12
12
  lib/kdl/kdl.tab.rb
13
+ kdl.output
data/bin/kdl ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kdl"
5
+
6
+ system 'bin/rake racc'
7
+
8
+ puts KDL.parse_document(ARGF.read).to_s
data/lib/kdl/kdl.tab.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.5.2
3
+ # This file is automatically generated by Racc 1.6.0
4
4
  # from Racc grammar file "".
5
5
  #
6
6
 
@@ -8,7 +8,7 @@ require 'racc/parser.rb'
8
8
  module KDL
9
9
  class Parser < Racc::Parser
10
10
 
11
- module_eval(<<'...end kdl.yy/module_eval...', 'kdl.yy', 69)
11
+ module_eval(<<'...end kdl.yy/module_eval...', 'kdl.yy', 70)
12
12
 
13
13
  def parse(str, options = {})
14
14
  if options.fetch(:parse_types, true)
@@ -29,92 +29,96 @@ module_eval(<<'...end kdl.yy/module_eval...', 'kdl.yy', 69)
29
29
  ##### State transition tables begin ###
30
30
 
31
31
  racc_action_table = [
32
- -2, 10, 19, 20, 21, 19, 20, 21, 6, 7,
33
- 6, 7, 45, 25, 18, 38, 8, 18, 8, 17,
34
- 58, 32, 17, 19, 47, 48, 52, 53, 56, 57,
35
- 55, 45, 38, -43, 62, 18, 19, 20, 21, 38,
36
- 43, -29, -30, 19, 20, 21, 64, 74, 18, 19,
37
- 20, 21, nil, 17, 75, 18, 19, 20, 21, nil,
38
- 17, 18, 19, 47, 48, 52, 53, 56, 57, 55,
39
- nil, nil, 58, nil, 18, 66, 67, 52, 53, 56,
40
- 57, 55, 30, 7, nil, nil, 18, 6, 7, 35,
41
- 8, 32, 6, 7, 35, 8, 6, 7, nil, 35,
42
- 8, 6, 7, nil, 8, 6, 7, 6, 7, 8,
43
- 6, 7, nil, 8, nil, 8, nil, nil, 8, 66,
44
- 67, 52, 53, 56, 57, 55, 19, 20, 21 ]
32
+ -49, 9, 18, 19, 20, 18, 19, 20, 5, 6,
33
+ 24, -49, 60, -49, 17, 64, 7, 17, -49, 16,
34
+ 63, 18, 49, 50, 54, 55, 58, 59, 57, 39,
35
+ 39, 39, 63, 17, 18, 19, 20, 66, 45, 36,
36
+ 36, 36, 5, 6, 39, -29, 17, 18, 19, 20,
37
+ 7, 16, -30, 68, 36, 5, 6, 74, 78, 17,
38
+ 18, 19, 20, 7, 16, nil, 35, 6, 18, 19,
39
+ 20, 79, 17, 34, 7, 31, 36, 16, 18, 49,
40
+ 50, 54, 55, 58, 59, 57, nil, nil, 60, 39,
41
+ 17, 70, 71, 54, 55, 58, 59, 57, 31, 36,
42
+ 5, 6, 17, 5, 6, 5, 6, 34, 7, nil,
43
+ 34, 7, nil, 7, 5, 6, 5, 6, 5, 6,
44
+ nil, nil, 7, nil, 7, nil, 7, 70, 71, 54,
45
+ 55, 58, 59, 57, 18, 19, 20 ]
45
46
 
46
47
  racc_action_check = [
47
- 3, 1, 2, 2, 2, 5, 5, 5, 0, 0,
48
- 3, 3, 45, 10, 2, 17, 0, 5, 3, 2,
49
- 31, 45, 5, 30, 30, 30, 30, 30, 30, 30,
50
- 30, 30, 32, 30, 39, 30, 68, 68, 68, 43,
51
- 30, 47, 48, 69, 69, 69, 49, 68, 68, 37,
52
- 37, 37, nil, 68, 69, 69, 14, 14, 14, nil,
53
- 69, 37, 63, 63, 63, 63, 63, 63, 63, 63,
54
- nil, nil, 63, nil, 63, 64, 64, 64, 64, 64,
55
- 64, 64, 15, 15, nil, nil, 64, 28, 28, 15,
56
- 15, 15, 29, 29, 28, 28, 33, 33, nil, 29,
57
- 29, 35, 35, nil, 33, 58, 58, 60, 60, 35,
58
- 70, 70, nil, 58, nil, 60, nil, nil, 70, 51,
59
- 51, 51, 51, 51, 51, 51, 18, 18, 18 ]
48
+ 35, 1, 2, 2, 2, 38, 38, 38, 0, 0,
49
+ 9, 35, 30, 35, 2, 36, 0, 38, 35, 2,
50
+ 35, 29, 29, 29, 29, 29, 29, 29, 29, 29,
51
+ 16, 31, 39, 29, 3, 3, 3, 41, 29, 29,
52
+ 16, 31, 3, 3, 45, 49, 3, 72, 72, 72,
53
+ 3, 3, 50, 51, 45, 72, 72, 63, 72, 72,
54
+ 73, 73, 73, 72, 72, nil, 14, 14, 13, 13,
55
+ 13, 73, 73, 14, 14, 14, 14, 73, 67, 67,
56
+ 67, 67, 67, 67, 67, 67, nil, nil, 67, 47,
57
+ 67, 68, 68, 68, 68, 68, 68, 68, 47, 47,
58
+ 27, 27, 68, 28, 28, 32, 32, 27, 27, nil,
59
+ 28, 28, nil, 32, 34, 34, 60, 60, 62, 62,
60
+ nil, nil, 34, nil, 60, nil, 62, 53, 53, 53,
61
+ 53, 53, 53, 53, 17, 17, 17 ]
60
62
 
61
63
  racc_action_pointer = [
62
- -2, 1, 0, 0, nil, 3, nil, nil, nil, nil,
63
- 13, nil, nil, nil, 54, 72, nil, 5, 124, nil,
64
- nil, nil, nil, nil, nil, nil, nil, nil, 77, 82,
65
- 21, 8, 22, 86, nil, 91, nil, 47, nil, 19,
66
- nil, nil, nil, 29, nil, 2, nil, 25, 26, 30,
67
- nil, 116, nil, nil, nil, nil, nil, nil, 95, nil,
68
- 97, nil, nil, 60, 72, nil, nil, nil, 34, 41,
69
- 100, nil, nil, nil, nil, nil ]
64
+ -2, 1, 0, 32, nil, nil, nil, nil, nil, 10,
65
+ nil, nil, nil, 66, 56, nil, 20, 132, nil, nil,
66
+ nil, nil, nil, nil, nil, nil, nil, 90, 93, 19,
67
+ 0, 21, 95, nil, 104, 0, 5, nil, 3, 12,
68
+ nil, 22, nil, nil, nil, 34, nil, 79, nil, 29,
69
+ 36, 37, nil, 124, nil, nil, nil, nil, nil, nil,
70
+ 106, nil, 108, 47, nil, nil, nil, 76, 88, nil,
71
+ nil, nil, 45, 58, nil, nil, nil, nil, nil, nil ]
70
72
 
71
73
  racc_action_default = [
72
- -51, -52, -1, -50, -3, -52, -44, -45, -46, -47,
73
- -52, -6, -7, -8, -52, -51, -13, -51, -52, -28,
74
- -29, -30, -48, -4, -5, 76, -9, -10, -52, -52,
75
- -44, -52, -51, -23, -24, -25, -42, -52, -43, -52,
76
- -11, -12, -14, -51, -16, -52, -22, -34, -35, -52,
77
- -32, -52, -36, -37, -38, -39, -40, -41, -51, -21,
78
- -26, -18, -27, -52, -52, -33, -34, -35, -52, -52,
79
- -50, -15, -17, -31, -20, -19 ]
74
+ -54, -55, -1, -2, -3, -49, -50, -51, -52, -55,
75
+ -6, -7, -8, -55, -54, -13, -54, -55, -28, -29,
76
+ -30, -4, -5, -53, 80, -9, -10, -55, -55, -48,
77
+ -55, -54, -23, -24, -25, -42, -43, -47, -55, -42,
78
+ -48, -55, -11, -12, -14, -54, -16, -55, -22, -34,
79
+ -35, -55, -32, -55, -36, -37, -38, -39, -40, -41,
80
+ -54, -21, -26, -44, -45, -18, -27, -55, -55, -33,
81
+ -34, -35, -55, -55, -46, -15, -17, -31, -20, -19 ]
80
82
 
81
83
  racc_goto_table = [
82
- 22, 23, 24, 2, 3, 4, 39, 51, 5, 42,
83
- 37, 44, 27, 1, 26, 28, 29, 65, 49, nil,
84
- nil, nil, nil, nil, nil, 40, 41, nil, nil, nil,
85
- 22, nil, nil, 61, nil, nil, 63, nil, nil, 60,
86
- 51, 51, 71, 73, 72, nil, nil, nil, nil, nil,
87
- nil, 49, nil, nil, nil, nil, nil, 22, nil, nil,
88
- nil, 69, 70, 4, 23, 24, 68, 22 ]
84
+ 21, 22, 23, 2, 3, 4, 41, 53, 29, 44,
85
+ 38, 46, 26, 1, 25, 27, 28, 69, 51, nil,
86
+ nil, nil, nil, 47, nil, 42, 43, nil, nil, nil,
87
+ nil, 23, nil, nil, nil, 65, nil, nil, 62, 67,
88
+ nil, 47, nil, nil, nil, 53, 53, 75, 77, 76,
89
+ nil, nil, nil, nil, nil, nil, 51, nil, nil, nil,
90
+ nil, 23, nil, 73, 72, 4, nil, nil, nil, 21,
91
+ 22, 23 ]
89
92
 
90
93
  racc_goto_check = [
91
- 21, 6, 7, 2, 3, 4, 14, 9, 5, 15,
92
- 16, 17, 11, 1, 8, 12, 13, 19, 14, nil,
93
- nil, nil, nil, nil, nil, 11, 11, nil, nil, nil,
94
- 21, nil, nil, 6, nil, nil, 16, nil, nil, 3,
95
- 9, 9, 15, 15, 17, nil, nil, nil, nil, nil,
96
- nil, 14, nil, nil, nil, nil, nil, 21, nil, nil,
97
- nil, 2, 3, 4, 6, 7, 5, 21 ]
94
+ 5, 6, 21, 2, 3, 4, 13, 8, 14, 15,
95
+ 16, 17, 10, 1, 7, 11, 12, 19, 13, nil,
96
+ nil, nil, nil, 14, nil, 10, 10, nil, nil, nil,
97
+ nil, 21, nil, nil, nil, 5, nil, nil, 3, 16,
98
+ nil, 14, nil, nil, nil, 8, 8, 15, 15, 17,
99
+ nil, nil, nil, nil, nil, nil, 13, nil, nil, nil,
100
+ nil, 21, nil, 2, 3, 4, nil, nil, nil, 5,
101
+ 6, 21 ]
98
102
 
99
103
  racc_goto_pointer = [
100
- nil, 13, 3, 4, 5, 8, -4, -3, 0, -23,
101
- nil, -3, 0, 1, -12, -21, -7, -19, nil, -34,
102
- nil, -3 ]
104
+ nil, 13, 3, 4, 5, -3, -2, 1, -22, nil,
105
+ -2, 1, 2, -11, -6, -20, -6, -18, nil, -36,
106
+ nil, -1 ]
103
107
 
104
108
  racc_goto_default = [
105
- nil, nil, nil, 33, 36, nil, 11, 12, 13, 14,
106
- 15, nil, 59, 46, 16, nil, 31, nil, 34, 50,
107
- 54, 9 ]
109
+ nil, nil, nil, 32, 37, 10, 11, 12, 13, 14,
110
+ nil, 61, 48, 15, 40, nil, 30, nil, 33, 52,
111
+ 56, 8 ]
108
112
 
109
113
  racc_reduce_table = [
110
114
  0, 0, :racc_error,
111
- 1, 21, :_reduce_1,
112
- 1, 21, :_reduce_2,
113
- 1, 22, :_reduce_3,
114
- 2, 22, :_reduce_4,
115
- 2, 22, :_reduce_5,
116
- 2, 22, :_reduce_6,
117
- 2, 22, :_reduce_7,
115
+ 1, 22, :_reduce_1,
116
+ 1, 22, :_reduce_2,
117
+ 1, 23, :_reduce_3,
118
+ 2, 23, :_reduce_4,
119
+ 2, 23, :_reduce_5,
120
+ 2, 23, :_reduce_6,
121
+ 2, 23, :_reduce_7,
118
122
  1, 26, :_reduce_8,
119
123
  2, 26, :_reduce_9,
120
124
  2, 28, :_reduce_10,
@@ -132,37 +136,40 @@ racc_reduce_table = [
132
136
  2, 33, :_reduce_none,
133
137
  1, 31, :_reduce_none,
134
138
  1, 31, :_reduce_none,
135
- 1, 38, :_reduce_none,
136
- 2, 38, :_reduce_none,
139
+ 1, 39, :_reduce_none,
140
+ 2, 39, :_reduce_none,
137
141
  3, 29, :_reduce_27,
138
142
  1, 34, :_reduce_28,
139
143
  1, 34, :_reduce_29,
140
144
  1, 34, :_reduce_30,
141
- 3, 37, :_reduce_31,
142
- 1, 35, :_reduce_none,
143
- 2, 35, :_reduce_33,
144
- 1, 39, :_reduce_34,
145
- 1, 39, :_reduce_35,
146
- 1, 39, :_reduce_36,
147
- 1, 39, :_reduce_37,
148
- 1, 39, :_reduce_38,
149
- 1, 39, :_reduce_39,
150
- 1, 40, :_reduce_40,
151
- 1, 40, :_reduce_41,
152
- 1, 36, :_reduce_none,
145
+ 3, 38, :_reduce_31,
153
146
  1, 36, :_reduce_none,
154
- 1, 41, :_reduce_none,
155
- 1, 41, :_reduce_none,
156
- 1, 41, :_reduce_none,
157
- 1, 23, :_reduce_none,
158
- 2, 23, :_reduce_none,
159
- 1, 25, :_reduce_none,
160
- 1, 25, :_reduce_none,
161
- 0, 24, :_reduce_51 ]
162
-
163
- racc_reduce_n = 52
164
-
165
- racc_shift_n = 76
147
+ 2, 36, :_reduce_33,
148
+ 1, 40, :_reduce_34,
149
+ 1, 40, :_reduce_35,
150
+ 1, 40, :_reduce_36,
151
+ 1, 40, :_reduce_37,
152
+ 1, 40, :_reduce_38,
153
+ 1, 40, :_reduce_39,
154
+ 1, 41, :_reduce_40,
155
+ 1, 41, :_reduce_41,
156
+ 1, 35, :_reduce_none,
157
+ 1, 35, :_reduce_none,
158
+ 2, 35, :_reduce_none,
159
+ 2, 35, :_reduce_none,
160
+ 3, 35, :_reduce_none,
161
+ 1, 37, :_reduce_none,
162
+ 1, 37, :_reduce_none,
163
+ 1, 42, :_reduce_none,
164
+ 1, 42, :_reduce_none,
165
+ 1, 42, :_reduce_none,
166
+ 1, 24, :_reduce_none,
167
+ 2, 24, :_reduce_none,
168
+ 0, 25, :_reduce_54 ]
169
+
170
+ racc_reduce_n = 55
171
+
172
+ racc_shift_n = 80
166
173
 
167
174
  racc_token_table = {
168
175
  false => 0,
@@ -184,9 +191,10 @@ racc_token_table = {
184
191
  :EQUALS => 16,
185
192
  :SEMICOLON => 17,
186
193
  :EOF => 18,
187
- :SLASHDASH => 19 }
194
+ :SLASHDASH => 19,
195
+ :ESCLINE => 20 }
188
196
 
189
- racc_nt_base = 20
197
+ racc_nt_base = 21
190
198
 
191
199
  racc_use_result_var = false
192
200
 
@@ -227,12 +235,12 @@ Racc_token_to_s_table = [
227
235
  "SEMICOLON",
228
236
  "EOF",
229
237
  "SLASHDASH",
238
+ "ESCLINE",
230
239
  "$start",
231
240
  "document",
232
241
  "nodes",
233
242
  "linespaces",
234
243
  "none",
235
- "linespace_star",
236
244
  "node",
237
245
  "empty_node",
238
246
  "untyped_node",
@@ -242,6 +250,7 @@ Racc_token_to_s_table = [
242
250
  "node_children",
243
251
  "empty_children",
244
252
  "identifier",
253
+ "ws",
245
254
  "value",
246
255
  "ws_star",
247
256
  "property",
@@ -256,103 +265,103 @@ Racc_debug_parser = false
256
265
 
257
266
  # reduce 0 omitted
258
267
 
259
- module_eval(<<'.,.,', 'kdl.yy', 13)
268
+ module_eval(<<'.,.,', 'kdl.yy', 14)
260
269
  def _reduce_1(val, _values)
261
270
  KDL::Document.new(val[0])
262
271
  end
263
272
  .,.,
264
273
 
265
- module_eval(<<'.,.,', 'kdl.yy', 14)
274
+ module_eval(<<'.,.,', 'kdl.yy', 15)
266
275
  def _reduce_2(val, _values)
267
276
  KDL::Document.new([])
268
277
  end
269
278
  .,.,
270
279
 
271
- module_eval(<<'.,.,', 'kdl.yy', 16)
280
+ module_eval(<<'.,.,', 'kdl.yy', 17)
272
281
  def _reduce_3(val, _values)
273
282
  []
274
283
  end
275
284
  .,.,
276
285
 
277
- module_eval(<<'.,.,', 'kdl.yy', 17)
286
+ module_eval(<<'.,.,', 'kdl.yy', 18)
278
287
  def _reduce_4(val, _values)
279
288
  [val[1]]
280
289
  end
281
290
  .,.,
282
291
 
283
- module_eval(<<'.,.,', 'kdl.yy', 18)
292
+ module_eval(<<'.,.,', 'kdl.yy', 19)
284
293
  def _reduce_5(val, _values)
285
294
  []
286
295
  end
287
296
  .,.,
288
297
 
289
- module_eval(<<'.,.,', 'kdl.yy', 19)
298
+ module_eval(<<'.,.,', 'kdl.yy', 20)
290
299
  def _reduce_6(val, _values)
291
300
  [*val[0], val[1]]
292
301
  end
293
302
  .,.,
294
303
 
295
- module_eval(<<'.,.,', 'kdl.yy', 20)
304
+ module_eval(<<'.,.,', 'kdl.yy', 21)
296
305
  def _reduce_7(val, _values)
297
306
  val[0]
298
307
  end
299
308
  .,.,
300
309
 
301
- module_eval(<<'.,.,', 'kdl.yy', 21)
310
+ module_eval(<<'.,.,', 'kdl.yy', 22)
302
311
  def _reduce_8(val, _values)
303
312
  val[0]
304
313
  end
305
314
  .,.,
306
315
 
307
- module_eval(<<'.,.,', 'kdl.yy', 22)
316
+ module_eval(<<'.,.,', 'kdl.yy', 23)
308
317
  def _reduce_9(val, _values)
309
318
  val[1].as_type(val[0], @type_parsers.fetch(val[0], nil))
310
319
  end
311
320
  .,.,
312
321
 
313
- module_eval(<<'.,.,', 'kdl.yy', 23)
322
+ module_eval(<<'.,.,', 'kdl.yy', 24)
314
323
  def _reduce_10(val, _values)
315
- val[0].tap { |x| x.children = nil }
324
+ val[0].tap { |x| x.children = [] }
316
325
  end
317
326
  .,.,
318
327
 
319
- module_eval(<<'.,.,', 'kdl.yy', 24)
328
+ module_eval(<<'.,.,', 'kdl.yy', 25)
320
329
  def _reduce_11(val, _values)
321
330
  val[0].tap { |x| x.children = val[1] }
322
331
  end
323
332
  .,.,
324
333
 
325
- module_eval(<<'.,.,', 'kdl.yy', 25)
334
+ module_eval(<<'.,.,', 'kdl.yy', 26)
326
335
  def _reduce_12(val, _values)
327
- val[0].tap { |x| x.children = nil }
336
+ val[0].tap { |x| x.children = [] }
328
337
  end
329
338
  .,.,
330
339
 
331
- module_eval(<<'.,.,', 'kdl.yy', 26)
340
+ module_eval(<<'.,.,', 'kdl.yy', 27)
332
341
  def _reduce_13(val, _values)
333
342
  KDL::Node.new(val[0])
334
343
  end
335
344
  .,.,
336
345
 
337
- module_eval(<<'.,.,', 'kdl.yy', 27)
346
+ module_eval(<<'.,.,', 'kdl.yy', 28)
338
347
  def _reduce_14(val, _values)
339
348
  val[0].tap { |x| x.arguments << val[2] }
340
349
  end
341
350
  .,.,
342
351
 
343
- module_eval(<<'.,.,', 'kdl.yy', 28)
352
+ module_eval(<<'.,.,', 'kdl.yy', 29)
344
353
  def _reduce_15(val, _values)
345
354
  val[0]
346
355
  end
347
356
  .,.,
348
357
 
349
- module_eval(<<'.,.,', 'kdl.yy', 29)
358
+ module_eval(<<'.,.,', 'kdl.yy', 30)
350
359
  def _reduce_16(val, _values)
351
360
  val[0].tap { |x| x.properties[val[2][0]] = val[2][1] }
352
361
  end
353
362
  .,.,
354
363
 
355
- module_eval(<<'.,.,', 'kdl.yy', 30)
364
+ module_eval(<<'.,.,', 'kdl.yy', 31)
356
365
  def _reduce_17(val, _values)
357
366
  val[0]
358
367
  end
@@ -360,13 +369,13 @@ module_eval(<<'.,.,', 'kdl.yy', 30)
360
369
 
361
370
  # reduce 18 omitted
362
371
 
363
- module_eval(<<'.,.,', 'kdl.yy', 32)
372
+ module_eval(<<'.,.,', 'kdl.yy', 33)
364
373
  def _reduce_19(val, _values)
365
374
  val[2]
366
375
  end
367
376
  .,.,
368
377
 
369
- module_eval(<<'.,.,', 'kdl.yy', 33)
378
+ module_eval(<<'.,.,', 'kdl.yy', 34)
370
379
  def _reduce_20(val, _values)
371
380
  []
372
381
  end
@@ -384,31 +393,31 @@ module_eval(<<'.,.,', 'kdl.yy', 33)
384
393
 
385
394
  # reduce 26 omitted
386
395
 
387
- module_eval(<<'.,.,', 'kdl.yy', 39)
396
+ module_eval(<<'.,.,', 'kdl.yy', 40)
388
397
  def _reduce_27(val, _values)
389
398
  val[1]
390
399
  end
391
400
  .,.,
392
401
 
393
- module_eval(<<'.,.,', 'kdl.yy', 41)
402
+ module_eval(<<'.,.,', 'kdl.yy', 42)
394
403
  def _reduce_28(val, _values)
395
404
  val[0].value
396
405
  end
397
406
  .,.,
398
407
 
399
- module_eval(<<'.,.,', 'kdl.yy', 42)
408
+ module_eval(<<'.,.,', 'kdl.yy', 43)
400
409
  def _reduce_29(val, _values)
401
410
  val[0].value
402
411
  end
403
412
  .,.,
404
413
 
405
- module_eval(<<'.,.,', 'kdl.yy', 43)
414
+ module_eval(<<'.,.,', 'kdl.yy', 44)
406
415
  def _reduce_30(val, _values)
407
416
  val[0].value
408
417
  end
409
418
  .,.,
410
419
 
411
- module_eval(<<'.,.,', 'kdl.yy', 45)
420
+ module_eval(<<'.,.,', 'kdl.yy', 46)
412
421
  def _reduce_31(val, _values)
413
422
  [val[0], val[2]]
414
423
  end
@@ -416,55 +425,55 @@ module_eval(<<'.,.,', 'kdl.yy', 45)
416
425
 
417
426
  # reduce 32 omitted
418
427
 
419
- module_eval(<<'.,.,', 'kdl.yy', 48)
428
+ module_eval(<<'.,.,', 'kdl.yy', 49)
420
429
  def _reduce_33(val, _values)
421
430
  val[1].as_type(val[0], @type_parsers.fetch(val[0], nil))
422
431
  end
423
432
  .,.,
424
433
 
425
- module_eval(<<'.,.,', 'kdl.yy', 50)
434
+ module_eval(<<'.,.,', 'kdl.yy', 51)
426
435
  def _reduce_34(val, _values)
427
436
  KDL::Value::String.new(val[0].value)
428
437
  end
429
438
  .,.,
430
439
 
431
- module_eval(<<'.,.,', 'kdl.yy', 51)
440
+ module_eval(<<'.,.,', 'kdl.yy', 52)
432
441
  def _reduce_35(val, _values)
433
442
  KDL::Value::String.new(val[0].value)
434
443
  end
435
444
  .,.,
436
445
 
437
- module_eval(<<'.,.,', 'kdl.yy', 52)
446
+ module_eval(<<'.,.,', 'kdl.yy', 53)
438
447
  def _reduce_36(val, _values)
439
448
  KDL::Value::Int.new(val[0].value)
440
449
  end
441
450
  .,.,
442
451
 
443
- module_eval(<<'.,.,', 'kdl.yy', 53)
452
+ module_eval(<<'.,.,', 'kdl.yy', 54)
444
453
  def _reduce_37(val, _values)
445
454
  KDL::Value::Float.new(val[0].value, format: val[0].meta[:format])
446
455
  end
447
456
  .,.,
448
457
 
449
- module_eval(<<'.,.,', 'kdl.yy', 54)
458
+ module_eval(<<'.,.,', 'kdl.yy', 55)
450
459
  def _reduce_38(val, _values)
451
460
  KDL::Value::Boolean.new(val[0])
452
461
  end
453
462
  .,.,
454
463
 
455
- module_eval(<<'.,.,', 'kdl.yy', 55)
464
+ module_eval(<<'.,.,', 'kdl.yy', 56)
456
465
  def _reduce_39(val, _values)
457
466
  KDL::Value::Null
458
467
  end
459
468
  .,.,
460
469
 
461
- module_eval(<<'.,.,', 'kdl.yy', 57)
470
+ module_eval(<<'.,.,', 'kdl.yy', 58)
462
471
  def _reduce_40(val, _values)
463
472
  true
464
473
  end
465
474
  .,.,
466
475
 
467
- module_eval(<<'.,.,', 'kdl.yy', 58)
476
+ module_eval(<<'.,.,', 'kdl.yy', 59)
468
477
  def _reduce_41(val, _values)
469
478
  false
470
479
  end
@@ -488,8 +497,14 @@ module_eval(<<'.,.,', 'kdl.yy', 58)
488
497
 
489
498
  # reduce 50 omitted
490
499
 
491
- module_eval(<<'.,.,', 'kdl.yy', 65)
492
- def _reduce_51(val, _values)
500
+ # reduce 51 omitted
501
+
502
+ # reduce 52 omitted
503
+
504
+ # reduce 53 omitted
505
+
506
+ module_eval(<<'.,.,', 'kdl.yy', 66)
507
+ def _reduce_54(val, _values)
493
508
  nil
494
509
  end
495
510
  .,.,
data/lib/kdl/kdl.yy CHANGED
@@ -10,30 +10,31 @@ class KDL::Parser
10
10
  SEMICOLON
11
11
  EOF
12
12
  SLASHDASH
13
+ ESCLINE
13
14
  rule
14
15
  document : nodes { KDL::Document.new(val[0]) }
15
16
  | linespaces { KDL::Document.new([])}
16
17
 
17
18
  nodes : none { [] }
18
- | linespace_star node { [val[1]] }
19
- | linespace_star empty_node { [] }
19
+ | linespaces node { [val[1]] }
20
+ | linespaces empty_node { [] }
20
21
  | nodes node { [*val[0], val[1]] }
21
22
  | nodes empty_node { val[0] }
22
23
  node : untyped_node { val[0] }
23
24
  | type untyped_node { val[1].as_type(val[0], @type_parsers.fetch(val[0], nil)) }
24
- untyped_node : node_decl node_term { val[0].tap { |x| x.children = nil } }
25
+ untyped_node : node_decl node_term { val[0].tap { |x| x.children = [] } }
25
26
  | node_decl node_children node_term { val[0].tap { |x| x.children = val[1] } }
26
- | node_decl empty_children node_term { val[0].tap { |x| x.children = nil } }
27
+ | node_decl empty_children node_term { val[0].tap { |x| x.children = [] } }
27
28
  node_decl : identifier { KDL::Node.new(val[0]) }
28
- | node_decl WS value { val[0].tap { |x| x.arguments << val[2] } }
29
- | node_decl WS SLASHDASH ws_star value { val[0] }
30
- | node_decl WS property { val[0].tap { |x| x.properties[val[2][0]] = val[2][1] } }
31
- | node_decl WS SLASHDASH ws_star property { val[0] }
29
+ | node_decl ws value { val[0].tap { |x| x.arguments << val[2] } }
30
+ | node_decl ws SLASHDASH ws_star value { val[0] }
31
+ | node_decl ws property { val[0].tap { |x| x.properties[val[2][0]] = val[2][1] } }
32
+ | node_decl ws SLASHDASH ws_star property { val[0] }
32
33
  empty_node : SLASHDASH ws_star node
33
34
  node_children : ws_star LBRACE nodes RBRACE { val[2] }
34
- | ws_star LBRACE linespace_star RBRACE { [] }
35
+ | ws_star LBRACE linespaces RBRACE { [] }
35
36
  empty_children: SLASHDASH node_children
36
- | WS empty_children
37
+ | ws empty_children
37
38
  node_term: linespaces | semicolon_term
38
39
  semicolon_term: SEMICOLON | SEMICOLON linespaces
39
40
 
@@ -58,10 +59,10 @@ nodes : none { [] }
58
59
  boolean : TRUE { true }
59
60
  | FALSE { false }
60
61
 
61
- ws_star: none | WS
62
+ ws: WS | ESCLINE | WS ESCLINE | ESCLINE WS | WS ESCLINE WS
63
+ ws_star: none | ws
62
64
  linespace: WS | NEWLINE | EOF
63
65
  linespaces: linespace | linespaces linespace
64
- linespace_star: none | linespaces
65
66
 
66
67
  none: { nil }
67
68
 
data/lib/kdl/node.rb CHANGED
@@ -2,7 +2,7 @@ module KDL
2
2
  class Node
3
3
  attr_accessor :name, :arguments, :properties, :children, :type
4
4
 
5
- def initialize(name, arguments = [], properties = {}, children = nil, type: nil)
5
+ def initialize(name, arguments = [], properties = {}, children = [], type: nil)
6
6
  @name = name
7
7
  @arguments = arguments
8
8
  @properties = properties
@@ -19,11 +19,9 @@ module KDL
19
19
  unless properties.empty?
20
20
  s += " #{properties.map { |k, v| "#{id_to_s k}=#{v}" }.join(' ')}"
21
21
  end
22
- unless children.nil?
22
+ unless children.empty?
23
23
  s += " {\n"
24
- unless children.empty?
25
- s += children.map { |c| "#{c.to_s(level + 1)}\n" }.join("\n")
26
- end
24
+ s += children.map { |c| "#{c.to_s(level + 1)}\n" }.join("\n")
27
25
  s += "#{indent}}"
28
26
  end
29
27
  s
data/lib/kdl/tokenizer.rb CHANGED
@@ -120,20 +120,18 @@ module KDL
120
120
  end
121
121
  else
122
122
  self.context = :decimal
123
- traverse(1)
124
123
  @buffer = c
124
+ traverse(1)
125
125
  end
126
126
  when '\\'
127
127
  t = Tokenizer.new(@str, @index + 1)
128
- la = t.next_token[0]
129
- if la == :NEWLINE
130
- @index = t.index
131
- new_line
132
- elsif la == :WS && (lan = t.next_token[0]) == :NEWLINE
128
+ la = t.next_token
129
+ if la[0] == :NEWLINE || la[0] == :EOF || (la[0] == :WS && (lan = t.next_token[0]) == :NEWLINE || lan == :EOF)
133
130
  @index = t.index
134
131
  new_line
132
+ return token(:ESCLINE, "\\#{la[1].value}")
135
133
  else
136
- raise_error "Unexpected '\\'"
134
+ raise_error "Unexpected '\\' (#{la[0]})"
137
135
  end
138
136
  when *SYMBOLS.keys
139
137
  return token(SYMBOLS[c], c).tap { traverse(1) }
@@ -293,18 +291,6 @@ module KDL
293
291
  if WHITEPACE.include?(c)
294
292
  traverse(1)
295
293
  @buffer += c
296
- elsif c == "\\"
297
- t = Tokenizer.new(@str, @index + 1)
298
- la = t.next_token[0]
299
- if la == :NEWLINE
300
- @index = t.index
301
- new_line
302
- elsif (la == :WS && (lan = t.next_token[0]) == :NEWLINE)
303
- @index = t.index
304
- new_line
305
- else
306
- raise_error "Unexpected '\\'"
307
- end
308
294
  elsif c == "/" && @str[@index + 1] == '*'
309
295
  self.context = :multi_line_comment
310
296
  @comment_nesting = 1
@@ -355,10 +341,16 @@ module KDL
355
341
  return parse_float(s) if s =~ /[.E]/i
356
342
 
357
343
  token(:INTEGER, Integer(munch_underscores(s), 10), format: '%d')
344
+ rescue
345
+ if s[0] =~ INITIAL_IDENTIFIER_CHARS && s[1..-1].each_char.all? { |c| c =~ IDENTIFIER_CHARS }
346
+ token(:IDENT, s)
347
+ else
348
+ raise
349
+ end
358
350
  end
359
351
 
360
352
  def parse_float(s)
361
- match, _, fraction, exponent = *s.match(/^([-+]?[\d_]+)(?:\.(\d+))?(?:[eE]([-+]?[\d_]+))?$/)
353
+ match, _, fraction, exponent = *s.match(/^([-+]?[\d_]+)(?:\.([\d_]+))?(?:[eE]([-+]?[\d_]+))?$/)
362
354
  raise_error "Invalid floating point value #{s}" if match.nil?
363
355
 
364
356
  s = munch_underscores(s)
@@ -3,9 +3,15 @@ require 'base64'
3
3
  module KDL
4
4
  module Types
5
5
  class Base64 < Value
6
+ RGX = /^[A-Za-z0-9+\/=]+$/.freeze
7
+
6
8
  def self.call(value, type = 'base64')
7
9
  return nil unless value.is_a? ::KDL::Value::String
8
10
 
11
+ unless RGX.match?(value.value)
12
+ raise ArgumentError, "invalid base64: #{value.value}"
13
+ end
14
+
9
15
  data = ::Base64.decode64(value.value)
10
16
  new(data, type: type)
11
17
  end
@@ -12,6 +12,8 @@ module KDL
12
12
  end
13
13
 
14
14
  def self.call(value, type = 'email')
15
+ return nil unless value.is_a? ::KDL::Value::String
16
+
15
17
  local, domain = Parser.new(value.value).parse
16
18
 
17
19
  new(value.value, type: type, local: local, domain: domain)
@@ -29,6 +31,8 @@ module KDL
29
31
  end
30
32
 
31
33
  def self.call(value, type = 'email')
34
+ return nil unless value.is_a? ::KDL::Value::String
35
+
32
36
  local, domain, unicode_domain = Email::Parser.new(value.value, idn: true).parse
33
37
 
34
38
  new("#{local}@#{domain}", type: type, local: local, domain: domain, unicode_domain: unicode_domain)
@@ -4,6 +4,8 @@ module KDL
4
4
  module Types
5
5
  class Hostname < Value
6
6
  def self.call(value, type = 'hostname')
7
+ return nil unless value.is_a? ::KDL::Value::String
8
+
7
9
  validator = Validator.new(value.value)
8
10
  raise ArgumentError, "invalid hostname #{value}" unless validator.valid?
9
11
 
@@ -21,6 +23,8 @@ module KDL
21
23
  end
22
24
 
23
25
  def self.call(value, type = 'idn-hostname')
26
+ return nil unless value.is_a? ::KDL::Value::String
27
+
24
28
  validator = Validator.new(value.value)
25
29
  raise ArgumentError, "invalid hostname #{value}" unless validator.valid?
26
30
 
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  module KDL
2
4
  module Types
3
5
  class URLTemplate < Value
@@ -53,7 +55,7 @@ module KDL
53
55
  when '+' then ReservedExpansion
54
56
  when '#' then FragmentExpansion
55
57
  when '.' then LabelExpansion
56
- when '/' then PathExpantion
58
+ when '/' then PathExpansion
57
59
  when ';' then ParameterExpansion
58
60
  when '?' then QueryExpansion
59
61
  when '&' then QueryContinuation
@@ -275,7 +277,7 @@ module KDL
275
277
  end
276
278
  end
277
279
 
278
- class PathExpantion < StringExpansion
280
+ class PathExpansion < StringExpansion
279
281
  def prefix
280
282
  '/'
281
283
  end
data/lib/kdl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KDL
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danielle Smith
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-04 00:00:00.000000000 Z
11
+ date: 2022-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: racc
@@ -54,6 +54,7 @@ files:
54
54
  - README.md
55
55
  - Rakefile
56
56
  - bin/console
57
+ - bin/kdl
57
58
  - bin/racc
58
59
  - bin/rake
59
60
  - bin/setup
@@ -96,7 +97,7 @@ metadata:
96
97
  homepage_uri: https://kdl.dev
97
98
  source_code_uri: https://github.com/danini-the-panini/kdl-rb
98
99
  changelog_uri: https://github.com/danini-the-panini/kdl-rb/releases
99
- post_install_message:
100
+ post_install_message:
100
101
  rdoc_options: []
101
102
  require_paths:
102
103
  - lib
@@ -111,8 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  - !ruby/object:Gem::Version
112
113
  version: '0'
113
114
  requirements: []
114
- rubygems_version: 3.2.22
115
- signing_key:
115
+ rubygems_version: 3.3.7
116
+ signing_key:
116
117
  specification_version: 4
117
118
  summary: KDL Document Language
118
119
  test_files: []