kdl 1.0.6 → 2.0.0

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +7 -1
  3. data/.gitignore +1 -0
  4. data/.gitmodules +4 -0
  5. data/Gemfile +6 -1
  6. data/README.md +51 -7
  7. data/Rakefile +6 -1
  8. data/bin/kdl +1 -1
  9. data/kdl.gemspec +2 -2
  10. data/lib/kdl/document.rb +58 -2
  11. data/lib/kdl/kdl.tab.rb +303 -228
  12. data/lib/kdl/kdl.yy +57 -49
  13. data/lib/kdl/node.rb +113 -12
  14. data/lib/kdl/parser_common.rb +26 -0
  15. data/lib/kdl/string_dumper.rb +30 -33
  16. data/lib/kdl/tokenizer.rb +350 -113
  17. data/lib/kdl/types/base64.rb +1 -1
  18. data/lib/kdl/types/country/iso3166_countries.rb +1 -1
  19. data/lib/kdl/types/country/iso3166_subdivisions.rb +1 -1
  20. data/lib/kdl/types/country.rb +2 -2
  21. data/lib/kdl/types/currency/iso4217_currencies.rb +1 -1
  22. data/lib/kdl/types/currency.rb +1 -1
  23. data/lib/kdl/types/date_time.rb +3 -3
  24. data/lib/kdl/types/decimal.rb +1 -1
  25. data/lib/kdl/types/duration/iso8601_parser.rb +1 -1
  26. data/lib/kdl/types/duration.rb +1 -1
  27. data/lib/kdl/types/email/parser.rb +1 -1
  28. data/lib/kdl/types/email.rb +1 -1
  29. data/lib/kdl/types/hostname/validator.rb +1 -1
  30. data/lib/kdl/types/hostname.rb +1 -1
  31. data/lib/kdl/types/ip.rb +1 -1
  32. data/lib/kdl/types/irl/parser.rb +1 -1
  33. data/lib/kdl/types/irl.rb +1 -1
  34. data/lib/kdl/types/regex.rb +1 -1
  35. data/lib/kdl/types/url.rb +1 -1
  36. data/lib/kdl/types/url_template.rb +1 -1
  37. data/lib/kdl/types/uuid.rb +1 -1
  38. data/lib/kdl/v1/document.rb +17 -0
  39. data/lib/kdl/v1/kdl.tab.rb +594 -0
  40. data/lib/kdl/v1/kdl.yy +89 -0
  41. data/lib/kdl/v1/node.rb +30 -0
  42. data/lib/kdl/v1/string_dumper.rb +28 -0
  43. data/lib/kdl/v1/tokenizer.rb +296 -0
  44. data/lib/kdl/v1/value.rb +89 -0
  45. data/lib/kdl/v1.rb +11 -0
  46. data/lib/kdl/value.rb +81 -12
  47. data/lib/kdl/version.rb +1 -1
  48. data/lib/kdl.rb +40 -1
  49. metadata +13 -4
