tomlrb 2.0.4 → 2.0.5
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/scanner.rb +3 -3
- data/lib/tomlrb/version.rb +1 -1
- metadata +6 -7
- data/lib/tomlrb/parser.y +0 -230
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aec8269e8038829c92db82e6e8c07d46f59ddf59e8b8f5efc71f32194d51ebe9
|
|
4
|
+
data.tar.gz: 935417690ae25dac4908969541c04104d6cf6f038158031e0990889c48401485
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef69a2e4e0fecc696b3a32f9ead5189d95d5a189f7fae3bd882d61686a4b9379af88289a4466174a850b5ec92c7ad5e0fb5cd394e1659356dbfe461e399a1613
|
|
7
|
+
data.tar.gz: df31d0060e144acf8c62d11e6af76d014042b50d29ee5e2d874bd15670e8151821a3b37fa2f95f3ad6e527dcbf33da638f4dc7a4e99a6377f1bdd1e94b919449
|
data/lib/tomlrb/scanner.rb
CHANGED
|
@@ -9,15 +9,15 @@ module Tomlrb
|
|
|
9
9
|
IDENTIFIER =
|
|
10
10
|
/[A-Za-z0-9_-]+/.freeze
|
|
11
11
|
SPACE =
|
|
12
|
-
/[ \t]
|
|
12
|
+
/[ \t]+/.freeze
|
|
13
13
|
NEWLINE =
|
|
14
14
|
/(?:[ \t]*(?:\r?\n)[ \t]*)+/.freeze
|
|
15
15
|
STRING_BASIC =
|
|
16
|
-
/
|
|
16
|
+
/"(?:[^\u0000-\u0008\u000A-\u001F\u007F"\\]|\\[^\u0000-\u0008\u000A-\u001F\u007F])*"/.freeze
|
|
17
17
|
STRING_MULTI =
|
|
18
18
|
/"{3}([^\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]*?(?<!\\)"{3,5})/m.freeze
|
|
19
19
|
STRING_LITERAL =
|
|
20
|
-
/
|
|
20
|
+
/'[^\u0000-\u0008\u000A-\u001F\u007F']*'/.freeze
|
|
21
21
|
STRING_LITERAL_MULTI =
|
|
22
22
|
/'{3}([^\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]*?'{3,5})/m.freeze
|
|
23
23
|
DATETIME =
|
data/lib/tomlrb/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Francois Bernier
|
|
@@ -10,19 +10,19 @@ cert_chain: []
|
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
13
|
+
name: racc
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '4'
|
|
19
|
-
type: :
|
|
18
|
+
version: '1.4'
|
|
19
|
+
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '4'
|
|
25
|
+
version: '1.4'
|
|
26
26
|
description: A racc based toml parser
|
|
27
27
|
email:
|
|
28
28
|
- frankbernier@gmail.com
|
|
@@ -38,7 +38,6 @@ files:
|
|
|
38
38
|
- lib/tomlrb/local_date_time.rb
|
|
39
39
|
- lib/tomlrb/local_time.rb
|
|
40
40
|
- lib/tomlrb/parser.rb
|
|
41
|
-
- lib/tomlrb/parser.y
|
|
42
41
|
- lib/tomlrb/scanner.rb
|
|
43
42
|
- lib/tomlrb/string_utils.rb
|
|
44
43
|
- lib/tomlrb/version.rb
|
|
@@ -60,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
60
|
version: '0'
|
|
62
61
|
requirements: []
|
|
63
|
-
rubygems_version:
|
|
62
|
+
rubygems_version: 4.0.20
|
|
64
63
|
specification_version: 4
|
|
65
64
|
summary: A racc based toml parser
|
|
66
65
|
test_files: []
|
data/lib/tomlrb/parser.y
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
class Tomlrb::GeneratedParser
|
|
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
|
-
rule
|
|
4
|
-
expressions
|
|
5
|
-
| expressions expression
|
|
6
|
-
| expressions EOS
|
|
7
|
-
;
|
|
8
|
-
expression
|
|
9
|
-
: table
|
|
10
|
-
| assignment
|
|
11
|
-
| inline_table
|
|
12
|
-
| NEWLINE
|
|
13
|
-
;
|
|
14
|
-
table
|
|
15
|
-
: table_start table_identifier table_end newlines
|
|
16
|
-
| table_start table_identifier table_end EOS
|
|
17
|
-
| table_start table_end newlines
|
|
18
|
-
| table_start table_end EOS
|
|
19
|
-
;
|
|
20
|
-
table_start
|
|
21
|
-
: '[' '[' { @handler.start_(:array_of_tables) }
|
|
22
|
-
| '[' { @handler.start_(:table) }
|
|
23
|
-
;
|
|
24
|
-
;
|
|
25
|
-
table_end
|
|
26
|
-
: ']' ']' { array = @handler.end_(:array_of_tables); @handler.set_context(array, is_array_of_tables: true) }
|
|
27
|
-
| ']' { array = @handler.end_(:table); @handler.set_context(array) }
|
|
28
|
-
;
|
|
29
|
-
table_identifier
|
|
30
|
-
: table_identifier '.' table_identifier_component { @handler.push(val[2]) }
|
|
31
|
-
| table_identifier '.' FLOAT { val[2].split('.').each { |k| @handler.push(k) } }
|
|
32
|
-
| FLOAT {
|
|
33
|
-
keys = val[0].split('.')
|
|
34
|
-
@handler.start_(:table)
|
|
35
|
-
keys.each { |key| @handler.push(key) }
|
|
36
|
-
}
|
|
37
|
-
| table_identifier_component { @handler.push(val[0]) }
|
|
38
|
-
;
|
|
39
|
-
table_identifier_component
|
|
40
|
-
: IDENTIFIER
|
|
41
|
-
| STRING_BASIC { result = StringUtils.replace_escaped_chars(val[0]) }
|
|
42
|
-
| STRING_LITERAL
|
|
43
|
-
| INTEGER
|
|
44
|
-
| NON_DEC_INTEGER
|
|
45
|
-
| FLOAT_KEYWORD
|
|
46
|
-
| BOOLEAN
|
|
47
|
-
| DATETIME { result = val[0][0] }
|
|
48
|
-
| LOCAL_TIME { result = val[0][0] }
|
|
49
|
-
;
|
|
50
|
-
inline_table
|
|
51
|
-
: inline_table_start inline_table_end
|
|
52
|
-
| inline_table_start inline_continued inline_table_end
|
|
53
|
-
;
|
|
54
|
-
inline_table_start
|
|
55
|
-
: '{' { @handler.start_(:inline) }
|
|
56
|
-
;
|
|
57
|
-
inline_table_end
|
|
58
|
-
: '}' {
|
|
59
|
-
array = @handler.end_(:inline)
|
|
60
|
-
@handler.push_inline(array)
|
|
61
|
-
}
|
|
62
|
-
;
|
|
63
|
-
inline_continued
|
|
64
|
-
: inline_assignment
|
|
65
|
-
| inline_assignment inline_next
|
|
66
|
-
;
|
|
67
|
-
inline_next
|
|
68
|
-
: ',' inline_continued
|
|
69
|
-
;
|
|
70
|
-
inline_assignment
|
|
71
|
-
: inline_assignment_key '=' value {
|
|
72
|
-
keys = @handler.end_(:inline_keys)
|
|
73
|
-
@handler.push(keys)
|
|
74
|
-
}
|
|
75
|
-
;
|
|
76
|
-
inline_assignment_key
|
|
77
|
-
: inline_assignment_key '.' assignment_key_component {
|
|
78
|
-
@handler.push(val[2])
|
|
79
|
-
}
|
|
80
|
-
| inline_assignment_key '.' FLOAT { val[2].split('.').each { |k| @handler.push(k) } }
|
|
81
|
-
| FLOAT {
|
|
82
|
-
keys = val[0].split('.')
|
|
83
|
-
@handler.start_(:inline_keys)
|
|
84
|
-
keys.each { |key| @handler.push(key) }
|
|
85
|
-
}
|
|
86
|
-
| assignment_key_component {
|
|
87
|
-
@handler.start_(:inline_keys)
|
|
88
|
-
@handler.push(val[0])
|
|
89
|
-
}
|
|
90
|
-
;
|
|
91
|
-
assignment
|
|
92
|
-
: assignment_key '=' value EOS {
|
|
93
|
-
keys = @handler.end_(:keys)
|
|
94
|
-
value = keys.pop
|
|
95
|
-
@handler.validate_value(value)
|
|
96
|
-
@handler.push(value)
|
|
97
|
-
@handler.assign(keys)
|
|
98
|
-
}
|
|
99
|
-
| assignment_key '=' value NEWLINE {
|
|
100
|
-
keys = @handler.end_(:keys)
|
|
101
|
-
value = keys.pop
|
|
102
|
-
@handler.validate_value(value)
|
|
103
|
-
@handler.push(value)
|
|
104
|
-
@handler.assign(keys)
|
|
105
|
-
}
|
|
106
|
-
;
|
|
107
|
-
assignment_key
|
|
108
|
-
: assignment_key '.' assignment_key_component { @handler.push(val[2]) }
|
|
109
|
-
| assignment_key '.' FLOAT { val[2].split('.').each { |k| @handler.push(k) } }
|
|
110
|
-
| FLOAT {
|
|
111
|
-
keys = val[0].split('.')
|
|
112
|
-
@handler.start_(:keys)
|
|
113
|
-
keys.each { |key| @handler.push(key) }
|
|
114
|
-
}
|
|
115
|
-
| assignment_key_component { @handler.start_(:keys); @handler.push(val[0]) }
|
|
116
|
-
;
|
|
117
|
-
assignment_key_component
|
|
118
|
-
: IDENTIFIER
|
|
119
|
-
| STRING_BASIC { result = StringUtils.replace_escaped_chars(val[0]) }
|
|
120
|
-
| STRING_LITERAL
|
|
121
|
-
| INTEGER
|
|
122
|
-
| NON_DEC_INTEGER
|
|
123
|
-
| FLOAT_KEYWORD
|
|
124
|
-
| BOOLEAN
|
|
125
|
-
| DATETIME { result = val[0][0] }
|
|
126
|
-
| LOCAL_TIME { result = val[0][0] }
|
|
127
|
-
;
|
|
128
|
-
array
|
|
129
|
-
: start_array array_first_value array_values comma end_array
|
|
130
|
-
| start_array array_first_value array_values end_array
|
|
131
|
-
| start_array array_first_value comma end_array
|
|
132
|
-
| start_array array_first_value end_array
|
|
133
|
-
| start_array end_array
|
|
134
|
-
;
|
|
135
|
-
array_first_value
|
|
136
|
-
: newlines non_nil_value
|
|
137
|
-
| non_nil_value
|
|
138
|
-
;
|
|
139
|
-
array_values
|
|
140
|
-
: array_values array_value
|
|
141
|
-
| array_value
|
|
142
|
-
;
|
|
143
|
-
array_value
|
|
144
|
-
: comma newlines non_nil_value
|
|
145
|
-
| comma non_nil_value
|
|
146
|
-
;
|
|
147
|
-
start_array
|
|
148
|
-
: '[' { @handler.start_(:array) }
|
|
149
|
-
;
|
|
150
|
-
end_array
|
|
151
|
-
: newlines ']' { array = @handler.end_(:array); @handler.push(array.compact) }
|
|
152
|
-
| ']' { array = @handler.end_(:array); @handler.push(array.compact) }
|
|
153
|
-
;
|
|
154
|
-
comma
|
|
155
|
-
: newlines ','
|
|
156
|
-
| ','
|
|
157
|
-
;
|
|
158
|
-
newlines
|
|
159
|
-
: newlines NEWLINE
|
|
160
|
-
| NEWLINE
|
|
161
|
-
;
|
|
162
|
-
value
|
|
163
|
-
: scalar { @handler.push(val[0]) }
|
|
164
|
-
| array
|
|
165
|
-
| inline_table
|
|
166
|
-
;
|
|
167
|
-
non_nil_value
|
|
168
|
-
: non_nil_scalar { @handler.push(val[0]) }
|
|
169
|
-
| array
|
|
170
|
-
| inline_table
|
|
171
|
-
;
|
|
172
|
-
scalar
|
|
173
|
-
: string
|
|
174
|
-
| literal
|
|
175
|
-
;
|
|
176
|
-
non_nil_scalar
|
|
177
|
-
: string
|
|
178
|
-
| non_nil_literal
|
|
179
|
-
;
|
|
180
|
-
literal
|
|
181
|
-
| non_nil_literal
|
|
182
|
-
;
|
|
183
|
-
non_nil_literal
|
|
184
|
-
: FLOAT { result = val[0].to_f }
|
|
185
|
-
| FLOAT_KEYWORD {
|
|
186
|
-
v = val[0]
|
|
187
|
-
result = if v.end_with?('nan')
|
|
188
|
-
Float::NAN
|
|
189
|
-
else
|
|
190
|
-
(v[0] == '-' ? -1 : 1) * Float::INFINITY
|
|
191
|
-
end
|
|
192
|
-
}
|
|
193
|
-
| INTEGER { result = val[0].to_i }
|
|
194
|
-
| NON_DEC_INTEGER {
|
|
195
|
-
base = case val[0][1]
|
|
196
|
-
when 'x' then 16
|
|
197
|
-
when 'o' then 8
|
|
198
|
-
when 'b' then 2
|
|
199
|
-
end
|
|
200
|
-
result = val[0].to_i(base)
|
|
201
|
-
}
|
|
202
|
-
| BOOLEAN { result = val[0] == 'true' ? true : false }
|
|
203
|
-
| DATETIME {
|
|
204
|
-
_str, year, month, day, hour, min, sec, offset = val[0]
|
|
205
|
-
result = if offset.nil?
|
|
206
|
-
if hour.nil?
|
|
207
|
-
LocalDate.new(year, month, day)
|
|
208
|
-
else
|
|
209
|
-
LocalDateTime.new(year, month, day, hour, min || 0, sec.to_f)
|
|
210
|
-
end
|
|
211
|
-
else
|
|
212
|
-
# Patch for 24:00:00 which Ruby parses
|
|
213
|
-
if hour.to_i == 24 && min.to_i == 0 && sec.to_i == 0
|
|
214
|
-
hour = (hour.to_i + 1).to_s
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
time = Time.new(year, month, day, hour || 0, min || 0, sec.to_f, offset)
|
|
218
|
-
# Should be out of parser.y?
|
|
219
|
-
raise ArgumentError, "Invalid Offset Date-Time: #{year}-#{month}-#{day}T#{hour}:#{min}:#{sec}#{offset}" unless min.to_i == time.min && hour.to_i == time.hour && day.to_i == time.day && month.to_i == time.month && year.to_i == time.year
|
|
220
|
-
time
|
|
221
|
-
end
|
|
222
|
-
}
|
|
223
|
-
| LOCAL_TIME { result = LocalTime.new(*val[0][1..-1]) }
|
|
224
|
-
;
|
|
225
|
-
string
|
|
226
|
-
: STRING_MULTI { result = StringUtils.replace_escaped_chars(StringUtils.multiline_replacements(val[0])) }
|
|
227
|
-
| STRING_BASIC { result = StringUtils.replace_escaped_chars(val[0]) }
|
|
228
|
-
| STRING_LITERAL_MULTI { result = StringUtils.strip_spaces(val[0]) }
|
|
229
|
-
| STRING_LITERAL { result = val[0] }
|
|
230
|
-
;
|