Module: OracleSqlParser::Grammar::Condition::Comparison

Includes:
Treetop::Runtime
Included in:
OracleSqlParser::Grammar::Condition, ComparisonParser
Defined in:
lib/oracle-sql-parser/grammar/condition/comparison.rb

Defined Under Namespace

Modules: ComparisonCondition0, SimpleComparisonCondition0, SimpleComparisonCondition1, SimpleComparisonCondition2

Instance Method Summary collapse

Instance Method Details

#_nt_comparison_conditionObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/oracle-sql-parser/grammar/condition/comparison.rb', line 18

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

  i0 = index
  r1 = _nt_simple_comparison_condition
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
    r0.extend(ComparisonCondition0)
    r0.extend(ComparisonCondition0)
  else
    r2 = _nt_group_comparison_condition
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
      r0.extend(ComparisonCondition0)
      r0.extend(ComparisonCondition0)
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:comparison_condition][start_index] = r0

  r0
end

#_nt_group_comparison_conditionObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/oracle-sql-parser/grammar/condition/comparison.rb', line 54

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

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

  node_cache[:group_comparison_condition][start_index] = r0

  r0
end

#_nt_simple_comparison_conditionObject



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
157
158
159
160
161
162
163
164
165
166
167
168
169
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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
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
# File 'lib/oracle-sql-parser/grammar/condition/comparison.rb', line 116

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

  i0 = index
  i1, s1 = index, []
  r2 = _nt_expr
  s1 << r2
  if r2
    r4 = _nt_space
    if r4
      r3 = r4
    else
      r3 = instantiate_node(SyntaxNode,input, index...index)
    end
    s1 << r3
    if r3
      i5 = index
      if (match_len = has_terminal?('!=', false, index))
        r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('\'!=\'')
        r6 = nil
      end
      if r6
        r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
        r5 = r6
      else
        if (match_len = has_terminal?('^=', false, index))
          r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
          @index += match_len
        else
          terminal_parse_failure('\'^=\'')
          r7 = nil
        end
        if r7
          r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
          r5 = r7
        else
          if (match_len = has_terminal?('<>', false, index))
            r8 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            @index += match_len
          else
            terminal_parse_failure('\'<>\'')
            r8 = nil
          end
          if r8
            r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
            r5 = r8
          else
            if (match_len = has_terminal?('>=', false, index))
              r9 = instantiate_node(SyntaxNode,input, index...(index + match_len))
              @index += match_len
            else
              terminal_parse_failure('\'>=\'')
              r9 = nil
            end
            if r9
              r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
              r5 = r9
            else
              if (match_len = has_terminal?('<=', false, index))
                r10 = instantiate_node(SyntaxNode,input, index...(index + match_len))
                @index += match_len
              else
                terminal_parse_failure('\'<=\'')
                r10 = nil
              end
              if r10
                r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
                r5 = r10
              else
                if (match_len = has_terminal?('=', false, index))
                  r11 = true
                  @index += match_len
                else
                  terminal_parse_failure('\'=\'')
                  r11 = nil
                end
                if r11
                  r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
                  r5 = r11
                else
                  if (match_len = has_terminal?('>', false, index))
                    r12 = true
                    @index += match_len
                  else
                    terminal_parse_failure('\'>\'')
                    r12 = nil
                  end
                  if r12
                    r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
                    r5 = r12
                  else
                    if (match_len = has_terminal?('<', false, index))
                      r13 = true
                      @index += match_len
                    else
                      terminal_parse_failure('\'<\'')
                      r13 = nil
                    end
                    if r13
                      r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
                      r5 = r13
                    else
                      @index = i5
                      r5 = nil
                    end
                  end
                end
              end
            end
          end
        end
      end
      s1 << r5
      if r5
        r15 = _nt_space
        if r15
          r14 = r15
        else
          r14 = instantiate_node(SyntaxNode,input, index...index)
        end
        s1 << r14
        if r14
          r16 = _nt_expr
          s1 << r16
        end
      end
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(SimpleComparisonCondition0)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
    r0.extend(SimpleComparisonCondition2)
    r0.extend(SimpleComparisonCondition2)
  else
    i17, s17 = index, []
    if (match_len = has_terminal?('(', false, index))
      r18 = true
      @index += match_len
    else
      terminal_parse_failure('\'(\'')
      r18 = nil
    end
    s17 << r18
    if r18
      r20 = _nt_space
      if r20
        r19 = r20
      else
        r19 = instantiate_node(SyntaxNode,input, index...index)
      end
      s17 << r19
      if r19
        r21 = _nt_exprs
        s17 << r21
        if r21
          r23 = _nt_space
          if r23
            r22 = r23
          else
            r22 = instantiate_node(SyntaxNode,input, index...index)
          end
          s17 << r22
          if r22
            if (match_len = has_terminal?(')', false, index))
              r24 = true
              @index += match_len
            else
              terminal_parse_failure('\')\'')
              r24 = nil
            end
            s17 << r24
            if r24
              r26 = _nt_space
              if r26
                r25 = r26
              else
                r25 = instantiate_node(SyntaxNode,input, index...index)
              end
              s17 << r25
              if r25
                i27 = index
                if (match_len = has_terminal?('!=', false, index))
                  r28 = instantiate_node(SyntaxNode,input, index...(index + match_len))
                  @index += match_len
                else
                  terminal_parse_failure('\'!=\'')
                  r28 = nil
                end
                if r28
                  r28 = SyntaxNode.new(input, (index-1)...index) if r28 == true
                  r27 = r28
                else
                  if (match_len = has_terminal?('^=', false, index))
                    r29 = instantiate_node(SyntaxNode,input, index...(index + match_len))
                    @index += match_len
                  else
                    terminal_parse_failure('\'^=\'')
                    r29 = nil
                  end
                  if r29
                    r29 = SyntaxNode.new(input, (index-1)...index) if r29 == true
                    r27 = r29
                  else
                    if (match_len = has_terminal?('<>', false, index))
                      r30 = instantiate_node(SyntaxNode,input, index...(index + match_len))
                      @index += match_len
                    else
                      terminal_parse_failure('\'<>\'')
                      r30 = nil
                    end
                    if r30
                      r30 = SyntaxNode.new(input, (index-1)...index) if r30 == true
                      r27 = r30
                    else
                      if (match_len = has_terminal?('=', false, index))
                        r31 = true
                        @index += match_len
                      else
                        terminal_parse_failure('\'=\'')
                        r31 = nil
                      end
                      if r31
                        r31 = SyntaxNode.new(input, (index-1)...index) if r31 == true
                        r27 = r31
                      else
                        @index = i27
                        r27 = nil
                      end
                    end
                  end
                end
                s17 << r27
                if r27
                  r33 = _nt_space
                  if r33
                    r32 = r33
                  else
                    r32 = instantiate_node(SyntaxNode,input, index...index)
                  end
                  s17 << r32
                  if r32
                    if (match_len = has_terminal?('(', false, index))
                      r34 = true
                      @index += match_len
                    else
                      terminal_parse_failure('\'(\'')
                      r34 = nil
                    end
                    s17 << r34
                    if r34
                      r36 = _nt_space
                      if r36
                        r35 = r36
                      else
                        r35 = instantiate_node(SyntaxNode,input, index...index)
                      end
                      s17 << r35
                      if r35
                        r37 = _nt_subquery
                        s17 << r37
                        if r37
                          r39 = _nt_space
                          if r39
                            r38 = r39
                          else
                            r38 = instantiate_node(SyntaxNode,input, index...index)
                          end
                          s17 << r38
                          if r38
                            if (match_len = has_terminal?(')', false, index))
                              r40 = true
                              @index += match_len
                            else
                              terminal_parse_failure('\')\'')
                              r40 = nil
                            end
                            s17 << r40
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
    if s17.last
      r17 = instantiate_node(SyntaxNode,input, i17...index, s17)
      r17.extend(SimpleComparisonCondition1)
    else
      @index = i17
      r17 = nil
    end
    if r17
      r17 = SyntaxNode.new(input, (index-1)...index) if r17 == true
      r0 = r17
      r0.extend(SimpleComparisonCondition2)
      r0.extend(SimpleComparisonCondition2)
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:simple_comparison_condition][start_index] = r0

  r0
end

#rootObject



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

def root
  @root ||= :comparison_condition
end