Module: OracleSqlParser::Grammar::Expression::Compound

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

Defined Under Namespace

Modules: CompoundExpression0, CompoundExpression1, CompoundExpression2, CompoundExpression3, CompoundExpression4

Instance Method Summary collapse

Instance Method Details

#_nt_compound_expressionObject



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

def _nt_compound_expression
  start_index = index
  if node_cache[:compound_expression].has_key?(index)
    cached = node_cache[:compound_expression][index]
    if cached
      node_cache[:compound_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
  i2, s2 = index, []
  if (match_len = has_terminal?('(', false, index))
    r3 = true
    @index += match_len
  else
    terminal_parse_failure('\'(\'')
    r3 = nil
  end
  s2 << r3
  if r3
    r5 = _nt_space
    if r5
      r4 = r5
    else
      r4 = instantiate_node(SyntaxNode,input, index...index)
    end
    s2 << r4
    if r4
      r6 = _nt_expr
      s2 << r6
      if r6
        r8 = _nt_space
        if r8
          r7 = r8
        else
          r7 = instantiate_node(SyntaxNode,input, index...index)
        end
        s2 << r7
        if r7
          if (match_len = has_terminal?(')', false, index))
            r9 = true
            @index += match_len
          else
            terminal_parse_failure('\')\'')
            r9 = nil
          end
          s2 << r9
        end
      end
    end
  end
  if s2.last
    r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
    r2.extend(CompoundExpression0)
  else
    @index = i2
    r2 = nil
  end
  if r2
    r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
    r1 = r2
  else
    i10, s10 = index, []
    r11 = _nt_not_loop_sql_expression
    s10 << r11
    if r11
      r13 = _nt_space
      if r13
        r12 = r13
      else
        r12 = instantiate_node(SyntaxNode,input, index...index)
      end
      s10 << r12
      if r12
        i14 = index
        if (match_len = has_terminal?('*', false, index))
          r15 = true
          @index += match_len
        else
          terminal_parse_failure('\'*\'')
          r15 = nil
        end
        if r15
          r15 = SyntaxNode.new(input, (index-1)...index) if r15 == true
          r14 = r15
        else
          if (match_len = has_terminal?('/', false, index))
            r16 = true
            @index += match_len
          else
            terminal_parse_failure('\'/\'')
            r16 = nil
          end
          if r16
            r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
            r14 = r16
          else
            if (match_len = has_terminal?('+', false, index))
              r17 = true
              @index += match_len
            else
              terminal_parse_failure('\'+\'')
              r17 = nil
            end
            if r17
              r17 = SyntaxNode.new(input, (index-1)...index) if r17 == true
              r14 = r17
            else
              if (match_len = has_terminal?('-', false, index))
                r18 = true
                @index += match_len
              else
                terminal_parse_failure('\'-\'')
                r18 = nil
              end
              if r18
                r18 = SyntaxNode.new(input, (index-1)...index) if r18 == true
                r14 = r18
              else
                if (match_len = has_terminal?('||', false, index))
                  r19 = instantiate_node(SyntaxNode,input, index...(index + match_len))
                  @index += match_len
                else
                  terminal_parse_failure('\'||\'')
                  r19 = nil
                end
                if r19
                  r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true
                  r14 = r19
                else
                  @index = i14
                  r14 = nil
                end
              end
            end
          end
        end
        s10 << r14
        if r14
          r21 = _nt_space
          if r21
            r20 = r21
          else
            r20 = instantiate_node(SyntaxNode,input, index...index)
          end
          s10 << r20
          if r20
            r22 = _nt_expr
            s10 << r22
          end
        end
      end
    end
    if s10.last
      r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
      r10.extend(CompoundExpression1)
    else
      @index = i10
      r10 = nil
    end
    if r10
      r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
      r1 = r10
    else
      i23, s23 = index, []
      i24 = index
      r25 = _nt_number_literal
      if r25
        @index = i24
        r24 = nil
      else
        @index = i24
        r24 = instantiate_node(SyntaxNode,input, index...index)
      end
      s23 << r24
      if r24
        i26 = index
        r27 = _nt_prior_keyword
        if r27
          r27 = SyntaxNode.new(input, (index-1)...index) if r27 == true
          r26 = r27
        else
          if (match_len = has_terminal?('-', false, index))
            r28 = true
            @index += match_len
          else
            terminal_parse_failure('\'-\'')
            r28 = nil
          end
          if r28
            r28 = SyntaxNode.new(input, (index-1)...index) if r28 == true
            r26 = r28
          else
            if (match_len = has_terminal?('+', false, index))
              r29 = true
              @index += match_len
            else
              terminal_parse_failure('\'+\'')
              r29 = nil
            end
            if r29
              r29 = SyntaxNode.new(input, (index-1)...index) if r29 == true
              r26 = r29
            else
              @index = i26
              r26 = nil
            end
          end
        end
        s23 << r26
        if r26
          r31 = _nt_space
          if r31
            r30 = r31
          else
            r30 = instantiate_node(SyntaxNode,input, index...index)
          end
          s23 << r30
          if r30
            r32 = _nt_expr
            s23 << r32
          end
        end
      end
      if s23.last
        r23 = instantiate_node(SyntaxNode,input, i23...index, s23)
        r23.extend(CompoundExpression2)
      else
        @index = i23
        r23 = nil
      end
      if r23
        r23 = SyntaxNode.new(input, (index-1)...index) if r23 == true
        r1 = r23
      else
        @index = i1
        r1 = nil
      end
    end
  end
  s0 << r1
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(CompoundExpression3)
    r0.extend(CompoundExpression4)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:compound_expression][start_index] = r0

  r0
end

#rootObject



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

def root
  @root ||= :compound_expression
end