Module: OracleSqlParser::Grammar::Expression::Case

Includes:
Treetop::Runtime
Included in:
OracleSqlParser::Grammar::Expression, CaseParser
Defined in:
lib/oracle-sql-parser/grammar/expression/case.rb

Defined Under Namespace

Modules: CaseExpression0, CaseExpression1, ComparisonExpr0, ElseClause0, ElseClause1, ElseExpr0, ReturnExpr0, SearchedCaseExpression0, SearchedCaseExpression1, SimpleCaseExpression0, SimpleCaseExpression1, SimpleCaseExpression2

Instance Method Summary collapse

Instance Method Details

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

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

  i0, s0 = index, []
  r1 = _nt_case_keyword
  s0 << r1
  if r1
    r3 = _nt_space
    if r3
      r2 = r3
    else
      r2 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r2
    if r2
      i4 = index
      r5 = _nt_simple_case_expression
      if r5
        r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
        r4 = r5
      else
        r6 = _nt_searched_case_expression
        if r6
          r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
          r4 = r6
        else
          @index = i4
          r4 = nil
        end
      end
      s0 << r4
      if r4
        r8 = _nt_space
        if r8
          r7 = r8
        else
          r7 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r7
        if r7
          r10 = _nt_else_clause
          if r10
            r9 = r10
          else
            r9 = instantiate_node(SyntaxNode,input, index...index)
          end
          s0 << r9
          if r9
            r12 = _nt_space
            if r12
              r11 = r12
            else
              r11 = instantiate_node(SyntaxNode,input, index...index)
            end
            s0 << r11
            if r11
              r13 = _nt_end_keyword
              s0 << r13
            end
          end
        end
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(CaseExpression0)
    r0.extend(CaseExpression1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:case_expression][start_index] = r0

  r0
end

#_nt_comparison_exprObject



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/oracle-sql-parser/grammar/expression/case.rb', line 286

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

  r0 = _nt_expr
  r0.extend(ComparisonExpr0)
  r0.extend(ComparisonExpr0)

  node_cache[:comparison_expr][start_index] = r0

  r0
end

#_nt_else_clauseObject



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

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

  i0, s0 = index, []
  r1 = _nt_else_keyword
  s0 << r1
  if r1
    r3 = _nt_space
    if r3
      r2 = r3
    else
      r2 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r2
    if r2
      r4 = _nt_else_expr
      s0 << r4
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(ElseClause0)
    r0.extend(ElseClause1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:else_clause][start_index] = r0

  r0
end

#_nt_else_exprObject



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/oracle-sql-parser/grammar/expression/case.rb', line 338

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

  r0 = _nt_expr
  r0.extend(ElseExpr0)
  r0.extend(ElseExpr0)

  node_cache[:else_expr][start_index] = r0

  r0
end

#_nt_return_exprObject



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/oracle-sql-parser/grammar/expression/case.rb', line 312

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

  r0 = _nt_expr
  r0.extend(ReturnExpr0)
  r0.extend(ReturnExpr0)

  node_cache[:return_expr][start_index] = r0

  r0
end

#_nt_searched_case_expressionObject



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/oracle-sql-parser/grammar/expression/case.rb', line 385

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

  i0, s0 = index, []
  r1 = _nt_when_keyword
  s0 << r1
  if r1
    r3 = _nt_space
    if r3
      r2 = r3
    else
      r2 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r2
    if r2
      r4 = _nt_condition
      s0 << r4
      if r4
        r6 = _nt_space
        if r6
          r5 = r6
        else
          r5 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r5
        if r5
          r7 = _nt_then_keyword
          s0 << r7
          if r7
            r9 = _nt_space
            if r9
              r8 = r9
            else
              r8 = instantiate_node(SyntaxNode,input, index...index)
            end
            s0 << r8
            if r8
              r10 = _nt_return_expr
              s0 << r10
            end
          end
        end
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(SearchedCaseExpression0)
    r0.extend(SearchedCaseExpression1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:searched_case_expression][start_index] = r0

  r0
end

#_nt_simple_case_expressionObject



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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/oracle-sql-parser/grammar/expression/case.rb', line 183

def _nt_simple_case_expression
  start_index = index
  if node_cache[:simple_case_expression].has_key?(index)
    cached = node_cache[:simple_case_expression][index]
    if cached
      node_cache[:simple_case_expression][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
    r2 = _nt_space
    s0 << r2
    if r2
      s3, i3 = [], index
      loop do
        i4, s4 = index, []
        r5 = _nt_when_keyword
        s4 << r5
        if r5
          r6 = _nt_space
          s4 << r6
          if r6
            r7 = _nt_comparison_expr
            s4 << r7
            if r7
              r8 = _nt_space
              s4 << r8
              if r8
                r9 = _nt_then_keyword
                s4 << r9
                if r9
                  r11 = _nt_space
                  if r11
                    r10 = r11
                  else
                    r10 = instantiate_node(SyntaxNode,input, index...index)
                  end
                  s4 << r10
                  if r10
                    r12 = _nt_return_expr
                    s4 << r12
                    if r12
                      r14 = _nt_space
                      if r14
                        r13 = r14
                      else
                        r13 = instantiate_node(SyntaxNode,input, index...index)
                      end
                      s4 << r13
                    end
                  end
                end
              end
            end
          end
        end
        if s4.last
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          r4.extend(SimpleCaseExpression0)
        else
          @index = i4
          r4 = nil
        end
        if r4
          s3 << r4
        else
          break
        end
      end
      if s3.empty?
        @index = i3
        r3 = nil
      else
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
      end
      s0 << r3
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(SimpleCaseExpression1)
    r0.extend(SimpleCaseExpression2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:simple_case_expression][start_index] = r0

  r0
end

#rootObject



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

def root
  @root ||= :case_expression
end