kdl 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -1
- data/README.md +17 -1
- data/lib/kdl/document.rb +2 -0
- data/lib/kdl/error.rb +24 -0
- data/lib/kdl/kdl.tab.rb +128 -129
- data/lib/kdl/kdl.yy +7 -7
- data/lib/kdl/node.rb +7 -5
- data/lib/kdl/parser_common.rb +3 -1
- data/lib/kdl/string_dumper.rb +2 -0
- data/lib/kdl/tokenizer.rb +79 -65
- data/lib/kdl/types/base64.rb +2 -0
- data/lib/kdl/types/country/iso3166_countries.rb +2 -0
- data/lib/kdl/types/country/iso3166_subdivisions.rb +2 -0
- data/lib/kdl/types/country.rb +2 -0
- data/lib/kdl/types/currency/iso4217_currencies.rb +2 -0
- data/lib/kdl/types/currency.rb +2 -0
- data/lib/kdl/types/date_time.rb +2 -0
- data/lib/kdl/types/decimal.rb +2 -0
- data/lib/kdl/types/duration/iso8601_parser.rb +2 -0
- data/lib/kdl/types/duration.rb +2 -0
- data/lib/kdl/types/email/parser.rb +9 -7
- data/lib/kdl/types/email.rb +2 -0
- data/lib/kdl/types/hostname/validator.rb +2 -0
- data/lib/kdl/types/hostname.rb +2 -0
- data/lib/kdl/types/ip.rb +2 -0
- data/lib/kdl/types/irl/parser.rb +9 -7
- data/lib/kdl/types/irl.rb +2 -0
- data/lib/kdl/types/regex.rb +2 -0
- data/lib/kdl/types/url.rb +2 -0
- data/lib/kdl/types/url_template.rb +5 -3
- data/lib/kdl/types/uuid.rb +2 -0
- data/lib/kdl/types.rb +2 -0
- data/lib/kdl/v1/document.rb +2 -0
- data/lib/kdl/v1/node.rb +2 -0
- data/lib/kdl/v1/string_dumper.rb +2 -0
- data/lib/kdl/v1/tokenizer.rb +33 -31
- data/lib/kdl/v1/value.rb +2 -0
- data/lib/kdl/v1.rb +2 -0
- data/lib/kdl/value.rb +6 -3
- data/lib/kdl/version.rb +3 -1
- data/lib/kdl.rb +9 -2
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 323bc0f1637f5dea4aaa671d7582c87118d8a7500557fbbec5907d34082d0914
|
4
|
+
data.tar.gz: abd85e1a66342b328ad9da3946a14565ee300a0f5e77c5c5418cbc931cf8fe38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fafe1a9343387a093c324f84cccd47378a635c950f9892b9456d23f2c75fe2341ebb68ea09e0043b0672430fc0c799fb13263447ddb4586539cd5f306357c4b
|
7
|
+
data.tar.gz: 3cf0863f0e7751890f394f7f5d759adf980ca7b4fec872c40a1b75f71a08e380681bc8ed93e917567bbab337281b4c03a1a8f34760bd9fa66aefd67187a59a0e
|
data/.github/workflows/ruby.yml
CHANGED
data/README.md
CHANGED
@@ -66,12 +66,20 @@ The resulting document will also serialize back to the same version it was parse
|
|
66
66
|
KDL.parse(a_string, output_version: 2)
|
67
67
|
```
|
68
68
|
|
69
|
-
This allows you to to convert
|
69
|
+
This allows you to to convert documents between versions:
|
70
70
|
|
71
71
|
```ruby
|
72
72
|
KDL.parse('foo "bar" true', version: 1, output_version: 2).to_s #=> 'foo bar #true'
|
73
73
|
```
|
74
74
|
|
75
|
+
You can also convert an already parsed document between versions with `to_v1` and `to_v2`:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
doc = KDL.parse('foo "bar" true', version: 1)
|
79
|
+
doc.version #=> 1
|
80
|
+
doc.to_v2.to_s #=> 'foo bar #true'
|
81
|
+
```
|
82
|
+
|
75
83
|
You can also set the default version globally:
|
76
84
|
|
77
85
|
```ruby
|
@@ -79,6 +87,14 @@ KDL.default_version = 2
|
|
79
87
|
KDL.default_output_version = 2
|
80
88
|
```
|
81
89
|
|
90
|
+
You can still force automatic version detection with `auto_parse`:
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
KDL.default_version = 2
|
94
|
+
KDL.parse('foo "bar" true') #=> Error
|
95
|
+
KDL.auto_parse('foo "bar" true') #=> KDL::V1::Document
|
96
|
+
```
|
97
|
+
|
82
98
|
Version directives are also respected:
|
83
99
|
|
84
100
|
```ruby
|
data/lib/kdl/document.rb
CHANGED
data/lib/kdl/error.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KDL
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
class VersionMismatchError < Error
|
7
|
+
attr_reader :version, :parser_version
|
8
|
+
|
9
|
+
def initialize(message, version = nil, parser_version = nil)
|
10
|
+
super(message)
|
11
|
+
@version = version
|
12
|
+
@parser_version = parser_version
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class UnsupportedVersionError < Error
|
17
|
+
attr_reader :version
|
18
|
+
|
19
|
+
def initialize(message, version = nil)
|
20
|
+
super(message)
|
21
|
+
@version = version
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/kdl/kdl.tab.rb
CHANGED
@@ -29,98 +29,100 @@ module_eval(<<'...end kdl.yy/module_eval...', 'kdl.yy', 78)
|
|
29
29
|
##### State transition tables begin ###
|
30
30
|
|
31
31
|
racc_action_table = [
|
32
|
-
20, 21, 22,
|
33
|
-
|
34
|
-
18,
|
35
|
-
|
36
|
-
|
37
|
-
20, 21, 22, 7, 18,
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
5, 6, 7,
|
45
|
-
6,
|
46
|
-
|
47
|
-
|
32
|
+
20, 21, 22, 9, 33, 26, 20, 21, 22, 33,
|
33
|
+
33, 33, 19, 18, 5, 6, 33, 18, 19, 18,
|
34
|
+
18, 33, 7, 18, 48, 49, 50, 54, 55, 58,
|
35
|
+
59, 57, 33, 33, -63, -63, 19, 20, 21, 22,
|
36
|
+
71, 18, 18, -39, -40, 5, 6, -41, 85, 19,
|
37
|
+
20, 21, 22, 7, 18, 73, 20, 21, 22, 33,
|
38
|
+
33, 87, 19, 83, 5, 6, 33, 18, 19, 18,
|
39
|
+
91, 92, 7, 48, 49, 50, 54, 55, 58, 59,
|
40
|
+
57, 70, 6, nil, 33, 19, -54, -54, nil, 7,
|
41
|
+
75, 76, 77, 54, 55, 58, 59, 57, 33, 33,
|
42
|
+
nil, nil, 19, 5, 6, 5, 6, 18, 18, 5,
|
43
|
+
6, 7, 30, 7, 5, 6, nil, 7, 5, 6,
|
44
|
+
5, 6, 7, 70, 6, nil, 7, nil, 7, 5,
|
45
|
+
6, 7, 70, 6, 70, 6, nil, 7, nil, 30,
|
46
|
+
7, 30, 7, 75, 76, 77, 54, 55, 58, 59,
|
47
|
+
57, 20, 21, 22, 20, 21, 22 ]
|
48
48
|
|
49
49
|
racc_action_check = [
|
50
|
-
2, 2, 2,
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
50
|
+
2, 2, 2, 1, 40, 9, 3, 3, 3, 15,
|
51
|
+
46, 62, 2, 40, 3, 3, 19, 2, 3, 46,
|
52
|
+
62, 33, 3, 3, 32, 32, 32, 32, 32, 32,
|
53
|
+
32, 32, 32, 41, 32, 41, 32, 80, 80, 80,
|
54
|
+
45, 32, 41, 48, 49, 80, 80, 50, 80, 80,
|
55
|
+
81, 81, 81, 80, 80, 51, 17, 17, 17, 61,
|
56
|
+
64, 81, 81, 78, 17, 17, 83, 81, 17, 64,
|
57
|
+
89, 90, 17, 43, 43, 43, 43, 43, 43, 43,
|
58
|
+
43, 43, 43, nil, 70, 43, 70, 70, nil, 43,
|
59
|
+
73, 73, 73, 73, 73, 73, 73, 73, 65, 79,
|
60
|
+
nil, nil, 73, 0, 0, 12, 12, 65, 79, 28,
|
61
|
+
28, 0, 12, 12, 30, 30, nil, 28, 35, 35,
|
62
|
+
39, 39, 30, 63, 63, nil, 35, nil, 39, 71,
|
63
|
+
71, 63, 84, 84, 86, 86, nil, 71, nil, 84,
|
64
|
+
84, 86, 86, 53, 53, 53, 53, 53, 53, 53,
|
65
|
+
53, 14, 14, 14, 36, 36, 36 ]
|
66
66
|
|
67
67
|
racc_action_pointer = [
|
68
|
-
93,
|
69
|
-
nil, nil, 95, nil,
|
70
|
-
nil, nil, nil, nil, nil, nil, nil, nil,
|
71
|
-
|
72
|
-
nil, nil,
|
73
|
-
|
74
|
-
nil,
|
75
|
-
|
76
|
-
|
77
|
-
|
68
|
+
93, 3, -2, 4, nil, nil, nil, nil, nil, 5,
|
69
|
+
nil, nil, 95, nil, 149, -1, nil, 54, nil, 6,
|
70
|
+
nil, nil, nil, nil, nil, nil, nil, nil, 99, nil,
|
71
|
+
104, nil, 22, 11, nil, 108, 152, nil, nil, 110,
|
72
|
+
-6, 23, nil, 71, nil, 28, 0, nil, 27, 28,
|
73
|
+
31, 39, nil, 141, nil, nil, nil, nil, nil, nil,
|
74
|
+
nil, 49, 1, 113, 50, 88, nil, nil, nil, nil,
|
75
|
+
74, 119, nil, 88, nil, nil, nil, nil, 48, 89,
|
76
|
+
35, 48, nil, 56, 122, nil, 124, nil, nil, 57,
|
77
|
+
58, nil, nil ]
|
78
78
|
|
79
79
|
racc_action_default = [
|
80
|
-
-
|
81
|
-
-6, -7, -
|
82
|
-
-
|
83
|
-
-34, -10, -
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
80
|
+
-63, -64, -1, -2, -3, -58, -59, -60, -61, -64,
|
81
|
+
-6, -7, -64, -9, -64, -11, -17, -64, -36, -63,
|
82
|
+
-39, -40, -41, -4, -5, -62, 93, -8, -32, -33,
|
83
|
+
-34, -10, -22, -54, -23, -37, -64, -56, -57, -35,
|
84
|
+
-12, -13, -18, -63, -20, -64, -57, -30, -45, -46,
|
85
|
+
-47, -64, -43, -64, -48, -49, -50, -51, -52, -53,
|
86
|
+
-55, -63, -15, -63, -64, -14, -31, -19, -21, -28,
|
87
|
+
-58, -63, -29, -64, -44, -45, -46, -47, -64, -16,
|
88
|
+
-64, -64, -42, -63, -63, -25, -63, -24, -38, -64,
|
89
|
+
-64, -27, -26 ]
|
90
90
|
|
91
91
|
racc_goto_table = [
|
92
|
-
17, 17,
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
nil,
|
99
|
-
|
100
|
-
|
101
|
-
|
92
|
+
17, 17, 2, 23, 24, 3, 25, 36, 41, 53,
|
93
|
+
42, 4, 1, 44, 51, 31, 62, 34, 61, 74,
|
94
|
+
53, 67, 35, 66, 68, 51, nil, 40, 72, nil,
|
95
|
+
43, 25, 84, 86, nil, 39, 65, nil, 25, 32,
|
96
|
+
nil, 79, 25, nil, 66, nil, 72, nil, 35, 78,
|
97
|
+
53, 82, nil, nil, nil, nil, 46, 60, nil, nil,
|
98
|
+
nil, 66, nil, nil, 64, 46, nil, nil, 35, nil,
|
99
|
+
64, 88, 89, 81, 90, nil, 80, nil, 17, 17,
|
100
|
+
23, 24, 4, 25, nil, nil, 64, nil, 64, 64,
|
101
|
+
nil, nil, nil, nil, 60, nil, nil, nil, nil, nil,
|
102
|
+
nil, nil, nil, 64 ]
|
102
103
|
|
103
104
|
racc_goto_check = [
|
104
|
-
17, 17,
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
nil,
|
111
|
-
19,
|
112
|
-
|
113
|
-
|
105
|
+
17, 17, 2, 5, 6, 3, 24, 19, 14, 10,
|
106
|
+
16, 4, 1, 18, 15, 9, 14, 5, 15, 22,
|
107
|
+
10, 16, 3, 20, 18, 15, nil, 13, 20, nil,
|
108
|
+
17, 24, 7, 7, nil, 3, 13, nil, 24, 12,
|
109
|
+
nil, 14, 24, nil, 20, nil, 20, nil, 3, 19,
|
110
|
+
10, 16, nil, nil, nil, nil, 12, 12, nil, nil,
|
111
|
+
nil, 20, nil, nil, 12, 12, nil, nil, 3, nil,
|
112
|
+
12, 19, 19, 2, 19, nil, 3, nil, 17, 17,
|
113
|
+
5, 6, 4, 24, nil, nil, 12, nil, 12, 12,
|
114
|
+
nil, nil, nil, nil, 12, nil, nil, nil, nil, nil,
|
115
|
+
nil, nil, nil, 12 ]
|
114
116
|
|
115
117
|
racc_goto_pointer = [
|
116
|
-
nil, 12,
|
117
|
-
-
|
118
|
-
-
|
118
|
+
nil, 12, 2, 5, 11, 0, 1, -48, nil, 1,
|
119
|
+
-23, nil, 24, -5, -24, -18, -22, -2, -19, -12,
|
120
|
+
-18, nil, -34, nil, 3 ]
|
119
121
|
|
120
122
|
racc_goto_default = [
|
121
|
-
nil, nil, nil, 28,
|
122
|
-
14, 15, 69, nil, 16,
|
123
|
-
|
123
|
+
nil, nil, nil, 28, 37, 10, 11, 12, 27, 13,
|
124
|
+
14, 15, 38, 69, nil, 16, nil, 63, nil, 45,
|
125
|
+
47, 29, 52, 56, 8 ]
|
124
126
|
|
125
127
|
racc_reduce_table = [
|
126
128
|
0, 0, :racc_error,
|
@@ -135,11 +137,11 @@ racc_reduce_table = [
|
|
135
137
|
1, 27, :_reduce_9,
|
136
138
|
2, 27, :_reduce_10,
|
137
139
|
1, 29, :_reduce_11,
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
140
|
+
3, 29, :_reduce_12,
|
141
|
+
3, 29, :_reduce_13,
|
142
|
+
4, 29, :_reduce_14,
|
143
|
+
4, 29, :_reduce_15,
|
144
|
+
5, 29, :_reduce_16,
|
143
145
|
1, 31, :_reduce_17,
|
144
146
|
3, 31, :_reduce_18,
|
145
147
|
4, 31, :_reduce_19,
|
@@ -147,39 +149,38 @@ racc_reduce_table = [
|
|
147
149
|
4, 31, :_reduce_21,
|
148
150
|
2, 31, :_reduce_22,
|
149
151
|
2, 26, :_reduce_none,
|
150
|
-
4,
|
151
|
-
4,
|
152
|
-
6,
|
153
|
-
6,
|
152
|
+
4, 33, :_reduce_24,
|
153
|
+
4, 33, :_reduce_25,
|
154
|
+
6, 33, :_reduce_26,
|
155
|
+
6, 33, :_reduce_27,
|
154
156
|
2, 40, :_reduce_none,
|
155
157
|
2, 40, :_reduce_none,
|
156
|
-
1,
|
157
|
-
2,
|
158
|
+
1, 34, :_reduce_none,
|
159
|
+
2, 34, :_reduce_none,
|
158
160
|
1, 28, :_reduce_none,
|
159
161
|
1, 28, :_reduce_none,
|
160
162
|
1, 41, :_reduce_none,
|
161
163
|
2, 41, :_reduce_none,
|
162
164
|
1, 37, :_reduce_none,
|
163
165
|
2, 37, :_reduce_none,
|
164
|
-
|
165
|
-
|
166
|
-
1,
|
167
|
-
1,
|
168
|
-
|
169
|
-
3, 38, :_reduce_43,
|
166
|
+
6, 30, :_reduce_38,
|
167
|
+
1, 35, :_reduce_39,
|
168
|
+
1, 35, :_reduce_40,
|
169
|
+
1, 35, :_reduce_41,
|
170
|
+
3, 38, :_reduce_42,
|
170
171
|
1, 36, :_reduce_none,
|
171
|
-
2, 36, :
|
172
|
+
2, 36, :_reduce_44,
|
173
|
+
1, 42, :_reduce_45,
|
172
174
|
1, 42, :_reduce_46,
|
173
175
|
1, 42, :_reduce_47,
|
174
176
|
1, 42, :_reduce_48,
|
175
177
|
1, 42, :_reduce_49,
|
176
178
|
1, 42, :_reduce_50,
|
177
179
|
1, 42, :_reduce_51,
|
178
|
-
1,
|
180
|
+
1, 43, :_reduce_52,
|
179
181
|
1, 43, :_reduce_53,
|
180
|
-
1,
|
181
|
-
|
182
|
-
2, 35, :_reduce_none,
|
182
|
+
1, 32, :_reduce_none,
|
183
|
+
2, 32, :_reduce_none,
|
183
184
|
1, 39, :_reduce_none,
|
184
185
|
1, 39, :_reduce_none,
|
185
186
|
1, 44, :_reduce_none,
|
@@ -187,11 +188,11 @@ racc_reduce_table = [
|
|
187
188
|
1, 44, :_reduce_none,
|
188
189
|
1, 23, :_reduce_none,
|
189
190
|
2, 23, :_reduce_none,
|
190
|
-
0, 24, :
|
191
|
+
0, 24, :_reduce_63 ]
|
191
192
|
|
192
|
-
racc_reduce_n =
|
193
|
+
racc_reduce_n = 64
|
193
194
|
|
194
|
-
racc_shift_n =
|
195
|
+
racc_shift_n = 93
|
195
196
|
|
196
197
|
racc_token_table = {
|
197
198
|
false => 0,
|
@@ -269,10 +270,10 @@ Racc_token_to_s_table = [
|
|
269
270
|
"untyped_node",
|
270
271
|
"type",
|
271
272
|
"node_decl",
|
273
|
+
"ws_plus",
|
272
274
|
"node_children",
|
273
275
|
"empty_childrens",
|
274
276
|
"identifier",
|
275
|
-
"ws_plus",
|
276
277
|
"value",
|
277
278
|
"slashdash",
|
278
279
|
"property",
|
@@ -358,7 +359,7 @@ module_eval(<<'.,.,', 'kdl.yy', 23)
|
|
358
359
|
|
359
360
|
module_eval(<<'.,.,', 'kdl.yy', 24)
|
360
361
|
def _reduce_12(val, _values)
|
361
|
-
val[0].tap { |x| x.children = val[
|
362
|
+
val[0].tap { |x| x.children = val[2] }
|
362
363
|
end
|
363
364
|
.,.,
|
364
365
|
|
@@ -370,19 +371,19 @@ module_eval(<<'.,.,', 'kdl.yy', 25)
|
|
370
371
|
|
371
372
|
module_eval(<<'.,.,', 'kdl.yy', 26)
|
372
373
|
def _reduce_14(val, _values)
|
373
|
-
val[0].tap { |x| x.children = val[
|
374
|
+
val[0].tap { |x| x.children = val[3] }
|
374
375
|
end
|
375
376
|
.,.,
|
376
377
|
|
377
378
|
module_eval(<<'.,.,', 'kdl.yy', 27)
|
378
379
|
def _reduce_15(val, _values)
|
379
|
-
val[0].tap { |x| x.children = val[
|
380
|
+
val[0].tap { |x| x.children = val[2] }
|
380
381
|
end
|
381
382
|
.,.,
|
382
383
|
|
383
384
|
module_eval(<<'.,.,', 'kdl.yy', 28)
|
384
385
|
def _reduce_16(val, _values)
|
385
|
-
val[0].tap { |x| x.children = val[
|
386
|
+
val[0].tap { |x| x.children = val[3] }
|
386
387
|
end
|
387
388
|
.,.,
|
388
389
|
|
@@ -468,100 +469,100 @@ module_eval(<<'.,.,', 'kdl.yy', 39)
|
|
468
469
|
|
469
470
|
# reduce 37 omitted
|
470
471
|
|
471
|
-
# reduce 38 omitted
|
472
|
-
|
473
472
|
module_eval(<<'.,.,', 'kdl.yy', 47)
|
474
|
-
def
|
473
|
+
def _reduce_38(val, _values)
|
475
474
|
val[2]
|
476
475
|
end
|
477
476
|
.,.,
|
478
477
|
|
479
478
|
module_eval(<<'.,.,', 'kdl.yy', 49)
|
480
|
-
def
|
479
|
+
def _reduce_39(val, _values)
|
481
480
|
val[0].value
|
482
481
|
end
|
483
482
|
.,.,
|
484
483
|
|
485
484
|
module_eval(<<'.,.,', 'kdl.yy', 50)
|
486
|
-
def
|
485
|
+
def _reduce_40(val, _values)
|
487
486
|
val[0].value
|
488
487
|
end
|
489
488
|
.,.,
|
490
489
|
|
491
490
|
module_eval(<<'.,.,', 'kdl.yy', 51)
|
492
|
-
def
|
491
|
+
def _reduce_41(val, _values)
|
493
492
|
val[0].value
|
494
493
|
end
|
495
494
|
.,.,
|
496
495
|
|
497
496
|
module_eval(<<'.,.,', 'kdl.yy', 53)
|
498
|
-
def
|
497
|
+
def _reduce_42(val, _values)
|
499
498
|
[val[0], val[2]]
|
500
499
|
end
|
501
500
|
.,.,
|
502
501
|
|
503
|
-
# reduce
|
502
|
+
# reduce 43 omitted
|
504
503
|
|
505
504
|
module_eval(<<'.,.,', 'kdl.yy', 56)
|
506
|
-
def
|
505
|
+
def _reduce_44(val, _values)
|
507
506
|
val[1].as_type(val[0], @type_parsers.fetch(val[0], nil))
|
508
507
|
end
|
509
508
|
.,.,
|
510
509
|
|
511
510
|
module_eval(<<'.,.,', 'kdl.yy', 58)
|
512
|
-
def
|
511
|
+
def _reduce_45(val, _values)
|
513
512
|
@output_module::Value::String.new(val[0].value)
|
514
513
|
end
|
515
514
|
.,.,
|
516
515
|
|
517
516
|
module_eval(<<'.,.,', 'kdl.yy', 59)
|
518
|
-
def
|
517
|
+
def _reduce_46(val, _values)
|
519
518
|
@output_module::Value::String.new(val[0].value)
|
520
519
|
end
|
521
520
|
.,.,
|
522
521
|
|
523
522
|
module_eval(<<'.,.,', 'kdl.yy', 60)
|
524
|
-
def
|
523
|
+
def _reduce_47(val, _values)
|
525
524
|
@output_module::Value::String.new(val[0].value)
|
526
525
|
end
|
527
526
|
.,.,
|
528
527
|
|
529
528
|
module_eval(<<'.,.,', 'kdl.yy', 61)
|
530
|
-
def
|
529
|
+
def _reduce_48(val, _values)
|
531
530
|
@output_module::Value::Int.new(val[0].value)
|
532
531
|
end
|
533
532
|
.,.,
|
534
533
|
|
535
534
|
module_eval(<<'.,.,', 'kdl.yy', 62)
|
536
|
-
def
|
535
|
+
def _reduce_49(val, _values)
|
537
536
|
@output_module::Value::Float.new(val[0].value, format: val[0].meta[:format])
|
538
537
|
end
|
539
538
|
.,.,
|
540
539
|
|
541
540
|
module_eval(<<'.,.,', 'kdl.yy', 63)
|
542
|
-
def
|
541
|
+
def _reduce_50(val, _values)
|
543
542
|
@output_module::Value::Boolean.new(val[0])
|
544
543
|
end
|
545
544
|
.,.,
|
546
545
|
|
547
546
|
module_eval(<<'.,.,', 'kdl.yy', 64)
|
548
|
-
def
|
547
|
+
def _reduce_51(val, _values)
|
549
548
|
@output_module::Value::Null
|
550
549
|
end
|
551
550
|
.,.,
|
552
551
|
|
553
552
|
module_eval(<<'.,.,', 'kdl.yy', 66)
|
554
|
-
def
|
553
|
+
def _reduce_52(val, _values)
|
555
554
|
true
|
556
555
|
end
|
557
556
|
.,.,
|
558
557
|
|
559
558
|
module_eval(<<'.,.,', 'kdl.yy', 67)
|
560
|
-
def
|
559
|
+
def _reduce_53(val, _values)
|
561
560
|
false
|
562
561
|
end
|
563
562
|
.,.,
|
564
563
|
|
564
|
+
# reduce 54 omitted
|
565
|
+
|
565
566
|
# reduce 55 omitted
|
566
567
|
|
567
568
|
# reduce 56 omitted
|
@@ -578,10 +579,8 @@ module_eval(<<'.,.,', 'kdl.yy', 67)
|
|
578
579
|
|
579
580
|
# reduce 62 omitted
|
580
581
|
|
581
|
-
# reduce 63 omitted
|
582
|
-
|
583
582
|
module_eval(<<'.,.,', 'kdl.yy', 74)
|
584
|
-
def
|
583
|
+
def _reduce_63(val, _values)
|
585
584
|
nil
|
586
585
|
end
|
587
586
|
.,.,
|
data/lib/kdl/kdl.yy
CHANGED
@@ -21,12 +21,12 @@ rule
|
|
21
21
|
node : unterm_node node_term { val[0] }
|
22
22
|
unterm_node : untyped_node { val[0] }
|
23
23
|
| type untyped_node { val[1].as_type(val[0], @type_parsers.fetch(val[0], nil)) }
|
24
|
-
untyped_node : node_decl
|
25
|
-
| node_decl node_children { val[0].tap { |x| x.children = val[
|
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[
|
28
|
-
| node_decl node_children empty_childrens { val[0].tap { |x| x.children = val[
|
29
|
-
| node_decl empty_childrens node_children empty_childrens { val[0].tap { |x| x.children = val[
|
24
|
+
untyped_node : node_decl { val[0].tap { |x| x.children = [] } }
|
25
|
+
| node_decl ws_plus node_children { val[0].tap { |x| x.children = val[2] } }
|
26
|
+
| node_decl ws_plus empty_childrens { val[0].tap { |x| x.children = [] } }
|
27
|
+
| node_decl ws_plus empty_childrens node_children { val[0].tap { |x| x.children = val[3] } }
|
28
|
+
| node_decl ws_plus node_children empty_childrens { val[0].tap { |x| x.children = val[2] } }
|
29
|
+
| node_decl ws_plus empty_childrens node_children empty_childrens { val[0].tap { |x| x.children = val[3] } }
|
30
30
|
node_decl : identifier { @output_module::Node.new(val[0]) }
|
31
31
|
| node_decl ws_plus value { val[0].tap { |x| x.arguments << val[2] } }
|
32
32
|
| node_decl ws_plus slashdash value { val[0] }
|
@@ -43,7 +43,7 @@ rule
|
|
43
43
|
empty_childrens: empty_children | empty_childrens empty_children
|
44
44
|
node_term: linespaces | semicolon_term
|
45
45
|
semicolon_term: SEMICOLON | SEMICOLON linespaces
|
46
|
-
slashdash: SLASHDASH | slashdash
|
46
|
+
slashdash: SLASHDASH | slashdash linespaces
|
47
47
|
|
48
48
|
type : LPAREN ws_star identifier ws_star RPAREN ws_star { val[2] }
|
49
49
|
|
data/lib/kdl/node.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module KDL
|
2
4
|
class Node
|
3
5
|
class Custom < Node
|
@@ -92,15 +94,15 @@ module KDL
|
|
92
94
|
indent = ' ' * level
|
93
95
|
s = "#{indent}#{type ? "(#{id_to_s type, m })" : ''}#{id_to_s name, m}"
|
94
96
|
unless arguments.empty?
|
95
|
-
s
|
97
|
+
s << " #{arguments.map(&m).join(' ')}"
|
96
98
|
end
|
97
99
|
unless properties.empty?
|
98
|
-
s
|
100
|
+
s << " #{properties.map { |k, v| "#{id_to_s k, m}=#{v.public_send(m)}" }.join(' ')}"
|
99
101
|
end
|
100
102
|
unless children.empty?
|
101
|
-
s
|
102
|
-
s
|
103
|
-
s
|
103
|
+
s << " {\n"
|
104
|
+
s << children.map { |c| "#{c.public_send(m, level + 1)}" }.join("\n")
|
105
|
+
s << "\n#{indent}}"
|
104
106
|
end
|
105
107
|
s
|
106
108
|
end
|
data/lib/kdl/parser_common.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module KDL
|
2
4
|
module ParserCommon
|
3
5
|
|
@@ -19,7 +21,7 @@ module KDL
|
|
19
21
|
def check_version
|
20
22
|
return unless doc_version = @tokenizer.version_directive
|
21
23
|
if doc_version != parser_version
|
22
|
-
raise
|
24
|
+
raise VersionMismatchError.new("Version mismatch, document specified v#{doc_version}, but this is a v#{parser_version} parser", doc_version, parser_version)
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|