ec2cli 0.1.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.
@@ -0,0 +1,519 @@
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
+ module EC2
13
+
14
+ class Parser < Racc::Parser
15
+
16
+ module_eval(<<'...end ec2-parser.y/module_eval...', 'ec2-parser.y', 143)
17
+
18
+ KEYWORDS = %w(
19
+ ALL
20
+ AND
21
+ DESCRIBE
22
+ DESC
23
+ IMAGES
24
+ INSTANCES
25
+ REGIONS
26
+ RUN
27
+ SET
28
+ SHOW
29
+ START
30
+ STOP
31
+ TAGS
32
+ USE
33
+ WHERE
34
+ )
35
+
36
+ KEYWORD_REGEXP = Regexp.compile("(?:#{KEYWORDS.join '|'})\\b", Regexp::IGNORECASE)
37
+
38
+ def initialize(obj)
39
+ src = obj.is_a?(IO) ? obj.read : obj.to_s
40
+ @ss = StringScanner.new(src)
41
+ end
42
+
43
+ @@structs = {}
44
+
45
+ def struct(name, attrs = {})
46
+ unless (clazz = @@structs[name])
47
+ clazz = attrs.empty? ? Struct.new(name.to_s) : Struct.new(name.to_s, *attrs.keys)
48
+ @@structs[name] = clazz
49
+ end
50
+
51
+ obj = clazz.new
52
+
53
+ attrs.each do |key, val|
54
+ obj.send("#{key}=", val)
55
+ end
56
+
57
+ return obj
58
+ end
59
+ private :struct
60
+
61
+ def scan
62
+ tok = nil
63
+
64
+ until @ss.eos?
65
+ if (tok = @ss.scan /\s+/)
66
+ # nothing to do
67
+ elsif (tok = @ss.scan /(?:=)/)
68
+ sym = {
69
+ '=' => :EQ,
70
+ }.fetch(tok)
71
+ yield [sym, tok]
72
+ elsif (tok = @ss.scan KEYWORD_REGEXP)
73
+ yield [tok.upcase.to_sym, tok]
74
+ elsif (tok = @ss.scan /NULL/i)
75
+ yield [:NULL, nil]
76
+ elsif (tok = @ss.scan /`(?:[^`]|``)*`/)
77
+ yield [:IDENTIFIER, tok.slice(1...-1).gsub(/``/, '`')]
78
+ elsif (tok = @ss.scan /'(?:[^']|'')*'/) #'
79
+ yield [:STRING, tok.slice(1...-1).gsub(/''/, "'")]
80
+ elsif (tok = @ss.scan /"(?:[^"]|"")*"/) #"
81
+ yield [:STRING, tok.slice(1...-1).gsub(/""/, '"')]
82
+ elsif (tok = @ss.scan /\d+(?:\.\d+)?/)
83
+ yield [:NUMBER, (tok =~ /\./ ? tok.to_f : tok.to_i)]
84
+ elsif (tok = @ss.scan /[,\(\)\*]/)
85
+ yield [tok, tok]
86
+ elsif (tok = @ss.scan /[^\s]+/)
87
+ yield [:IDENTIFIER, tok]
88
+ else
89
+ raise Racc::ParseError, ('parse error on value "%s"' % @ss.rest.inspect)
90
+ end
91
+ end
92
+
93
+ yield [false, 'EOF']
94
+ end
95
+ private :scan
96
+
97
+ def parse
98
+ yyparse self, :scan
99
+ end
100
+
101
+ def self.parse(obj)
102
+ self.new(obj).parse
103
+ end
104
+
105
+ ...end ec2-parser.y/module_eval...
106
+ ##### State transition tables begin ###
107
+
108
+ racc_action_table = [
109
+ 10, 11, 30, 43, 60, 32, 12, 13, 14, 15,
110
+ 58, 53, 59, 16, 30, 17, 63, 28, 57, 27,
111
+ 34, 35, 34, 35, 38, 19, 20, 21, 34, 35,
112
+ 38, 34, 35, 38, 51, 50, 34, 35, 30, 46,
113
+ 30, 26, 25, 54, 55, 56, 24, 23, 43, 22,
114
+ 46, 18, 67, 68 ]
115
+
116
+ racc_action_check = [
117
+ 0, 0, 41, 25, 49, 21, 0, 0, 0, 0,
118
+ 48, 41, 49, 0, 19, 0, 54, 18, 48, 17,
119
+ 54, 54, 56, 56, 56, 9, 9, 9, 23, 23,
120
+ 23, 24, 24, 24, 38, 38, 22, 22, 20, 30,
121
+ 32, 16, 15, 43, 44, 46, 14, 13, 53, 12,
122
+ 55, 1, 58, 60 ]
123
+
124
+ racc_action_pointer = [
125
+ -5, 51, nil, nil, nil, nil, nil, nil, nil, 23,
126
+ nil, nil, 47, 45, 44, 27, 22, 10, 17, 7,
127
+ 31, 2, 15, 7, 10, -6, nil, nil, nil, nil,
128
+ 30, nil, 33, nil, nil, nil, nil, nil, 13, nil,
129
+ nil, -5, nil, 33, 36, nil, 35, nil, -6, -12,
130
+ nil, nil, nil, 39, -1, 41, 1, nil, 30, nil,
131
+ 32, nil, nil, nil, nil, nil, nil, nil, nil ]
132
+
133
+ racc_action_default = [
134
+ -39, -39, -1, -2, -3, -4, -5, -6, -7, -39,
135
+ -11, -12, -39, -39, -39, -39, -39, -39, -39, -13,
136
+ -13, -39, -39, -39, -39, -39, -29, -30, 69, -8,
137
+ -39, -9, -13, -19, -31, -32, -20, -21, -39, -22,
138
+ -23, -13, -25, -39, -14, -15, -39, -10, -39, -39,
139
+ -35, -37, -24, -39, -39, -39, -39, -33, -39, -34,
140
+ -39, -26, -27, -28, -16, -17, -18, -36, -38 ]
141
+
142
+ racc_goto_table = [
143
+ 33, 36, 39, 37, 40, 42, 45, 29, 31, 1,
144
+ 7, 8, 9, 6, 44, 5, 4, 3, 41, 2,
145
+ 47, 48, 49, nil, nil, nil, nil, nil, nil, 52,
146
+ nil, 64, 62, 61, 65, nil, 66 ]
147
+
148
+ racc_goto_check = [
149
+ 13, 13, 13, 14, 14, 16, 12, 10, 10, 1,
150
+ 7, 8, 9, 6, 11, 5, 4, 3, 15, 2,
151
+ 10, 17, 18, nil, nil, nil, nil, nil, nil, 10,
152
+ nil, 12, 13, 16, 13, nil, 14 ]
153
+
154
+ racc_goto_pointer = [
155
+ nil, 9, 19, 17, 16, 15, 13, 10, 11, 12,
156
+ -12, -16, -24, -22, -20, -7, -20, -17, -16 ]
157
+
158
+ racc_goto_default = [
159
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
160
+ nil, nil, nil, nil, nil, nil, nil, nil, nil ]
161
+
162
+ racc_reduce_table = [
163
+ 0, 0, :racc_error,
164
+ 1, 26, :_reduce_none,
165
+ 1, 26, :_reduce_none,
166
+ 1, 26, :_reduce_none,
167
+ 1, 26, :_reduce_none,
168
+ 1, 26, :_reduce_none,
169
+ 1, 26, :_reduce_none,
170
+ 1, 26, :_reduce_none,
171
+ 3, 27, :_reduce_8,
172
+ 3, 27, :_reduce_9,
173
+ 4, 27, :_reduce_10,
174
+ 1, 34, :_reduce_none,
175
+ 1, 34, :_reduce_none,
176
+ 0, 35, :_reduce_none,
177
+ 2, 35, :_reduce_14,
178
+ 1, 36, :_reduce_15,
179
+ 3, 36, :_reduce_16,
180
+ 3, 37, :_reduce_17,
181
+ 3, 37, :_reduce_18,
182
+ 3, 28, :_reduce_19,
183
+ 3, 29, :_reduce_20,
184
+ 3, 29, :_reduce_21,
185
+ 3, 30, :_reduce_22,
186
+ 3, 30, :_reduce_23,
187
+ 4, 31, :_reduce_24,
188
+ 1, 40, :_reduce_25,
189
+ 3, 40, :_reduce_26,
190
+ 3, 41, :_reduce_27,
191
+ 3, 41, :_reduce_28,
192
+ 2, 32, :_reduce_29,
193
+ 2, 33, :_reduce_30,
194
+ 1, 38, :_reduce_none,
195
+ 1, 38, :_reduce_none,
196
+ 3, 39, :_reduce_33,
197
+ 3, 39, :_reduce_34,
198
+ 1, 42, :_reduce_35,
199
+ 3, 42, :_reduce_36,
200
+ 1, 43, :_reduce_37,
201
+ 3, 43, :_reduce_38 ]
202
+
203
+ racc_reduce_n = 39
204
+
205
+ racc_shift_n = 69
206
+
207
+ racc_token_table = {
208
+ false => 0,
209
+ :error => 1,
210
+ :INSTANCES => 2,
211
+ :IMAGES => 3,
212
+ :ALL => 4,
213
+ :DESCRIBE => 5,
214
+ :DESC => 6,
215
+ :WHERE => 7,
216
+ :AND => 8,
217
+ :IDENTIFIER => 9,
218
+ :EQ => 10,
219
+ :RUN => 11,
220
+ :START => 12,
221
+ :STOP => 13,
222
+ :SET => 14,
223
+ :TAGS => 15,
224
+ "," => 16,
225
+ :NULL => 17,
226
+ :SHOW => 18,
227
+ :REGIONS => 19,
228
+ :USE => 20,
229
+ :STRING => 21,
230
+ :NUMBER => 22,
231
+ "(" => 23,
232
+ ")" => 24 }
233
+
234
+ racc_nt_base = 25
235
+
236
+ racc_use_result_var = false
237
+
238
+ Racc_arg = [
239
+ racc_action_table,
240
+ racc_action_check,
241
+ racc_action_default,
242
+ racc_action_pointer,
243
+ racc_goto_table,
244
+ racc_goto_check,
245
+ racc_goto_default,
246
+ racc_goto_pointer,
247
+ racc_nt_base,
248
+ racc_reduce_table,
249
+ racc_token_table,
250
+ racc_shift_n,
251
+ racc_reduce_n,
252
+ racc_use_result_var ]
253
+
254
+ Racc_token_to_s_table = [
255
+ "$end",
256
+ "error",
257
+ "INSTANCES",
258
+ "IMAGES",
259
+ "ALL",
260
+ "DESCRIBE",
261
+ "DESC",
262
+ "WHERE",
263
+ "AND",
264
+ "IDENTIFIER",
265
+ "EQ",
266
+ "RUN",
267
+ "START",
268
+ "STOP",
269
+ "SET",
270
+ "TAGS",
271
+ "\",\"",
272
+ "NULL",
273
+ "SHOW",
274
+ "REGIONS",
275
+ "USE",
276
+ "STRING",
277
+ "NUMBER",
278
+ "\"(\"",
279
+ "\")\"",
280
+ "$start",
281
+ "stmt",
282
+ "describe_stmt",
283
+ "run_stmt",
284
+ "start_stmt",
285
+ "stop_stmt",
286
+ "set_stmt",
287
+ "show_stmt",
288
+ "use_stmt",
289
+ "describe_or_desc",
290
+ "where_clause",
291
+ "expr_list",
292
+ "expr",
293
+ "value",
294
+ "value_list",
295
+ "attr_list",
296
+ "attr",
297
+ "number_list",
298
+ "string_list" ]
299
+
300
+ Racc_debug_parser = false
301
+
302
+ ##### State transition tables end #####
303
+
304
+ # reduce 0 omitted
305
+
306
+ # reduce 1 omitted
307
+
308
+ # reduce 2 omitted
309
+
310
+ # reduce 3 omitted
311
+
312
+ # reduce 4 omitted
313
+
314
+ # reduce 5 omitted
315
+
316
+ # reduce 6 omitted
317
+
318
+ # reduce 7 omitted
319
+
320
+ module_eval(<<'.,.,', 'ec2-parser.y', 13)
321
+ def _reduce_8(val, _values)
322
+ struct(:DESCRIBE_INSTANCES, :filter => val[2])
323
+
324
+ end
325
+ .,.,
326
+
327
+ module_eval(<<'.,.,', 'ec2-parser.y', 17)
328
+ def _reduce_9(val, _values)
329
+ struct(:DESCRIBE_IMAGES, :filter => val[2], :all => false)
330
+
331
+ end
332
+ .,.,
333
+
334
+ module_eval(<<'.,.,', 'ec2-parser.y', 21)
335
+ def _reduce_10(val, _values)
336
+ struct(:DESCRIBE_IMAGES, :filter => val[3], :all => true)
337
+
338
+ end
339
+ .,.,
340
+
341
+ # reduce 11 omitted
342
+
343
+ # reduce 12 omitted
344
+
345
+ # reduce 13 omitted
346
+
347
+ module_eval(<<'.,.,', 'ec2-parser.y', 29)
348
+ def _reduce_14(val, _values)
349
+ val[1]
350
+
351
+ end
352
+ .,.,
353
+
354
+ module_eval(<<'.,.,', 'ec2-parser.y', 34)
355
+ def _reduce_15(val, _values)
356
+ [val[0]]
357
+
358
+ end
359
+ .,.,
360
+
361
+ module_eval(<<'.,.,', 'ec2-parser.y', 38)
362
+ def _reduce_16(val, _values)
363
+ val[0] + [val[2]]
364
+
365
+ end
366
+ .,.,
367
+
368
+ module_eval(<<'.,.,', 'ec2-parser.y', 43)
369
+ def _reduce_17(val, _values)
370
+ [val[0], [val[2]]]
371
+
372
+ end
373
+ .,.,
374
+
375
+ module_eval(<<'.,.,', 'ec2-parser.y', 47)
376
+ def _reduce_18(val, _values)
377
+ [val[0], val[2]]
378
+
379
+ end
380
+ .,.,
381
+
382
+ module_eval(<<'.,.,', 'ec2-parser.y', 52)
383
+ def _reduce_19(val, _values)
384
+ struct(:RUN_INSTANCES, :image_id => val[2])
385
+
386
+ end
387
+ .,.,
388
+
389
+ module_eval(<<'.,.,', 'ec2-parser.y', 57)
390
+ def _reduce_20(val, _values)
391
+ struct(:START_INSTANCES, :instances => [val[2]])
392
+
393
+ end
394
+ .,.,
395
+
396
+ module_eval(<<'.,.,', 'ec2-parser.y', 61)
397
+ def _reduce_21(val, _values)
398
+ struct(:START_INSTANCES, :instances => val[2])
399
+
400
+ end
401
+ .,.,
402
+
403
+ module_eval(<<'.,.,', 'ec2-parser.y', 66)
404
+ def _reduce_22(val, _values)
405
+ struct(:STOP_INSTANCES, :instances => [val[2]])
406
+
407
+ end
408
+ .,.,
409
+
410
+ module_eval(<<'.,.,', 'ec2-parser.y', 70)
411
+ def _reduce_23(val, _values)
412
+ struct(:STOP_INSTANCES, :instances => val[2])
413
+
414
+ end
415
+ .,.,
416
+
417
+ module_eval(<<'.,.,', 'ec2-parser.y', 75)
418
+ def _reduce_24(val, _values)
419
+ struct(:CREATE_TAGS, :tags => val[2], :filter => val[3])
420
+
421
+ end
422
+ .,.,
423
+
424
+ module_eval(<<'.,.,', 'ec2-parser.y', 80)
425
+ def _reduce_25(val, _values)
426
+ [val[0]]
427
+
428
+ end
429
+ .,.,
430
+
431
+ module_eval(<<'.,.,', 'ec2-parser.y', 84)
432
+ def _reduce_26(val, _values)
433
+ val[0] + [val[2]]
434
+
435
+ end
436
+ .,.,
437
+
438
+ module_eval(<<'.,.,', 'ec2-parser.y', 89)
439
+ def _reduce_27(val, _values)
440
+ [val[0], val[2]]
441
+
442
+ end
443
+ .,.,
444
+
445
+ module_eval(<<'.,.,', 'ec2-parser.y', 93)
446
+ def _reduce_28(val, _values)
447
+ [val[0], nil]
448
+
449
+ end
450
+ .,.,
451
+
452
+ module_eval(<<'.,.,', 'ec2-parser.y', 98)
453
+ def _reduce_29(val, _values)
454
+ struct(:SHOW_REGIONS)
455
+
456
+ end
457
+ .,.,
458
+
459
+ module_eval(<<'.,.,', 'ec2-parser.y', 103)
460
+ def _reduce_30(val, _values)
461
+ struct(:USE, :endpoint_or_region => val[1])
462
+
463
+ end
464
+ .,.,
465
+
466
+ # reduce 31 omitted
467
+
468
+ # reduce 32 omitted
469
+
470
+ module_eval(<<'.,.,', 'ec2-parser.y', 110)
471
+ def _reduce_33(val, _values)
472
+ val[1]
473
+
474
+ end
475
+ .,.,
476
+
477
+ module_eval(<<'.,.,', 'ec2-parser.y', 114)
478
+ def _reduce_34(val, _values)
479
+ val[1]
480
+
481
+ end
482
+ .,.,
483
+
484
+ module_eval(<<'.,.,', 'ec2-parser.y', 119)
485
+ def _reduce_35(val, _values)
486
+ [val[0]]
487
+
488
+ end
489
+ .,.,
490
+
491
+ module_eval(<<'.,.,', 'ec2-parser.y', 123)
492
+ def _reduce_36(val, _values)
493
+ val[0] + [val[2]]
494
+
495
+ end
496
+ .,.,
497
+
498
+ module_eval(<<'.,.,', 'ec2-parser.y', 128)
499
+ def _reduce_37(val, _values)
500
+ [val[0]]
501
+
502
+ end
503
+ .,.,
504
+
505
+ module_eval(<<'.,.,', 'ec2-parser.y', 132)
506
+ def _reduce_38(val, _values)
507
+ val[0] + [val[2]]
508
+
509
+ end
510
+ .,.,
511
+
512
+ def _reduce_none(val, _values)
513
+ val[0]
514
+ end
515
+
516
+ end # class Parser
517
+
518
+
519
+ end # EC2