sdbcli 0.1.1 → 0.1.2

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.
data/README CHANGED
@@ -42,7 +42,7 @@ https://bitbucket.org/winebarrel/sdbcli
42
42
 
43
43
  SELECT output_list FROM domain_name [where expression] [sort_instructions] [limit limit]
44
44
  queries using the SELECT statement
45
-
45
+
46
46
  ap-northeast-1> select * from test
47
47
  ---
48
48
  - [itemname1, {attr1: val1, attr2: val2}]
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
3
  # This file is automatically generated by racc 1.4.5
4
- # from racc grammer file "sdb-parser.y".
4
+ # from racc grammer file "lib/sdbcli/sdb-parser.y".
5
5
  #
6
6
 
7
7
  require 'racc/parser'
@@ -15,7 +15,7 @@ module SimpleDB
15
15
 
16
16
  class Parser < Racc::Parser
17
17
 
18
- module_eval <<'..end sdb-parser.y modeval..idc908e49d79', 'sdb-parser.y', 119
18
+ module_eval <<'..end lib/sdbcli/sdb-parser.y modeval..idca9c582f51', 'lib/sdbcli/sdb-parser.y', 139
19
19
 
20
20
  KEYWORDS = %w(
21
21
  AND
@@ -117,7 +117,7 @@ def self.parse(obj)
117
117
  self.new(obj).parse
118
118
  end
119
119
 
120
- ..end sdb-parser.y modeval..idc908e49d79
120
+ ..end lib/sdbcli/sdb-parser.y modeval..idca9c582f51
121
121
 
122
122
  ##### racc 1.4.5 generates ###
123
123
 
@@ -137,84 +137,81 @@ racc_reduce_table = [
137
137
  1, 36, :_reduce_12,
138
138
  1, 36, :_reduce_none,
139
139
  10, 29, :_reduce_14,
140
- 3, 38, :_reduce_15,
141
- 8, 30, :_reduce_16,
142
- 1, 40, :_reduce_17,
143
- 3, 40, :_reduce_18,
144
- 3, 41, :_reduce_19,
145
- 8, 31, :_reduce_20,
146
- 0, 42, :_reduce_21,
147
- 1, 42, :_reduce_none,
148
- 1, 32, :_reduce_23,
149
- 3, 33, :_reduce_24,
150
- 3, 34, :_reduce_25,
151
- 2, 35, :_reduce_26,
152
- 1, 37, :_reduce_27,
153
- 3, 37, :_reduce_28,
154
- 1, 39, :_reduce_29,
155
- 3, 39, :_reduce_30 ]
156
-
157
- racc_reduce_n = 31
158
-
159
- racc_shift_n = 74
140
+ 1, 38, :_reduce_15,
141
+ 3, 38, :_reduce_16,
142
+ 1, 40, :_reduce_none,
143
+ 1, 40, :_reduce_none,
144
+ 8, 30, :_reduce_19,
145
+ 1, 41, :_reduce_20,
146
+ 3, 41, :_reduce_21,
147
+ 3, 42, :_reduce_22,
148
+ 8, 31, :_reduce_23,
149
+ 0, 43, :_reduce_24,
150
+ 1, 43, :_reduce_none,
151
+ 1, 32, :_reduce_26,
152
+ 3, 33, :_reduce_27,
153
+ 3, 34, :_reduce_28,
154
+ 2, 35, :_reduce_29,
155
+ 1, 37, :_reduce_30,
156
+ 3, 37, :_reduce_31,
157
+ 1, 39, :_reduce_32,
158
+ 3, 39, :_reduce_33 ]
159
+
160
+ racc_reduce_n = 34
161
+
162
+ racc_shift_n = 76
160
163
 
161
164
  racc_action_table = [
162
- 6, 8, 51, 24, 71, 48, 72, 26, 25, 1,
163
- 27, 24, 50, 30, 31, 10, 32, 13, 15, 17,
164
- 33, 3, 5, 34, 35, 36, 34, 37, 38, 39,
165
- 40, 41, 42, 45, 47, 21, 49, 20, 52, 53,
166
- 54, 55, 56, 42, 58, 59, 60, 24, 62, 63,
167
- 64, 65, 34, 66, 67, 68, 70, 19, 73 ]
165
+ 6, 8, 53, 24, 46, 73, 48, 74, 25, 1,
166
+ 24, 55, 52, 56, 46, 10, 48, 13, 15, 17,
167
+ 30, 3, 5, 31, 32, 33, 34, 35, 36, 34,
168
+ 37, 38, 39, 40, 41, 42, 45, 27, 50, 51,
169
+ 26, 54, 21, 57, 58, 42, 60, 61, 62, 20,
170
+ 64, 65, 66, 67, 68, 69, 70, 72, 19, 75 ]
168
171
 
