bracecomp 0.1.1 → 0.1.2

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