Module: Laser::Parsers::Structural

Includes:
GeneralPurpose, Treetop::Runtime
Included in:
Annotation, StructuralParser
Defined in:
lib/laser/annotation_parser/structural_parser.rb

Defined Under Namespace

Modules: StructuralConstraint0, StructuralConstraint1, StructuralConstraint2, StructuralConstraint3, StructuralConstraint4, StructuralConstraint5, StructuralConstraint6, StructuralConstraint7, StructuralConstraint8, StructuralConstraint9

Instance Method Summary (collapse)

Methods included from GeneralPurpose

#_nt_annotation_name, #_nt_method_name, #_nt_operator, #_nt_parenthesized_type_list, #_nt_space, #_nt_type_list

Instance Method Details

- (Object) _nt_structural_constraint



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
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
# File 'lib/laser/annotation_parser/structural_parser.rb', line 106

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

  i0 = index
  i1, s1 = index, []
  if has_terminal?('#', false, index)
    r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure('#')
    r2 = nil
  end
  s1 << r2
  if r2
    r3 = _nt_method_name
    s1 << r3
    if r3
      s4, i4 = [], index
      loop do
        r5 = _nt_space
        if r5
          s4 << r5
        else
          break
        end
      end
      r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
      s1 << r4
      if r4
        r6 = _nt_parenthesized_type_list
        s1 << r6
        if r6
          s7, i7 = [], index
          loop do
            r8 = _nt_space
            if r8
              s7 << r8
            else
              break
            end
          end
          r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
          s1 << r7
          if r7
            if has_terminal?('->', false, index)
              r9 = instantiate_node(SyntaxNode,input, index...(index + 2))
              @index += 2
            else
              terminal_parse_failure('->')
              r9 = nil
            end
            s1 << r9
            if r9
              s10, i10 = [], index
              loop do
                r11 = _nt_space
                if r11
                  s10 << r11
                else
                  break
                end
              end
              r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
              s1 << r10
              if r10
                r12 = _nt_type
                s1 << r12
              end
            end
          end
        end
      end
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(StructuralConstraint0)
    r1.extend(StructuralConstraint1)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r0 = r1
  else
    i13, s13 = index, []
    if has_terminal?('#', false, index)
      r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure('#')
      r14 = nil
    end
    s13 << r14
    if r14
      r15 = _nt_method_name
      s13 << r15
      if r15
        s16, i16 = [], index
        loop do
          r17 = _nt_space
          if r17
            s16 << r17
          else
            break
          end
        end
        r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
        s13 << r16
        if r16
          r18 = _nt_parenthesized_type_list
          s13 << r18
          if r18
            s19, i19 = [], index
            loop do
              r20 = _nt_space
              if r20
                s19 << r20
              else
                break
              end
            end
            r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
            s13 << r19
            if r19
              r21 = _nt_type
              s13 << r21
            end
          end
        end
      end
    end
    if s13.last
      r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
      r13.extend(StructuralConstraint2)
      r13.extend(StructuralConstraint3)
    else
      @index = i13
      r13 = nil
    end
    if r13
      r0 = r13
    else
      i22, s22 = index, []
      if has_terminal?('#', false, index)
        r23 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('#')
        r23 = nil
      end
      s22 << r23
      if r23
        r24 = _nt_method_name
        s22 << r24
        if r24
          s25, i25 = [], index
          loop do
            r26 = _nt_space
            if r26
              s25 << r26
            else
              break
            end
          end
          r25 = instantiate_node(SyntaxNode,input, i25...index, s25)
          s22 << r25
          if r25
            r27 = _nt_parenthesized_type_list
            s22 << r27
          end
        end
      end
      if s22.last
        r22 = instantiate_node(SyntaxNode,input, i22...index, s22)
        r22.extend(StructuralConstraint4)
        r22.extend(StructuralConstraint5)
      else
        @index = i22
        r22 = nil
      end
      if r22
        r0 = r22
      else
        i28, s28 = index, []
        if has_terminal?('#', false, index)
          r29 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure('#')
          r29 = nil
        end
        s28 << r29
        if r29
          r30 = _nt_method_name
          s28 << r30
          if r30
            s31, i31 = [], index
            loop do
              r32 = _nt_space
              if r32
                s31 << r32
              else
                break
              end
            end
            r31 = instantiate_node(SyntaxNode,input, i31...index, s31)
            s28 << r31
            if r31
              if has_terminal?('->', false, index)
                r33 = instantiate_node(SyntaxNode,input, index...(index + 2))
                @index += 2
              else
                terminal_parse_failure('->')
                r33 = nil
              end
              s28 << r33
              if r33
                s34, i34 = [], index
                loop do
                  r35 = _nt_space
                  if r35
                    s34 << r35
                  else
                    break
                  end
                end
                r34 = instantiate_node(SyntaxNode,input, i34...index, s34)
                s28 << r34
                if r34
                  r36 = _nt_type
                  s28 << r36
                end
              end
            end
          end
        end
        if s28.last
          r28 = instantiate_node(SyntaxNode,input, i28...index, s28)
          r28.extend(StructuralConstraint6)
          r28.extend(StructuralConstraint7)
        else
          @index = i28
          r28 = nil
        end
        if r28
          r0 = r28
        else
          i37, s37 = index, []
          if has_terminal?('#', false, index)
            r38 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure('#')
            r38 = nil
          end
          s37 << r38
          if r38
            r39 = _nt_method_name
            s37 << r39
          end
          if s37.last
            r37 = instantiate_node(SyntaxNode,input, i37...index, s37)
            r37.extend(StructuralConstraint8)
            r37.extend(StructuralConstraint9)
          else
            @index = i37
            r37 = nil
          end
          if r37
            r0 = r37
          else
            @index = i0
            r0 = nil
          end
        end
      end
    end
  end

  node_cache[:structural_constraint][start_index] = r0

  r0
end

- (Object) root



10
11
12
# File 'lib/laser/annotation_parser/structural_parser.rb', line 10

def root
  @root ||= :structural_constraint
end