169
172
  racc_action_check = [
170
- 0, 0, 43, 8, 69, 40, 69, 9, 8, 0,
171
- 10, 13, 43, 17, 19, 0, 20, 0, 0, 0,
172
- 22, 0, 0, 23, 26, 27, 28, 29, 30, 31,
173
- 33, 34, 36, 37, 39, 5, 42, 3, 45, 46,
174
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 58,
175
- 59, 60, 61, 62, 63, 64, 65, 1, 72 ]
173
+ 0, 0, 43, 8, 56, 71, 56, 71, 8, 0,
174
+ 13, 47, 43, 47, 39, 0, 39, 0, 0, 0,
175
+ 17, 0, 0, 19, 20, 22, 23, 26, 27, 28,
176
+ 29, 30, 31, 33, 34, 36, 37, 10, 40, 42,
177
+ 9, 45, 5, 50, 51, 52, 53, 54, 55, 3,
178
+ 57, 60, 61, 62, 64, 65, 66, 67, 1, 74 ]
176
179
 
177
180
  racc_action_pointer = [
178
- -2, 45, nil, 15, nil, 10, nil, nil, -2, 7,
179
- 5, nil, nil, 6, nil, nil, nil, -9, nil, 9,
180
- 11, nil, 16, 7, nil, nil, 24, 7, 10, 23,
181
- 23, 16, nil, 25, 26, nil, 27, 28, nil, 27,
182
- -1, nil, 28, -4, nil, 32, 25, 24, 34, 33,
183
- 38, 37, 38, 31, 42, 40, nil, nil, 41, 42,
184
- 38, 36, 44, 45, 46, 47, nil, nil, nil, -10,
185
- nil, nil, 49, nil ]
181
+ -2, 46, nil, 27, nil, 17, nil, nil, -2, 40,
182
+ 32, nil, nil, 5, nil, nil, nil, -2, nil, 18,
183
+ 19, nil, 21, 10, nil, nil, 27, 10, 13, 26,
184
+ 26, 19, nil, 28, 29, nil, 30, 31, nil, 9,
185
+ 32, nil, 31, -4, nil, 35, nil, -3, nil, nil,
186
+ 36, 35, 40, 39, 40, 33, -1, 42, nil, nil,
187
+ 43, 44, 40, nil, 45, 46, 47, 48, nil, nil,
188
+ nil, -9, nil, nil, 50, nil ]
186
189
 
187
190
  racc_action_default = [
188
- -31, -31, -6, -31, -7, -31, -9, -8, -11, -31,
189
- -31, -1, -2, -21, -3, -23, -4, -31, -5, -31,
190
- -31, -26, -31, -13, -27, -12, -31, -31, -22, -31,
191
- -31, -31, -25, -31, -31, 74, -31, -31, -24, -31,
192
- -31, -28, -31, -31, -17, -31, -31, -31, -31, -31,
193
- -31, -31, -31, -31, -31, -31, -19, -18, -31, -31,
194
- -31, -15, -31, -31, -31, -31, -10, -16, -20, -31,
195
- -29, -14, -31, -30 ]
191
+ -34, -34, -6, -34, -7, -34, -9, -8, -11, -34,
192
+ -34, -1, -2, -24, -3, -26, -4, -34, -5, -34,
193
+ -34, -29, -34, -13, -30, -12, -34, -34, -25, -34,
194
+ -34, -34, -28, -34, -34, 76, -34, -34, -27, -34,
195
+ -34, -31, -34, -34, -20, -34, -18, -34, -17, -15,
196
+ -34, -34, -34, -34, -34, -34, -34, -34, -22, -21,
197
+ -34, -34, -34, -16, -34, -34, -34, -34, -10, -19,
198
+ -23, -34, -32, -14, -34, -33 ]
196
199
 
197
200
  racc_goto_table = [
198
- 23, 44, 7, 14, 16, 28, 18, 2, 4, 12,
199
- 22, 9, 46, 69, 43, 57, 11, 29, nil, nil,
200
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
201
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
202
- nil, nil, nil, nil, nil, nil, 61 ]
201
+ 49, 23, 44, 7, 16, 18, 28, 2, 4, 14,
202
+ 22, 9, 47, 71, 12, 43, 11, 63, 59, 29 ]
203
203
 
204
204
  racc_goto_check = [
205
- 11, 15, 9, 4, 5, 11, 6, 7, 8, 3,
206
- 10, 1, 12, 13, 14, 15, 2, 16, nil, nil,
207
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
208
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
209
- nil, nil, nil, nil, nil, nil, 11 ]
205
+ 14, 11, 16, 9, 5, 6, 11, 7, 8, 4,
206
+ 10, 1, 12, 13, 3, 15, 2, 14, 16, 17 ]
210
207
 
