bracecomp 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bracecomp.tab.rb +309 -306
- data/lib/bracecomp.y +3 -3
- metadata +18 -38
data/lib/bracecomp.tab.rb
CHANGED
@@ -1,306 +1,309 @@
|
|
1
|
-
#
|
2
|
-
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by
|
4
|
-
# from
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'racc/parser'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
elsif (piece = @s.scan /\A[
|
33
|
-
yield
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
@tree =
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
when /\A(
|
117
|
-
expand_range($1, $2,
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
.,.,
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
end
|
280
|
-
.,.,
|
281
|
-
|
282
|
-
module_eval
|
283
|
-
def _reduce_12(
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.9
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
|
9
|
+
|
10
|
+
require 'strscan'
|
11
|
+
|
12
|
+
class BraceComp < Racc::Parser
|
13
|
+
|
14
|
+
module_eval(<<'...end bracecomp.y/module_eval...', 'bracecomp.y', 50)
|
15
|
+
|
16
|
+
attr_reader :tree
|
17
|
+
|
18
|
+
def initialize(obj)
|
19
|
+
@src = obj.is_a?(IO) ? obj.read : obj.to_s
|
20
|
+
@s = StringScanner.new(@src)
|
21
|
+
end
|
22
|
+
private :initialize
|
23
|
+
|
24
|
+
def scan
|
25
|
+
piece = nil
|
26
|
+
|
27
|
+
until @s.eos?
|
28
|
+
if (piece = @s.scan /\A\s+/)
|
29
|
+
# nothing to do
|
30
|
+
elsif (piece = @s.scan /\A[^{},]+/)
|
31
|
+
yield [:WORD, piece]
|
32
|
+
elsif (piece = @s.scan /\A[{},]/)
|
33
|
+
yield [piece, piece]
|
34
|
+
else
|
35
|
+
raise Racc::ParseError, 'parse error'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
yield [false, '$']
|
40
|
+
end
|
41
|
+
private :scan
|
42
|
+
|
43
|
+
def parse
|
44
|
+
begin
|
45
|
+
@tree = yyparse self, :scan
|
46
|
+
rescue Racc::ParseError
|
47
|
+
@tree = [@src]
|
48
|
+
end
|
49
|
+
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
def permutation(stack, ary = [], &block)
|
54
|
+
list = stack.shift
|
55
|
+
return unless list
|
56
|
+
|
57
|
+
list.each do |i|
|
58
|
+
if stack.empty?
|
59
|
+
block.call(ary + [i])
|
60
|
+
else
|
61
|
+
permutation(stack, ary + [i], &block)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
stack.unshift(list)
|
66
|
+
end
|
67
|
+
private :permutation
|
68
|
+
|
69
|
+
def swap(a, b)
|
70
|
+
[b, a]
|
71
|
+
end
|
72
|
+
private :swap
|
73
|
+
|
74
|
+
def expand_range(first, last, is_num)
|
75
|
+
reversed = false
|
76
|
+
format = nil
|
77
|
+
|
78
|
+
if is_num
|
79
|
+
if first =~ /\A0+/
|
80
|
+
format = "%0#{first.length}d"
|
81
|
+
end
|
82
|
+
|
83
|
+
first = first.to_i
|
84
|
+
last = last.to_i
|
85
|
+
end
|
86
|
+
|
87
|
+
if first > last
|
88
|
+
reversed = true
|
89
|
+
first, last = swap(first, last)
|
90
|
+
end
|
91
|
+
|
92
|
+
expanded = Range.new(first, last).to_a
|
93
|
+
|
94
|
+
if is_num and format
|
95
|
+
expanded = expanded.map {|i| format % i }
|
96
|
+
end
|
97
|
+
|
98
|
+
reversed ? expanded.reverse : expanded
|
99
|
+
end
|
100
|
+
private :expand_range
|
101
|
+
|
102
|
+
def expand
|
103
|
+
return nil unless @tree
|
104
|
+
|
105
|
+
src = ''
|
106
|
+
sets = []
|
107
|
+
|
108
|
+
@tree.each do |i|
|
109
|
+
if i.kind_of?(String)
|
110
|
+
src << i
|
111
|
+
else
|
112
|
+
i = i.map {|expr|
|
113
|
+
case expr
|
114
|
+
when /\A([a-zA-Z])\.\.([a-zA-Z])\Z/
|
115
|
+
expand_range($1, $2, false)
|
116
|
+
when /\A(\d+)\.\.(\d+)\Z/
|
117
|
+
expand_range($1, $2, true)
|
118
|
+
else
|
119
|
+
expr
|
120
|
+
end
|
121
|
+
}.flatten
|
122
|
+
|
123
|
+
sets << i
|
124
|
+
src << '%s'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
expandeds = []
|
129
|
+
|
130
|
+
if sets.empty?
|
131
|
+
expandeds << src
|
132
|
+
else
|
133
|
+
permutation(sets) do |seq|
|
134
|
+
expandeds << src % seq
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
expandeds
|
139
|
+
end
|
140
|
+
...end bracecomp.y/module_eval...
|
141
|
+
##### State transition tables begin ###
|
142
|
+
|
143
|
+
racc_action_table = [
|
144
|
+
6, 7, 8, 9, 6, 7, 8, 9, 16, 17,
|
145
|
+
14, 15, 10, 14 ]
|
146
|
+
|
147
|
+
racc_action_check = [
|
148
|
+
0, 0, 0, 0, 2, 2, 2, 2, 12, 12,
|
149
|
+
7, 10, 1, 17 ]
|
150
|
+
|
151
|
+
racc_action_pointer = [
|
152
|
+
-2, 12, 2, nil, nil, nil, nil, 8, nil, nil,
|
153
|
+
11, nil, 4, nil, nil, nil, nil, 11, nil ]
|
154
|
+
|
155
|
+
racc_action_default = [
|
156
|
+
-1, -16, -2, -3, -5, -6, -7, -8, -9, -10,
|
157
|
+
-16, -4, -16, -12, -15, 19, -11, -14, -13 ]
|
158
|
+
|
159
|
+
racc_goto_table = [
|
160
|
+
13, 3, 2, 11, 12, 1, nil, nil, nil, nil,
|
161
|
+
18 ]
|
162
|
+
|
163
|
+
racc_goto_check = [
|
164
|
+
7, 3, 2, 3, 6, 1, nil, nil, nil, nil,
|
165
|
+
7 ]
|
166
|
+
|
167
|
+
racc_goto_pointer = [
|
168
|
+
nil, 5, 2, 1, nil, nil, -3, -7 ]
|
169
|
+
|
170
|
+
racc_goto_default = [
|
171
|
+
nil, nil, nil, nil, 4, 5, nil, nil ]
|
172
|
+
|
173
|
+
racc_reduce_table = [
|
174
|
+
0, 0, :racc_error,
|
175
|
+
0, 7, :_reduce_none,
|
176
|
+
1, 7, :_reduce_none,
|
177
|
+
1, 8, :_reduce_3,
|
178
|
+
2, 8, :_reduce_4,
|
179
|
+
1, 9, :_reduce_none,
|
180
|
+
1, 9, :_reduce_none,
|
181
|
+
1, 10, :_reduce_none,
|
182
|
+
1, 10, :_reduce_none,
|
183
|
+
1, 10, :_reduce_none,
|
184
|
+
1, 10, :_reduce_none,
|
185
|
+
3, 11, :_reduce_11,
|
186
|
+
1, 12, :_reduce_12,
|
187
|
+
3, 12, :_reduce_13,
|
188
|
+
0, 13, :_reduce_14,
|
189
|
+
1, 13, :_reduce_none ]
|
190
|
+
|
191
|
+
racc_reduce_n = 16
|
192
|
+
|
193
|
+
racc_shift_n = 19
|
194
|
+
|
195
|
+
racc_token_table = {
|
196
|
+
false => 0,
|
197
|
+
:error => 1,
|
198
|
+
:WORD => 2,
|
199
|
+
"{" => 3,
|
200
|
+
"}" => 4,
|
201
|
+
"," => 5 }
|
202
|
+
|
203
|
+
racc_nt_base = 6
|
204
|
+
|
205
|
+
racc_use_result_var = false
|
206
|
+
|
207
|
+
Racc_arg = [
|
208
|
+
racc_action_table,
|
209
|
+
racc_action_check,
|
210
|
+
racc_action_default,
|
211
|
+
racc_action_pointer,
|
212
|
+
racc_goto_table,
|
213
|
+
racc_goto_check,
|
214
|
+
racc_goto_default,
|
215
|
+
racc_goto_pointer,
|
216
|
+
racc_nt_base,
|
217
|
+
racc_reduce_table,
|
218
|
+
racc_token_table,
|
219
|
+
racc_shift_n,
|
220
|
+
racc_reduce_n,
|
221
|
+
racc_use_result_var ]
|
222
|
+
|
223
|
+
Racc_token_to_s_table = [
|
224
|
+
"$end",
|
225
|
+
"error",
|
226
|
+
"WORD",
|
227
|
+
"\"{\"",
|
228
|
+
"\"}\"",
|
229
|
+
"\",\"",
|
230
|
+
"$start",
|
231
|
+
"pattern",
|
232
|
+
"strings",
|
233
|
+
"string",
|
234
|
+
"words_or_sign",
|
235
|
+
"braced",
|
236
|
+
"exprs",
|
237
|
+
"expr" ]
|
238
|
+
|
239
|
+
Racc_debug_parser = false
|
240
|
+
|
241
|
+
##### State transition tables end #####
|
242
|
+
|
243
|
+
# reduce 0 omitted
|
244
|
+
|
245
|
+
# reduce 1 omitted
|
246
|
+
|
247
|
+
# reduce 2 omitted
|
248
|
+
|
249
|
+
module_eval(<<'.,.,', 'bracecomp.y', 8)
|
250
|
+
def _reduce_3(val, _values)
|
251
|
+
[val[0]]
|
252
|
+
|
253
|
+
end
|
254
|
+
.,.,
|
255
|
+
|
256
|
+
module_eval(<<'.,.,', 'bracecomp.y', 12)
|
257
|
+
def _reduce_4(val, _values)
|
258
|
+
val[0] << val[1]
|
259
|
+
|
260
|
+
end
|
261
|
+
.,.,
|
262
|
+
|
263
|
+
# reduce 5 omitted
|
264
|
+
|
265
|
+
# reduce 6 omitted
|
266
|
+
|
267
|
+
# reduce 7 omitted
|
268
|
+
|
269
|
+
# reduce 8 omitted
|
270
|
+
|
271
|
+
# reduce 9 omitted
|
272
|
+
|
273
|
+
# reduce 10 omitted
|
274
|
+
|
275
|
+
module_eval(<<'.,.,', 'bracecomp.y', 25)
|
276
|
+
def _reduce_11(val, _values)
|
277
|
+
val[1]
|
278
|
+
|
279
|
+
end
|
280
|
+
.,.,
|
281
|
+
|
282
|
+
module_eval(<<'.,.,', 'bracecomp.y', 30)
|
283
|
+
def _reduce_12(val, _values)
|
284
|
+
[val[0]]
|
285
|
+
|
286
|
+
end
|
287
|
+
.,.,
|
288
|
+
|
289
|
+
module_eval(<<'.,.,', 'bracecomp.y', 34)
|
290
|
+
def _reduce_13(val, _values)
|
291
|
+
val[0] << val[2]
|
292
|
+
|
293
|
+
end
|
294
|
+
.,.,
|
295
|
+
|
296
|
+
module_eval(<<'.,.,', 'bracecomp.y', 39)
|
297
|
+
def _reduce_14(val, _values)
|
298
|
+
''
|
299
|
+
|
300
|
+
end
|
301
|
+
.,.,
|
302
|
+
|
303
|
+
# reduce 15 omitted
|
304
|
+
|
305
|
+
def _reduce_none(val, _values)
|
306
|
+
val[0]
|
307
|
+
end
|
308
|
+
|
309
|
+
end # class BraceComp
|
data/lib/bracecomp.y
CHANGED
@@ -63,15 +63,15 @@ def scan
|
|
63
63
|
if (piece = @s.scan /\A\s+/)
|
64
64
|
# nothing to do
|
65
65
|
elsif (piece = @s.scan /\A[^{},]+/)
|
66
|
-
yield :WORD, piece
|
66
|
+
yield [:WORD, piece]
|
67
67
|
elsif (piece = @s.scan /\A[{},]/)
|
68
|
-
yield piece, piece
|
68
|
+
yield [piece, piece]
|
69
69
|
else
|
70
70
|
raise Racc::ParseError, 'parse error'
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
yield false, '$'
|
74
|
+
yield [false, '$']
|
75
75
|
end
|
76
76
|
private :scan
|
77
77
|
|
metadata
CHANGED
@@ -1,32 +1,22 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bracecomp
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 0.1.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- winebarrel
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-09-06 00:00:00 Z
|
12
|
+
date: 2013-01-17 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description:
|
22
15
|
email: sgwr_dts@yahoo.co.jp
|
23
16
|
executables: []
|
24
|
-
|
25
17
|
extensions: []
|
26
|
-
|
27
18
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
19
|
+
files:
|
30
20
|
- README
|
31
21
|
- lib/bracecomp/capistrano.rb
|
32
22
|
- lib/bracecomp.rb
|
@@ -34,36 +24,26 @@ files:
|
|
34
24
|
- lib/bracecomp.y
|
35
25
|
homepage: https://bitbucket.org/winebarrel/bracecomp
|
36
26
|
licenses: []
|
37
|
-
|
38
27
|
post_install_message:
|
39
28
|
rdoc_options: []
|
40
|
-
|
41
|
-
require_paths:
|
29
|
+
require_paths:
|
42
30
|
- lib
|
43
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
32
|
none: false
|
45
|
-
requirements:
|
46
|
-
- -
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
|
49
|
-
|
50
|
-
- 0
|
51
|
-
version: "0"
|
52
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
38
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
version: "0"
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
61
43
|
requirements: []
|
62
|
-
|
63
44
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.
|
45
|
+
rubygems_version: 1.8.23
|
65
46
|
signing_key:
|
66
47
|
specification_version: 3
|
67
48
|
summary: Brace expansion library.
|
68
49
|
test_files: []
|
69
|
-
|