Module: OracleSqlParser::Grammar::Expression

Includes:
Case, Compound, Cursor, Datetime, Function, Interval, Simple, Treetop::Runtime
Included in:
ExpressionParser, Grammar
Defined in:
lib/oracle-sql-parser/grammar/expression.rb,
lib/oracle-sql-parser/grammar/expression/case.rb,
lib/oracle-sql-parser/grammar/expression/cursor.rb,
lib/oracle-sql-parser/grammar/expression/simple.rb,
lib/oracle-sql-parser/grammar/expression/compound.rb,
lib/oracle-sql-parser/grammar/expression/datetime.rb,
lib/oracle-sql-parser/grammar/expression/function.rb,
lib/oracle-sql-parser/grammar/expression/interval.rb

Defined Under Namespace

Modules: Case, Compound, Cursor, Datetime, Expr0, ExpressionList0, ExpressionList1, ExpressionList2, Exprs0, Exprs1, Exprs2, Function, Interval, NotLoopSqlExpression0, NotLoopSqlExpression1, Simple, SqlExpression0, SqlExpression1 Classes: CaseParser, CompoundParser, CursorParser, DatetimeParser, FunctionParser, IntervalParser, SimpleParser

Instance Method Summary collapse

Methods included from Interval

#_nt_fractional_second_precision, #_nt_interval_expression, #_nt_leading_field_precision

Methods included from Datetime

#_nt_datetime_expression, #_nt_datetime_timezone_clause

Methods included from Cursor

#_nt_cursor_expression

Methods included from Simple

#_nt_simple_expression, #_nt_simple_expression_column

Methods included from Case

#_nt_case_expression, #_nt_comparison_expr, #_nt_else_clause, #_nt_else_expr, #_nt_return_expr, #_nt_searched_case_expression, #_nt_simple_case_expression

Methods included from Function

#_nt_function_arg, #_nt_function_args, #_nt_function_expression, #_nt_function_name

Methods included from Compound

#_nt_compound_expression

Instance Method Details

#_nt_column_expressionObject



374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 374