211
208
  racc_goto_pointer = [
212
- nil, 11, 16, 9, 3, 4, 6, 7, 8, 2,
213
- 2, -8, -27, -52, -22, -35, 4 ]
209
+ nil, 11, 16, 14, 9, 4, 5, 7, 8, 3,
210
+ 2, -7, -27, -54, -39, -21, -34, 6 ]
214
211
 
215
212
  racc_goto_default = [
216
213
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
217
- nil, nil, nil, nil, nil, nil, nil ]
214
+ nil, nil, nil, nil, nil, nil, nil, nil ]
218
215
 
219
216
  racc_token_table = {
220
217
  false => 0,
@@ -303,8 +300,9 @@ Racc_token_to_s_table = [
303
300
  'show_stmt',
304
301
  'get_output_list',
305
302
  'identifier_list',
306
- 'insert_attr_list',
303
+ 'insert_identifier_list',
307
304
  'value_list',
305
+ 'itemname_identifier',
308
306
  'set_clause_list',
309
307
  'set_clause',
310
308
  'delete_attr_list']
@@ -333,19 +331,19 @@ Racc_debug_parser = false
333
331
 
334
332
  # reduce 9 omitted
335
333
 
336
- module_eval <<'.,.,', 'sdb-parser.y', 17
334
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 17
337
335
  def _reduce_10( val, _values)
338
336
  struct(:GET, :domain => val[3], :item_name => val[7], :attr_names => val[1])
339
337
  end
340
338
  .,.,
341
339
 
342
- module_eval <<'.,.,', 'sdb-parser.y', 22
340
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 22
343
341
  def _reduce_11( val, _values)
344
342
  []
345
343
  end
346
344
  .,.,
347
345
 
348
- module_eval <<'.,.,', 'sdb-parser.y', 26
346
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 26
349
347
  def _reduce_12( val, _values)
350
348
  []
351
349
  end
@@ -353,105 +351,127 @@ module_eval <<'.,.,', 'sdb-parser.y', 26
353
351
 
354
352
  # reduce 13 omitted
355
353
 
356
- module_eval <<'.,.,', 'sdb-parser.y', 35
354
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 47
357
355
  def _reduce_14( val, _values)
356
+ unless val[4].length == val[8].length
357
+ raise Racc::ParseError, 'The number of an attribute and values differs'
358
+ end
359
+
358
360
  attrs = {}
359
361
  val[4].zip(val[8]).each {|k, v| attrs[k] = v }
360
- item_name = attrs.delete(:item_name)
362
+ item_name = attrs.find {|k, v| k =~ /\AitemName\Z/i }
363
+
364
+ unless item_name
365
+ raise Racc::ParseError,'itemName is not contained in the INSERT statement'
366
+ end
367
+
368
+ attrs.delete(item_name[0])
369
+ item_name = item_name[1]
370
+
361
371
  struct(:INSERT, :domain => val[2], :item_name => item_name, :attrs => attrs)
362
372
  end
363
373
  .,.,
364
374
 
365
- module_eval <<'.,.,', 'sdb-parser.y', 40
375
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 53
366
376
  def _reduce_15( val, _values)
367
- [:item_name, val[2]].flatten
377
+ [val[0]]
368
378
  end
369
379
  .,.,
370
380
 
371
- module_eval <<'.,.,', 'sdb-parser.y', 47
381
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 57
372
382
  def _reduce_16( val, _values)
383
+ val[0] + [val[2]]
384
+ end
385
+ .,.,
386
+
387
+ # reduce 17 omitted
388
+
389
+ # reduce 18 omitted
390
+
391
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 67
392
+ def _reduce_19( val, _values)
373
393
  attrs = {}
374
394
  val[3].each {|k, v| attrs[k] = v }
375
395
  struct(:UPDATE, :domain => val[1], :items => [[val[7], attrs]])
376
396
  end
377
397
  .,.,
378
398
 
379
- module_eval <<'.,.,', 'sdb-parser.y', 52
380
- def _reduce_17( val, _values)
399
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 72
400
+ def _reduce_20( val, _values)
381
401
  [val[0]]
382
402
  end
383
403
  .,.,
384
404
 
385
- module_eval <<'.,.,', 'sdb-parser.y', 56
386
- def _reduce_18( val, _values)
405
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 76
406
+ def _reduce_21( val, _values)
387
407
  val[0] + [val[2]]
388
408
  end
389
409
  .,.,
390
410
 
391
- module_eval <<'.,.,', 'sdb-parser.y', 61
392
- def _reduce_19( val, _values)
411
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 81
412
+ def _reduce_22( val, _values)
393
413
  [val[0], val[2]]
394
414
  end
395
415
  .,.,
396
416
 
397
- module_eval <<'.,.,', 'sdb-parser.y', 66
398
- def _reduce_20( val, _values)
417
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 86
418
+ def _reduce_23( val, _values)
399
419
  struct(:DELETE, :domain => val[3], :items => [[val[7], val[1]]])
400
420
  end
401
421
  .,.,
402
422
 
403
- module_eval <<'.,.,', 'sdb-parser.y', 71
404
- def _reduce_21( val, _values)
423
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 91
424
+ def _reduce_24( val, _values)
405
425
  []
406
426
  end
407
427
  .,.,
408
428
 
409
- # reduce 22 omitted
429
+ # reduce 25 omitted
410
430
 
411
- module_eval <<'.,.,', 'sdb-parser.y', 77
412
- def _reduce_23( val, _values)
431
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 97
432
+ def _reduce_26( val, _values)
413
433
  struct(:SELECT, :query => val[0])
414
434
  end
415
435
  .,.,
416
436
 
417
- module_eval <<'.,.,', 'sdb-parser.y', 82
418
- def _reduce_24( val, _values)
437
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 102
438
+ def _reduce_27( val, _values)
419
439
  struct(:CREATE, :domain => val[2])
420
440
  end
421
441
  .,.,
422
442
 
423
- module_eval <<'.,.,', 'sdb-parser.y', 87
424
- def _reduce_25( val, _values)
443
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 107
444
+ def _reduce_28( val, _values)
425
445
  struct(:DROP, :domain => val[2])
426
446
  end
427
447
  .,.,
428
448
 
429
- module_eval <<'.,.,', 'sdb-parser.y', 92
430
- def _reduce_26( val, _values)
449
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 112
450
+ def _reduce_29( val, _values)
431
451
  struct(:SHOW, :operand => :domains)
432
452
  end
433
453
  .,.,
434
454
 
435
- module_eval <<'.,.,', 'sdb-parser.y', 97
436
- def _reduce_27( val, _values)
455
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 117
456
+ def _reduce_30( val, _values)
437
457
  [val[0]]
438
458
  end
439
459
  .,.,
440
460
 
441
- module_eval <<'.,.,', 'sdb-parser.y', 101
442
- def _reduce_28( val, _values)
461
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 121
462
+ def _reduce_31( val, _values)
443
463
  val[0] + [val[2]]
444
464
  end
445
465
  .,.,
446
466
 
447
- module_eval <<'.,.,', 'sdb-parser.y', 106
448
- def _reduce_29( val, _values)
467
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 126
468
+ def _reduce_32( val, _values)
449
469
  [val[0]]
450
470
  end
451
471
  .,.,
452
472
 
453
- module_eval <<'.,.,', 'sdb-parser.y', 110
454
- def _reduce_30( val, _values)
473
+ module_eval <<'.,.,', 'lib/sdbcli/sdb-parser.y', 130
474
+ def _reduce_33( val, _values)
455
475
  [val[0], val[2]].flatten
456
476
  end
457
477
  .,.,
@@ -26,18 +26,38 @@ rule
26
26
  }