@@ -0,0 +1,594 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.8.0
4
+ # from Racc grammar file "kdl.yy".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+ module KDL
9
+ module V1
10
+ class Parser < Racc::Parser
11
+
12
+ module_eval(<<'...end kdl.yy/module_eval...', 'kdl.yy', 77)
13
+
14
+ include KDL::ParserCommon
15
+
16
+ def parser_version
17
+ 1
18
+ end
19
+
20
+ def parse(str, **options)
21
+ init(**options)
22
+ @tokenizer = ::KDL::V1::Tokenizer.new(str)
23
+ check_version
24
+ do_parse
25
+ end
26
+ ...end kdl.yy/module_eval...
27
+ ##### State transition tables begin ###
28
+
29
+ racc_action_table = [
30
+ 20, 21, 22, 20, 21, 22, 20, 21, 22, 9,
31
+ 38, 38, 19, -63, 5, 6, 26, 18, 19, 18,
32
+ 18, 38, 7, 18, 20, 56, 57, 61, 62, 65,
33
+ 66, 64, 38, 38, 38, -63, 19, 20, 21, 22,
34
+ 67, 18, 18, -58, 38, 5, 6, -41, 84, 19,
35
+ 20, 21, 22, 7, 18, -42, 20, 21, 22, 75,
36
+ 38, 86, 19, 38, 43, 6, 87, 18, 19, 18,
37
+ 90, 91, 7, 20, 56, 57, 61, 62, 65, 66,
38
+ 64, 43, 6, nil, nil, 19, nil, nil, 38, 7,
39
+ 77, 78, 61, 62, 65, 66, 64, 18, 38, 38,
40
+ 38, 19, 5, 6, 5, 6, nil, 18, 18, 18,
41
+ 7, 30, 7, 5, 6, 5, 6, 43, 6, 5,
42
+ 6, 7, nil, 7, nil, 7, nil, 7, 5, 6,
43
+ 5, 6, 43, 6, 43, 6, 7, nil, 7, 30,
44
+ 7, 30, 7, 77, 78, 61, 62, 65, 66, 64,
45
+ 20, 21, 22 ]
46
+
47
+ racc_action_check = [
48
+ 2, 2, 2, 14, 14, 14, 3, 3, 3, 1,
49
+ 32, 15, 2, 15, 3, 3, 9, 2, 3, 32,
50
+ 15, 19, 3, 3, 34, 34, 34, 34, 34, 34,
51
+ 34, 34, 34, 33, 43, 33, 34, 79, 79, 79,
52
+ 35, 34, 33, 43, 38, 79, 79, 56, 79, 79,
53
+ 80, 80, 80, 79, 79, 57, 17, 17, 17, 58,
54
+ 47, 80, 80, 71, 17, 17, 81, 80, 17, 47,
55
+ 88, 89, 17, 53, 53, 53, 53, 53, 53, 53,
56
+ 53, 53, 53, nil, nil, 53, nil, nil, 48, 53,
57
+ 75, 75, 75, 75, 75, 75, 75, 48, 49, 50,
58
+ 72, 75, 0, 0, 12, 12, nil, 49, 50, 72,
59
+ 0, 12, 12, 28, 28, 30, 30, 36, 36, 42,
60
+ 42, 28, nil, 30, nil, 36, nil, 42, 46, 46,
61
+ 67, 67, 83, 83, 85, 85, 46, nil, 67, 83,
62
+ 83, 85, 85, 60, 60, 60, 60, 60, 60, 60,
63
+ 44, 44, 44 ]
64
+
65
+ racc_action_pointer = [
66
+ 92, 9, -2, 4, nil, nil, nil, nil, nil, 16,
67
+ nil, nil, 94, nil, 1, 1, nil, 54, nil, 11,
68
+ nil, nil, nil, nil, nil, nil, nil, nil, 103, nil,
69
+ 105, nil, 0, 23, 22, 28, 107, nil, 34, nil,
70
+ nil, nil, 109, 24, 148, nil, 118, 50, 78, 88,
71
+ 89, nil, nil, 71, nil, nil, 31, 39, 43, nil,
72
+ 140, nil, nil, nil, nil, nil, nil, 120, nil, nil,
73
+ nil, 53, 90, nil, nil, 87, nil, nil, nil, 35,
74
+ 48, 51, nil, 122, nil, 124, nil, nil, 57, 58,
75
+ nil, nil ]
76
+
77
+ racc_action_default = [
78
+ -63, -64, -1, -2, -3, -58, -59, -60, -61, -64,
79
+ -6, -7, -64, -9, -64, -11, -17, -64, -36, -63,
80
+ -40, -41, -42, -4, -5, -62, 92, -8, -32, -33,
81
+ -34, -10, -12, -13, -22, -64, -63, -30, -54, -56,
82
+ -23, -37, -38, -54, -64, -57, -35, -15, -64, -14,
83
+ -57, -31, -18, -63, -20, -29, -46, -47, -64, -44,
84
+ -64, -48, -49, -50, -51, -52, -53, -63, -28, -37,
85
+ -55, -63, -16, -19, -21, -64, -45, -46, -47, -64,
86
+ -64, -64, -43, -63, -25, -63, -24, -39, -64, -64,
87
+ -27, -26 ]
88
+
89
+ racc_goto_table = [
90
+ 17, 17, 2, 23, 24, 25, 4, 54, 60, 52,
91
+ 1, 32, 83, 85, 58, 31, 76, 40, 34, 44,
92
+ 41, 33, 45, 3, 71, nil, 74, 60, 73, 49,
93
+ 25, nil, 53, 58, nil, nil, 50, nil, 47, 69,
94
+ 42, 70, nil, nil, 25, nil, 70, nil, 25, 60,
95
+ 82, nil, nil, 46, nil, 72, 69, nil, nil, 42,
96
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 80,
97
+ nil, 81, nil, 4, 45, nil, 42, 17, 17, 23,
98
+ 24, 25, nil, 88, nil, 89, 45, nil, 45, nil,
99
+ 79, 51, 55, nil, nil, nil, nil, nil, nil, nil,
100
+ nil, nil, nil, nil, nil, 51, 55, nil, 55, nil,
101
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
102
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
103
+ 51 ]
104
+
105
+ racc_goto_check = [
106
+ 17, 17, 2, 5, 6, 24, 4, 18, 10, 16,
107
+ 1, 12, 7, 7, 14, 9, 22, 5, 15, 19,
108
+ 15, 13, 15, 3, 14, nil, 18, 10, 16, 12,
109
+ 24, nil, 17, 14, nil, nil, 15, nil, 13, 15,
110
+ 3, 15, nil, nil, 24, nil, 15, nil, 24, 10,
111
+ 16, nil, nil, 3, nil, 13, 15, nil, nil, 3,
112
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 2,
113
+ nil, 19, nil, 4, 15, nil, 3, 17, 17, 5,
114
+ 6, 24, nil, 19, nil, 19, 15, nil, 15, nil,
115
+ 3, 20, 20, nil, nil, nil, nil, nil, nil, nil,
116
+ nil, nil, nil, nil, nil, 20, 20, nil, 20, nil,
117
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
118
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
119
+ 20 ]
120
+
121
+ racc_goto_pointer = [
122
+ nil, 10, 2, 23, 6, 0, 1, -67, nil, 1,
123
+ -26, nil, -4, 6, -20, 3, -25, -2, -27, 0,
124
+ 58, nil, -44, nil, 2 ]
125
+
126
+ racc_goto_default = [
127
+ nil, nil, nil, 28, 39, 10, 11, 12, 27, 13,
128
+ 14, 15, 68, nil, 16, 48, nil, 36, nil, 35,
129
+ 37, 29, 59, 63, 8 ]
130
+
131
+ racc_reduce_table = [
132
+ 0, 0, :racc_error,
133
+ 1, 21, :_reduce_1,
134
+ 1, 21, :_reduce_2,
135
+ 1, 22, :_reduce_3,
136
+ 2, 22, :_reduce_4,
137
+ 2, 22, :_reduce_5,
138
+ 2, 22, :_reduce_6,
139
+ 2, 22, :_reduce_7,
140
+ 2, 25, :_reduce_8,
141
+ 1, 27, :_reduce_9,
142
+ 2, 27, :_reduce_10,
143
+ 1, 29, :_reduce_11,
144
+ 2, 29, :_reduce_12,
145
+ 2, 29, :_reduce_13,
146
+ 3, 29, :_reduce_14,
147
+ 3, 29, :_reduce_15,
148
+ 4, 29, :_reduce_16,
149
+ 1, 31, :_reduce_17,
150
+ 3, 31, :_reduce_18,
151
+ 4, 31, :_reduce_19,
152
+ 3, 31, :_reduce_20,
153
+ 4, 31, :_reduce_21,
154
+ 2, 31, :_reduce_22,
155
+ 2, 26, :_reduce_none,
156
+ 4, 32, :_reduce_24,
157
+ 4, 32, :_reduce_25,
158
+ 6, 32, :_reduce_26,
159
+ 6, 32, :_reduce_27,
160
+ 2, 40, :_reduce_none,
161
+ 2, 40, :_reduce_none,
162
+ 1, 33, :_reduce_none,
163
+ 2, 33, :_reduce_none,
164
+ 1, 28, :_reduce_none,
165
+ 1, 28, :_reduce_none,
166
+ 1, 41, :_reduce_none,
167
+ 2, 41, :_reduce_none,
168
+ 1, 37, :_reduce_none,
169
+ 2, 37, :_reduce_none,
170
+ 2, 37, :_reduce_none,
171
+ 5, 30, :_reduce_39,
172
+ 1, 34, :_reduce_40,
173
+ 1, 34, :_reduce_41,
174
+ 1, 34, :_reduce_42,
175
+ 3, 38, :_reduce_43,
176
+ 1, 36, :_reduce_none,
177
+ 2, 36, :_reduce_45,
178
+ 1, 42, :_reduce_46,
179
+ 1, 42, :_reduce_47,
180
+ 1, 42, :_reduce_48,
181
+ 1, 42, :_reduce_49,
182
+ 1, 42, :_reduce_50,
183
+ 1, 42, :_reduce_51,
184
+ 1, 43, :_reduce_52,
185
+ 1, 43, :_reduce_53,
186
+ 1, 35, :_reduce_none,
187
+ 2, 35, :_reduce_none,
188
+ 1, 39, :_reduce_none,
189
+ 1, 39, :_reduce_none,
190
+ 1, 44, :_reduce_none,
191
+ 1, 44, :_reduce_none,
192
+ 1, 44, :_reduce_none,
193
+ 1, 23, :_reduce_none,
194
+ 2, 23, :_reduce_none,
195
+ 0, 24, :_reduce_63 ]
196
+
197
+ racc_reduce_n = 64
198
+
199
+ racc_shift_n = 92
200
+
201
+ racc_token_table = {
202
+ false => 0,
203
+ :error => 1,
204
+ :IDENT => 2,
205
+ :STRING => 3,
206
+ :RAWSTRING => 4,
207
+ :INTEGER => 5,
208
+ :FLOAT => 6,
209
+ :TRUE => 7,
210
+ :FALSE => 8,
211
+ :NULL => 9,
212
+ :WS => 10,
213
+ :NEWLINE => 11,
214
+ :LBRACE => 12,
215
+ :RBRACE => 13,
216
+ :LPAREN => 14,
217
+ :RPAREN => 15,
218
+ :EQUALS => 16,
219
+ :SEMICOLON => 17,
220
+ :EOF => 18,
221
+ :SLASHDASH => 19 }
222
+
223
+ racc_nt_base = 20
224
+
225
+ racc_use_result_var = false
226
+
227
+ Racc_arg = [
228
+ racc_action_table,
229
+ racc_action_check,
230
+ racc_action_default,
231
+ racc_action_pointer,
232
+ racc_goto_table,
233
+ racc_goto_check,
234
+ racc_goto_default,
235
+ racc_goto_pointer,
236
+ racc_nt_base,
237
+ racc_reduce_table,
238
+ racc_token_table,
239
+ racc_shift_n,
240
+ racc_reduce_n,
241
+ racc_use_result_var ]
242
+ Ractor.make_shareable(Racc_arg) if defined?(Ractor)
243
+
244
+ Racc_token_to_s_table = [
245
+ "$end",
246
+ "error",
247
+ "IDENT",
248
+ "STRING",
249
+ "RAWSTRING",
250
+ "INTEGER",
251
+ "FLOAT",
252
+ "TRUE",
253
+ "FALSE",
254
+ "NULL",
255
+ "WS",
256
+ "NEWLINE",
257
+ "LBRACE",
258
+ "RBRACE",
259
+ "LPAREN",
260
+ "RPAREN",
261
+ "EQUALS",
262
+ "SEMICOLON",
263
+ "EOF",
264
+ "SLASHDASH",
265
+ "$start",
266
+ "document",
267
+ "nodes",
268
+ "linespaces",
269
+ "none",
270
+ "node",
271
+ "empty_node",
272
+ "unterm_node",
273
+ "node_term",
274
+ "untyped_node",
275
+ "type",
276
+ "node_decl",
277
+ "node_children",
278
+ "empty_childrens",
279
+ "identifier",
280
+ "ws_plus",
281
+ "value",
282
+ "slashdash",
283
+ "property",
284
+ "ws_star",
285
+ "empty_children",
286
+ "semicolon_term",
287
+ "untyped_value",
288
+ "boolean",
289
+ "linespace" ]
290
+ Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
291
+
292
+ Racc_debug_parser = false
293
+
294
+ ##### State transition tables end #####
295
+
296
+ # reduce 0 omitted
297
+
298
+ module_eval(<<'.,.,', 'kdl.yy', 12)
299
+ def _reduce_1(val, _values)
300
+ @output_module::Document.new(val[0])
301
+ end
302
+ .,.,
303
+
304
+ module_eval(<<'.,.,', 'kdl.yy', 13)
305
+ def _reduce_2(val, _values)
306
+ @output_module::Document.new([])
307
+ end
308
+ .,.,
309
+
310
+ module_eval(<<'.,.,', 'kdl.yy', 15)
311
+ def _reduce_3(val, _values)
312
+ []
313
+ end
314
+ .,.,
315
+
316
+ module_eval(<<'.,.,', 'kdl.yy', 16)
317
+ def _reduce_4(val, _values)
318
+ [val[1]]
319
+ end
320
+ .,.,
321
+
322
+ module_eval(<<'.,.,', 'kdl.yy', 17)
323
+ def _reduce_5(val, _values)
324
+ []
325
+ end
326
+ .,.,
327
+
328
+ module_eval(<<'.,.,', 'kdl.yy', 18)
329
+ def _reduce_6(val, _values)
330
+ [*val[0], val[1]]
331
+ end
332
+ .,.,
333
+
334
+ module_eval(<<'.,.,', 'kdl.yy', 19)
335
+ def _reduce_7(val, _values)
336
+ val[0]
337
+ end
338
+ .,.,
339
+
340
+ module_eval(<<'.,.,', 'kdl.yy', 20)
341
+ def _reduce_8(val, _values)
342
+ val[0]
343
+ end
344
+ .,.,
345
+
346
+ module_eval(<<'.,.,', 'kdl.yy', 21)
347
+ def _reduce_9(val, _values)
348
+ val[0]
349
+ end
350
+ .,.,
351
+
352
+ module_eval(<<'.,.,', 'kdl.yy', 22)
353
+ def _reduce_10(val, _values)
354
+ val[1].as_type(val[0], @type_parsers.fetch(val[0], nil))
355
+ end
356
+ .,.,
357
+
358
+ module_eval(<<'.,.,', 'kdl.yy', 23)
359
+ def _reduce_11(val, _values)
360
+ val[0].tap { |x| x.children = [] }
361
+ end
362
+ .,.,
363
+
364
+ module_eval(<<'.,.,', 'kdl.yy', 24)
365
+ def _reduce_12(val, _values)
366
+ val[0].tap { |x| x.children = val[1] }
367
+ end
368
+ .,.,
369
+
370
+ module_eval(<<'.,.,', 'kdl.yy', 25)
371
+ def _reduce_13(val, _values)
372
+ val[0].tap { |x| x.children = [] }
373
+ end
374
+ .,.,
375
+
376
+ module_eval(<<'.,.,', 'kdl.yy', 26)
377
+ def _reduce_14(val, _values)
378
+ val[0].tap { |x| x.children = val[2] }
379
+ end
380
+ .,.,
381
+
382
+ module_eval(<<'.,.,', 'kdl.yy', 27)
383
+ def _reduce_15(val, _values)
384
+ val[0].tap { |x| x.children = val[1] }
385
+ end
386
+ .,.,
387
+
388
+ module_eval(<<'.,.,', 'kdl.yy', 28)
389
+ def _reduce_16(val, _values)
390
+ val[0].tap { |x| x.children = val[2] }
391
+ end
392
+ .,.,
393
+
394
+ module_eval(<<'.,.,', 'kdl.yy', 29)
395
+ def _reduce_17(val, _values)
396
+ @output_module::Node.new(val[0])
397
+ end
398
+ .,.,
399
+
400
+ module_eval(<<'.,.,', 'kdl.yy', 30)
401
+ def _reduce_18(val, _values)
402
+ val[0].tap { |x| x.arguments << val[2] }
403
+ end
404
+ .,.,
405
+
406
+ module_eval(<<'.,.,', 'kdl.yy', 31)
407
+ def _reduce_19(val, _values)
408
+ val[0]
409
+ end
410
+ .,.,
411
+
412
+ module_eval(<<'.,.,', 'kdl.yy', 32)
413
+ def _reduce_20(val, _values)
414
+ val[0].tap { |x| x.properties[val[2][0]] = val[2][1] }
415
+ end
416
+ .,.,
417
+
418
+ module_eval(<<'.,.,', 'kdl.yy', 33)
419
+ def _reduce_21(val, _values)
420
+ val[0]
421
+ end
422
+ .,.,
423
+
424
+ module_eval(<<'.,.,', 'kdl.yy', 34)
425
+ def _reduce_22(val, _values)
426
+ val[0]
427
+ end
428
+ .,.,
429
+
430
+ # reduce 23 omitted
431
+
432
+ module_eval(<<'.,.,', 'kdl.yy', 36)
433
+ def _reduce_24(val, _values)
434
+ val[2]
435
+ end
436
+ .,.,
437
+
438
+ module_eval(<<'.,.,', 'kdl.yy', 37)
439
+ def _reduce_25(val, _values)
440
+ []
441
+ end
442
+ .,.,
443
+
444
+ module_eval(<<'.,.,', 'kdl.yy', 38)
445
+ def _reduce_26(val, _values)
446
+ [*val[2], val[3]]
447
+ end
448
+ .,.,
449
+
450
+ module_eval(<<'.,.,', 'kdl.yy', 39)
451
+ def _reduce_27(val, _values)
452
+ [val[3]]
453
+ end
454
+ .,.,
455
+
456
+ # reduce 28 omitted
457
+
458
+ # reduce 29 omitted
459
+
460
+ # reduce 30 omitted
461
+
462
+ # reduce 31 omitted
463
+
464
+ # reduce 32 omitted
465
+
466
+ # reduce 33 omitted
467
+
468
+ # reduce 34 omitted
469
+
470
+ # reduce 35 omitted
471
+
472
+ # reduce 36 omitted
473
+
474
+ # reduce 37 omitted
475
+
476
+ # reduce 38 omitted
477
+
478
+ module_eval(<<'.,.,', 'kdl.yy', 47)
479
+ def _reduce_39(val, _values)
480
+ val[2]
481
+ end
482
+ .,.,
483
+
484
+ module_eval(<<'.,.,', 'kdl.yy', 49)
485
+ def _reduce_40(val, _values)
486
+ val[0].value
487
+ end
488
+ .,.,
489
+
490
+ module_eval(<<'.,.,', 'kdl.yy', 50)
491
+ def _reduce_41(val, _values)
492
+ val[0].value
493
+ end
494
+ .,.,
495
+
496
+ module_eval(<<'.,.,', 'kdl.yy', 51)
497
+ def _reduce_42(val, _values)
498
+ val[0].value
499
+ end
500
+ .,.,
501
+
502
+ module_eval(<<'.,.,', 'kdl.yy', 53)
503
+ def _reduce_43(val, _values)
504
+ [val[0], val[2]]
505
+ end
506
+ .,.,
507
+
508
+ # reduce 44 omitted
509
+
510
+ module_eval(<<'.,.,', 'kdl.yy', 56)
511
+ def _reduce_45(val, _values)
512
+ val[1].as_type(val[0], @type_parsers.fetch(val[0], nil))
513
+ end
514
+ .,.,
515
+
516
+ module_eval(<<'.,.,', 'kdl.yy', 58)
517
+ def _reduce_46(val, _values)
518
+ @output_module::Value::String.new(val[0].value)
519
+ end
520
+ .,.,
521
+
522
+ module_eval(<<'.,.,', 'kdl.yy', 59)
523
+ def _reduce_47(val, _values)
524
+ @output_module::Value::String.new(val[0].value)
525
+ end
526
+ .,.,
527
+
528
+ module_eval(<<'.,.,', 'kdl.yy', 60)
529
+ def _reduce_48(val, _values)
530
+ @output_module::Value::Int.new(val[0].value)
531
+ end
532
+ .,.,
533
+
534
+ module_eval(<<'.,.,', 'kdl.yy', 61)
535
+ def _reduce_49(val, _values)
536
+ @output_module::Value::Float.new(val[0].value, format: val[0].meta[:format])
537
+ end
538
+ .,.,
539
+
540
+ module_eval(<<'.,.,', 'kdl.yy', 62)
541
+ def _reduce_50(val, _values)
542
+ @output_module::Value::Boolean.new(val[0])
543
+ end
544
+ .,.,
545
+
546
+ module_eval(<<'.,.,', 'kdl.yy', 63)
547
+ def _reduce_51(val, _values)
548
+ @output_module::Value::Null
549
+ end
550
+ .,.,
551
+
552
+ module_eval(<<'.,.,', 'kdl.yy', 65)
553
+ def _reduce_52(val, _values)
554
+ true
555
+ end
556
+ .,.,
557
+
558
+ module_eval(<<'.,.,', 'kdl.yy', 66)
559
+ def _reduce_53(val, _values)
560
+ false
561
+ end
562
+ .,.,
563
+
564
+ # reduce 54 omitted
565
+
566
+ # reduce 55 omitted
567
+
568
+ # reduce 56 omitted
569
+
570
+ # reduce 57 omitted
571
+
572
+ # reduce 58 omitted
573
+
574
+ # reduce 59 omitted
575
+
576
+ # reduce 60 omitted
577
+
578
+ # reduce 61 omitted
579
+
580
+ # reduce 62 omitted
581
+
582
+ module_eval(<<'.,.,', 'kdl.yy', 73)
583
+ def _reduce_63(val, _values)
584
+ nil
585
+ end
586
+ .,.,
587
+
588
+ def _reduce_none(val, _values)
589
+ val[0]
590
+ end
591
+
592
+ end # class Parser
593
+ end # module V1
594
+ end # module KDL
data/lib/kdl/v1/kdl.yy ADDED
@@ -0,0 +1,89 @@
1
+ class KDL::V1::Parser
2
+ options no_result_var
3
+ token IDENT STRING RAWSTRING
4
+ INTEGER FLOAT TRUE FALSE NULL
5
+ WS NEWLINE
6
+ LBRACE RBRACE
7
+ LPAREN RPAREN
8
+ EQUALS
9
+ SEMICOLON
10
+ EOF
11
+ SLASHDASH
12
+ rule
13
+ document : nodes { @output_module::Document.new(val[0]) }
14
+ | linespaces { @output_module::Document.new([]) }
15
+
16
+ nodes : none { [] }
17
+ | linespaces node { [val[1]] }
18
+ | linespaces empty_node { [] }
19
+ | nodes node { [*val[0], val[1]] }
20
+ | nodes empty_node { val[0] }
21
+ node : unterm_node node_term { val[0] }
22
+ unterm_node : untyped_node { val[0] }
23
+ | type untyped_node { val[1].as_type(val[0], @type_parsers.fetch(val[0], nil)) }
24
+ untyped_node : node_decl { val[0].tap { |x| x.children = [] } }
25
+ | node_decl node_children { val[0].tap { |x| x.children = val[1] } }
26
+ | node_decl empty_childrens { val[0].tap { |x| x.children = [] } }
27
+ | node_decl empty_childrens node_children { val[0].tap { |x| x.children = val[2] } }
28
+ | node_decl node_children empty_childrens { val[0].tap { |x| x.children = val[1] } }
29
+ | node_decl empty_childrens node_children empty_childrens { val[0].tap { |x| x.children = val[2] } }
30
+ node_decl : identifier { @output_module::Node.new(val[0]) }
31
+ | node_decl ws_plus value { val[0].tap { |x| x.arguments << val[2] } }
32
+ | node_decl ws_plus slashdash value { val[0] }
33
+ | node_decl ws_plus property { val[0].tap { |x| x.properties[val[2][0]] = val[2][1] } }
34
+ | node_decl ws_plus slashdash property { val[0] }
35
+ | node_decl ws_plus { val[0] }
36
+ empty_node : slashdash node
37
+ node_children : ws_star LBRACE nodes RBRACE { val[2] }
38
+ | ws_star LBRACE linespaces RBRACE { [] }
39
+ | ws_star LBRACE nodes unterm_node ws_star RBRACE { [*val[2], val[3]] }
40
+ | ws_star LBRACE linespaces unterm_node ws_star RBRACE { [val[3]] }
41
+ empty_children : slashdash node_children
42
+ | ws_plus empty_children
43
+ empty_childrens: empty_children | empty_childrens empty_children
44
+ node_term: linespaces | semicolon_term
45
+ semicolon_term: SEMICOLON | SEMICOLON linespaces
46
+ slashdash: SLASHDASH | slashdash ws_plus | slashdash linespaces
47
+
48
+ type : LPAREN ws_star identifier ws_star RPAREN { val[2] }
49
+
50
+ identifier : IDENT { val[0].value }
51
+ | STRING { val[0].value }
52
+ | RAWSTRING { val[0].value }
53
+
54
+ property : identifier EQUALS value { [val[0], val[2]] }
55
+
56
+ value : untyped_value
57
+ | type untyped_value { val[1].as_type(val[0], @type_parsers.fetch(val[0], nil)) }
58
+
59
+ untyped_value : STRING { @output_module::Value::String.new(val[0].value) }
60
+ | RAWSTRING { @output_module::Value::String.new(val[0].value) }
61
+ | INTEGER { @output_module::Value::Int.new(val[0].value) }
62
+ | FLOAT { @output_module::Value::Float.new(val[0].value, format: val[0].meta[:format]) }
63
+ | boolean { @output_module::Value::Boolean.new(val[0]) }
64
+ | NULL { @output_module::Value::Null }
65
+
66
+ boolean : TRUE { true }
67
+ | FALSE { false }
68
+
69
+ ws_plus: WS | WS ws_plus
70
+ ws_star: none | ws_plus
71
+ linespace: WS | NEWLINE | EOF
72
+ linespaces: linespace | linespaces linespace
73
+
74
+ none: { nil }
75
+
76
+ ---- inner
77
+
78
+ include KDL::ParserCommon
79
+
80
+ def parser_version
81
+ 1
82
+ end
83
+
84
+ def parse(str, **options)
85
+ init(**options)
86
+ @tokenizer = ::KDL::V1::Tokenizer.new(str)
87
+ check_version
88
+ do_parse
89
+ end
@@ -0,0 +1,30 @@
1
+ module KDL
2
+ module V1
3
+ class Node < ::KDL::Node
4
+ def version
5
+ 1
6
+ end
7
+
8
+ def to_v1
9
+ self
10
+ end
11
+
12
+ def to_v2
13
+ ::KDL::Node.new(name,
14
+ arguments: arguments.map(&:to_v2),
15
+ properties: properties.transform_values(&:to_v2),
16
+ children: children.map(&:to_v2),
17
+ type: type
18
+ )
19
+ end
20
+
21
+ private
22
+
23
+ def id_to_s(id, m = :to_s)
24
+ return id.public_send(m) unless m == :to_s
25
+
26
+ StringDumper.stringify_identifier(id)
27
+ end
28
+ end
29
+ end
30
+ end