def _nt_column_expression
  start_index = index
  if node_cache[:column_expression].has_key?(index)
    cached = node_cache[:column_expression][index]
    if cached
      node_cache[:column_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if (match_len = has_terminal?('column_expression', false, index))
    r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
    @index += match_len
  else
    terminal_parse_failure('\'column_expression\'')
    r0 = nil
  end

  node_cache[:column_expression][start_index] = r0

  r0
end

#_nt_exprObject



625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 625

def _nt_expr
  start_index = index
  if node_cache[:expr].has_key?(index)
    cached = node_cache[:expr][index]
    if cached
      node_cache[:expr][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  r0 = _nt_sql_expression
  r0.extend(Expr0)
  r0.extend(Expr0)

  node_cache[:expr][start_index] = r0

  r0
end

#_nt_expression_listObject



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 441

def _nt_expression_list
  start_index = index
  if node_cache[:expression_list].has_key?(index)
    cached = node_cache[:expression_list][index]
    if cached
      node_cache[:expression_list][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  i1, s1 = index, []
  if (match_len = has_terminal?('(', false, index))
    r2 = true
    @index += match_len
  else
    terminal_parse_failure('\'(\'')
    r2 = nil
  end
  s1 << r2
  if r2
    r3 = _nt_exprs
    s1 << r3
    if r3
      if (match_len = has_terminal?(')', false, index))
        r4 = true
        @index += match_len
      else
        terminal_parse_failure('\')\'')
        r4 = nil
      end
      s1 << r4
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(ExpressionList0)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
    r0.extend(ExpressionList2)
    r0.extend(ExpressionList2)
  else
    i5, s5 = index, []
    r6 = _nt_exprs
    s5 << r6
    if s5.last
      r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
      r5.extend(ExpressionList1)
    else
      @index = i5
      r5 = nil
    end
    if r5
      r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
      r0 = r5
      r0.extend(ExpressionList2)
      r0.extend(ExpressionList2)
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:expression_list][start_index] = r0

  r0
end

#_nt_exprsObject



541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 541

def _nt_exprs
  start_index = index
  if node_cache[:exprs].has_key?(index)
    cached = node_cache[:exprs][index]
    if cached
      node_cache[:exprs][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0, s0 = index, []
  r1 = _nt_expr
  s0 << r1
  if r1
    s2, i2 = [], index
    loop do
      i3, s3 = index, []
      r5 = _nt_space
      if r5
        r4 = r5
      else
        r4 = instantiate_node(SyntaxNode,input, index...index)
      end
      s3 << r4
      if r4
        if (match_len = has_terminal?(',', false, index))
          r6 = true
          @index += match_len
        else
          terminal_parse_failure('\',\'')
          r6 = nil
        end
        s3 << r6
        if r6
          r8 = _nt_space
          if r8
            r7 = r8
          else
            r7 = instantiate_node(SyntaxNode,input, index...index)
          end
          s3 << r7
          if r7
            r9 = _nt_expr
            s3 << r9
          end
        end
      end
      if s3.last
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        r3.extend(Exprs0)
      else
        @index = i3
        r3 = nil
      end
      if r3
        s2 << r3
      else
        break
      end
    end
    r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
    s0 << r2
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Exprs1)
    r0.extend(Exprs2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:exprs][start_index] = r0

  r0
end

#_nt_json_object_access_expressionObject



398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 398

def _nt_json_object_access_expression
  start_index = index
  if node_cache[:json_object_access_expression].has_key?(index)
    cached = node_cache[:json_object_access_expression][index]
    if cached
      node_cache[:json_object_access_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if (match_len = has_terminal?('json_object_access_expression', false, index))
    r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
    @index += match_len
  else
    terminal_parse_failure('\'json_object_access_expression\'')
    r0 = nil
  end

  node_cache[:json_object_access_expression][start_index] = r0

  r0
end

#_nt_model_expressionObject



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 302

def _nt_model_expression
  start_index = index
  if node_cache[:model_expression].has_key?(index)
    cached = node_cache[:model_expression][index]
    if cached
      node_cache[:model_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if (match_len = has_terminal?('model_expression', false, index))
    r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
    @index += match_len
  else
    terminal_parse_failure('\'model_expression\'')
    r0 = nil
  end

  node_cache[:model_expression][start_index] = r0

  r0
end

#_nt_not_loop_sql_expressionObject



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
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 170

def _nt_not_loop_sql_expression
  start_index = index
  if node_cache[:not_loop_sql_expression].has_key?(index)
    cached = node_cache[:not_loop_sql_expression][index]
    if cached
      node_cache[:not_loop_sql_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0, s0 = index, []
  i1 = index
  r2 = _nt_function_expression
  if r2
    r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
    r1 = r2
  else
    r3 = _nt_case_expression
    if r3
      r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
      r1 = r3
    else
      r4 = _nt_cursor_expression
      if r4
        r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
        r1 = r4
      else
        r5 = _nt_object_access_expression
        if r5
          r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
          r1 = r5
        else
          r6 = _nt_scalar_subquery_expression
          if r6
            r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
            r1 = r6
          else
            r7 = _nt_model_expression
            if r7
              r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
              r1 = r7
            else
              r8 = _nt_type_constructor_expression
              if r8
                r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
                r1 = r8
              else
                r9 = _nt_simple_expression
                if r9
                  r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
                  r1 = r9
                else
                  r10 = _nt_variable_expression
                  if r10
                    r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
                    r1 = r10
                  else
                    @index = i1
                    r1 = nil
                  end
                end
              end
            end
          end
        end
      end
    end
  end
  s0 << r1
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(NotLoopSqlExpression0)
    r0.extend(NotLoopSqlExpression1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:not_loop_sql_expression][start_index] = r0

  r0
end

#_nt_object_access_expressionObject



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 254

def _nt_object_access_expression
  start_index = index
  if node_cache[:object_access_expression].has_key?(index)
    cached = node_cache[:object_access_expression][index]
    if cached
      node_cache[:object_access_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if (match_len = has_terminal?('object_access_expression', false, index))
    r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
    @index += match_len
  else
    terminal_parse_failure('\'object_access_expression\'')
    r0 = nil
  end

  node_cache[:object_access_expression][start_index] = r0

  r0
end

#_nt_scalar_subquery_expressionObject



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 278

def _nt_scalar_subquery_expression
  start_index = index
  if node_cache[:scalar_subquery_expression].has_key?(index)
    cached = node_cache[:scalar_subquery_expression][index]
    if cached
      node_cache[:scalar_subquery_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if (match_len = has_terminal?('scalar_subquery_expression', false, index))
    r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
    @index += match_len
  else
    terminal_parse_failure('\'scalar_subquery_expression\'')
    r0 = nil
  end

  node_cache[:scalar_subquery_expression][start_index] = r0

  r0
end

#_nt_sql_expressionObject



38
39
40
41
42
43
44
45
46
47
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
117
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
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 38

def _nt_sql_expression
  start_index = index
  if node_cache[:sql_expression].has_key?(index)
    cached = node_cache[:sql_expression][index]
    if cached
      node_cache[:sql_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0, s0 = index, []
  i1 = index
  r2 = _nt_interval_expression
  if r2
    r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
    r1 = r2
  else
    r3 = _nt_compound_expression
    if r3
      r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
      r1 = r3
    else
      r4 = _nt_function_expression
      if r4
        r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
        r1 = r4
      else
        r5 = _nt_case_expression
        if r5
          r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
          r1 = r5
        else
          r6 = _nt_cursor_expression
          if r6
            r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
            r1 = r6
          else
            r7 = _nt_datetime_expression
            if r7
              r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
              r1 = r7
            else
              r8 = _nt_object_access_expression
              if r8
                r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
                r1 = r8
              else
                r9 = _nt_scalar_subquery_expression
                if r9
                  r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
                  r1 = r9
                else
                  r10 = _nt_model_expression
                  if r10
                    r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
                    r1 = r10
                  else
                    r11 = _nt_type_constructor_expression
                    if r11
                      r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
                      r1 = r11
                    else
                      r12 = _nt_simple_expression
                      if r12
                        r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
                        r1 = r12
                      else
                        r13 = _nt_variable_expression
                        if r13
                          r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
                          r1 = r13
                        else
                          r14 = _nt_column_expression
                          if r14
                            r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
                            r1 = r14
                          else
                            r15 = _nt_json_object_access_expression
                            if r15
                              r15 = SyntaxNode.new(input, (index-1)...index) if r15 == true
                              r1 = r15
                            else
                              r16 = _nt_object_access_expression
                              if r16
                                r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
                                r1 = r16
                              else
                                @index = i1
                                r1 = nil
                              end
                            end
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
  s0 << r1
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(SqlExpression0)
    r0.extend(SqlExpression1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:sql_expression][start_index] = r0

  r0
end

#_nt_type_constructor_expressionObject



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 326

def _nt_type_constructor_expression
  start_index = index
  if node_cache[:type_constructor_expression].has_key?(index)
    cached = node_cache[:type_constructor_expression][index]
    if cached
      node_cache[:type_constructor_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if (match_len = has_terminal?('type_constructor_expression', false, index))
    r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
    @index += match_len
  else
    terminal_parse_failure('\'type_constructor_expression\'')
    r0 = nil
  end

  node_cache[:type_constructor_expression][start_index] = r0

  r0
end

#_nt_variable_expressionObject



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 350

def _nt_variable_expression
  start_index = index
  if node_cache[:variable_expression].has_key?(index)
    cached = node_cache[:variable_expression][index]
    if cached
      node_cache[:variable_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if (match_len = has_terminal?('variable_expression', false, index))
    r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
    @index += match_len
  else
    terminal_parse_failure('\'variable_expression\'')
    r0 = nil
  end

  node_cache[:variable_expression][start_index] = r0

  r0
end

#rootObject



8
9
10
# File 'lib/oracle-sql-parser/grammar/expression.rb', line 8

def root
  @root ||= :sql_expression
end