27
27
  | identifier_list
28
28
 
29
- insert_stmt : INSERT INTO IDENTIFIER '(' insert_attr_list ')' VALUES '(' value_list ')'
29
+ insert_stmt : INSERT INTO IDENTIFIER '(' insert_identifier_list ')' VALUES '(' value_list ')'
30
30
  {
31
+ unless val[4].length == val[8].length
32
+ raise Racc::ParseError, 'The number of an attribute and values differs'
33
+ end
34
+
31
35
  attrs = {}
32
36
  val[4].zip(val[8]).each {|k, v| attrs[k] = v }
33
- item_name = attrs.delete(:item_name)
37
+ item_name = attrs.find {|k, v| k =~ /\AitemName\Z/i }
38
+
39
+ unless item_name
40
+ raise Racc::ParseError,'itemName is not contained in the INSERT statement'
41
+ end
42
+
43
+ attrs.delete(item_name[0])
44
+ item_name = item_name[1]
45
+
34
46
  struct(:INSERT, :domain => val[2], :item_name => item_name, :attrs => attrs)
35
47
  }
36
48
 
37
- insert_attr_list : ITEMNAME ',' identifier_list
38
- {
39
- [:item_name, val[2]].flatten
40
- }
49
+
50
+ insert_identifier_list : itemname_identifier
51
+ {
52
+ [val[0]]
53
+ }
54
+ | insert_identifier_list ',' itemname_identifier
55
+ {
56
+ val[0] + [val[2]]
57
+ }
58
+
59
+ itemname_identifier : ITEMNAME
60
+ | IDENTIFIER
41
61
 
42
62
  update_stmt : UPDATE IDENTIFIER SET set_clause_list WHERE ITEMNAME '=' VALUE
43
63
  {
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdbcli
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - winebarrel