rgviz 0.29 → 0.30

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/lib/rgviz/parser.rb CHANGED
@@ -192,21 +192,25 @@ module Rgviz
192
192
 
193
193
  def parse_or_expression
194
194
  left = parse_and_expression
195
- if token_is! Token::Or
196
- right = parse_and_expression
197
- BinaryExpression.new left, BinaryExpression::Or, right
198
- else
199
- left
195
+ while true
196
+ if token_is! Token::Or
197
+ right = parse_and_expression
198
+ left = BinaryExpression.new left, BinaryExpression::Or, right
199
+ else
200
+ return left
201
+ end
200
202
  end
201
203
  end
202
204
 
203
205
  def parse_and_expression
204
206
  left = parse_not_expression
205
- if token_is! Token::And
206
- right = parse_not_expression
207
- BinaryExpression.new left, BinaryExpression::And, right
208
- else
209
- left
207
+ while true
208
+ if token_is! Token::And
209
+ right = parse_not_expression
210
+ left = BinaryExpression.new left, BinaryExpression::And, right
211
+ else
212
+ return left
213
+ end
210
214
  end
211
215
  end
212
216
 
@@ -281,34 +285,38 @@ module Rgviz
281
285
  end
282
286
 
283
287
  def parse_summation_or_substraction
284
- column1 = parse_multiplication_or_divition
285
- case @token.value
286
- when Token::PLUS
287
- next_token
288
- column2 = parse_multiplication_or_divition
289
- ScalarFunctionColumn.new ScalarFunctionColumn::Sum, column1, column2
290
- when Token::MINUS
291
- next_token
292
- column2 = parse_multiplication_or_divition
293
- ScalarFunctionColumn.new ScalarFunctionColumn::Difference, column1, column2
294
- else
295
- column1
288
+ left = parse_multiplication_or_divition
289
+ while true
290
+ case @token.value
291
+ when Token::PLUS
292
+ next_token
293
+ right = parse_multiplication_or_divition
294
+ left = ScalarFunctionColumn.new ScalarFunctionColumn::Sum, left, right
295
+ when Token::MINUS
296
+ next_token
297
+ right = parse_multiplication_or_divition
298
+ left = ScalarFunctionColumn.new ScalarFunctionColumn::Difference, left, right
299
+ else
300
+ return left
301
+ end
296
302
  end
297
303
  end
298
304
 
299
305
  def parse_multiplication_or_divition
300
- column1 = parse_atomic_column
301
- case @token.value
302
- when Token::STAR
303
- next_token
304
- column2 = parse_atomic_column
305
- ScalarFunctionColumn.new ScalarFunctionColumn::Product, column1, column2
306
- when Token::SLASH
307
- next_token
308
- column2 = parse_atomic_column
309
- ScalarFunctionColumn.new ScalarFunctionColumn::Quotient, column1, column2
310
- else
311
- column1
306
+ left = parse_atomic_column
307
+ while true
308
+ case @token.value
309
+ when Token::STAR
310
+ next_token
311
+ right = parse_atomic_column
312
+ left = ScalarFunctionColumn.new ScalarFunctionColumn::Product, left, right
313
+ when Token::SLASH
314
+ next_token
315
+ right = parse_atomic_column
316
+ left = ScalarFunctionColumn.new ScalarFunctionColumn::Quotient, left, right
317
+ else
318
+ return left
319
+ end
312
320
  end
313
321
  end
314
322
 
@@ -331,6 +331,20 @@ describe Parser do
331
331
  options.no_format.should be_true
332
332
  end
333
333
 
334
+ it "parses where with two ands" do
335
+ parse "where 1 = 1 and 1 = 1 and 1 = 1"
336
+ end
337
+
338
+ it "parses where with two ors" do
339
+ parse "where 1 = 1 or 1 = 1 or 1 = 1"
340
+ end
341
+
342
+ ['+', '-', '*', '/'].each do |op|
343
+ it "parses where with two #{op}" do
344
+ parse "where 1 #{op} 2 #{op} 3 = 4"
345
+ end
346
+ end
347
+
334
348
  it_raises_on 'select'
335
349
  it_raises_on 'where'
336
350
  it_raises_on 'where 1'
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgviz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 55
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 29
9
- version: "0.29"
8
+ - 30
9
+ version: "0.30"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ary Borenszweig