Module: OracleSqlParser::Grammar::Select::Order

Includes:
Treetop::Runtime
Included in:
OracleSqlParser::Grammar::Select, OrderParser
Defined in:
lib/oracle-sql-parser/grammar/select/order.rb

Defined Under Namespace

Modules: OrderByClause0, OrderByClause1, OrderByClauseItem0, OrderByClauseItem1, OrderByClauseItem2, OrderByClauseItems0, OrderByClauseItems1, OrderByClauseItems2

Instance Method Summary collapse

Instance Method Details

#_nt_order_by_clauseObject



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

def _nt_order_by_clause
  start_index = index
  if node_cache[:order_by_clause].has_key?(index)
    cached = node_cache[:order_by_clause][index]
    if cached
      node_cache[:order_by_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_order_keyword
  s0 << r1
  if r1
    r2 = _nt_space
    s0 << r2
    if r2
      r4 = _nt_siblings_keyword
      if r4
        r3 = r4
      else
        r3 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r3
      if r3
        r6 = _nt_space
        if r6
          r5 = r6
        else
          r5 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r5
        if r5
          r7 = _nt_by_keyword
          s0 << r7
          if r7
            r8 = _nt_space
            s0 << r8
            if r8
              r9 = _nt_order_by_clause_items
              s0 << r9
            end
          end
        end
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(OrderByClause0)
    r0.extend(OrderByClause1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:order_by_clause][start_index] = r0

  r0
end

#_nt_order_by_clause_itemObject



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

def _nt_order_by_clause_item
  start_index = index
  if node_cache[:order_by_clause_item].has_key?(index)
    cached = node_cache[:order_by_clause_item][index]
    if cached
      node_cache[:order_by_clause_item][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_expr
  if r2
    r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
    r1 = r2
  else
    r3 = _nt_position
    if r3
      r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
      r1 = r3
    else
      r4 = _nt_c_alias
      if r4
        r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
        r1 = r4
      else
        @index = i1
        r1 = nil
      end
    end
  end
  s0 << r1
  if r1
    r6 = _nt_space
    if r6
      r5 = r6
    else
      r5 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r5
    if r5
      i8 = index
      r9 = _nt_asc_keyword
      if r9
        r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
        r8 = r9
      else
        r10 = _nt_desc_keyword
        if r10
          r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
          r8 = r10
        else
          @index = i8
          r8 = nil
        end
      end
      if r8
        r7 = r8
      else
        r7 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r7
      if r7
        r12 = _nt_space
        if r12
          r11 = r12
        else
          r11 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r11
        if r11
          i14, s14 = index, []
          r15 = _nt_nulls_keyword
          s14 << r15
          if r15
            r16 = _nt_space
            s14 << r16
            if r16
              i17 = index
              r18 = _nt_first_keyword
              if r18
                r18 = SyntaxNode.new(input, (index-1)...index) if r18 == true
                r17 = r18
              else
                r19 = _nt_last_keyword
                if r19
                  r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true
                  r17 = r19
                else
                  @index = i17
                  r17 = nil
                end
              end
              s14 << r17
            end
          end
          if s14.last
            r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
            r14.extend(OrderByClauseItem0)
          else
            @index = i14
            r14 = nil
          end
          if r14
            r13 = r14
          else
            r13 = instantiate_node(SyntaxNode,input, index...index)
          end
          s0 << r13
        end
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(OrderByClauseItem1)
    r0.extend(OrderByClauseItem2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:order_by_clause_item][start_index] = r0

  r0
end

#_nt_order_by_clause_itemsObject



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

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

  i0, s0 = index, []
  r1 = _nt_order_by_clause_item
  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_order_by_clause_item
            s3 << r9
            if r9
              r11 = _nt_space
              if r11
                r10 = r11
              else
                r10 = instantiate_node(SyntaxNode,input, index...index)
              end
              s3 << r10
            end
          end
        end
      end
      if s3.last
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        r3.extend(OrderByClauseItems0)
      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(OrderByClauseItems1)
    r0.extend(OrderByClauseItems2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:order_by_clause_items][start_index] = r0

  r0
end

#rootObject



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

def root
  @root ||= :order_by_clause
end