Module: ActiveFacts::CQL::Context

Includes:
Treetop::Runtime
Included in:
CQL, ContextParser
Defined in:
lib/activefacts/cql/parser/Context.rb

Defined Under Namespace

Modules: ContextNote0, ContextNote1, ContextNote2, ContextType0, ContextType1, ContextType2, ContextType3, ContextType4, Description0, Description1, Description2, Description3, WhoSays0, WhoSays1

Instance Method Summary collapse

Instance Method Details

#_nt_context_noteObject



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
# File 'lib/activefacts/cql/parser/Context.rb', line 70

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

  i0, s0 = index, []
  if (match_len = has_terminal?('(', false, index))
    r1 = true
    @index += match_len
  else
    terminal_parse_failure('\'(\'')
    r1 = nil
  end
  s0 << r1
  if r1
    r2 = _nt_s
    s0 << r2
    if r2
      r4 = _nt_who_says
      if r4
        r3 = r4
      else
        r3 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r3
      if r3
        r5 = _nt_s
        s0 << r5
        if r5
          r6 = _nt_context_type
          s0 << r6
          if r6
            r7 = _nt_description
            s0 << r7
            if r7
              i9, s9 = index, []
              if (match_len = has_terminal?(',', false, index))
                r10 = true
                @index += match_len
              else
                terminal_parse_failure('\',\'')
                r10 = nil
              end
              s9 << r10
              if r10
                r11 = _nt_as_agreed_by
                s9 << r11
              end
              if s9.last
                r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
                r9.extend(ContextNote0)
              else
                @index = i9
                r9 = nil
              end
              if r9
                r8 = r9
              else
                r8 = instantiate_node(SyntaxNode,input, index...index)
              end
              s0 << r8
              if r8
                r12 = _nt_s
                s0 << r12
                if r12
                  if (match_len = has_terminal?(')', false, index))
                    r13 = true
                    @index += match_len
                  else
                    terminal_parse_failure('\')\'')
                    r13 = nil
                  end
                  s0 << r13
                  if r13
                    r14 = _nt_s
                    s0 << r14
                  end
                end
              end
            end
          end
        end
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(ContextNote1)
    r0.extend(ContextNote2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:context_note][start_index] = r0

  r0
end

#_nt_context_typeObject



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
# File 'lib/activefacts/cql/parser/Context.rb', line 266

def _nt_context_type
  start_index = index
  if node_cache[:context_type].has_key?(index)
    cached = node_cache[:context_type][index]
    if cached
      node_cache[:context_type][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_because
  s1 << r2
  if r2
    r3 = _nt_s
    s1 << r3
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(ContextType0)
    r1.extend(ContextType1)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    r4 = _nt_as_opposed_to
    r4.extend(ContextType2)
    r4.extend(ContextType2)
    if r4
      r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
      r0 = r4
    else
      r5 = _nt_so_that
      r5.extend(ContextType3)
      r5.extend(ContextType3)
      if r5
        r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
        r0 = r5
      else
        r6 = _nt_to_avoid
        r6.extend(ContextType4)
        r6.extend(ContextType4)
        if r6
          r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
          r0 = r6
        else
          @index = i0
          r0 = nil
        end
      end
    end
  end

  node_cache[:context_type][start_index] = r0

  r0
end

#_nt_descriptionObject



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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/activefacts/cql/parser/Context.rb', line 350

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

  i0 = index
  i1, s1 = index, []
  if (match_len = has_terminal?('(', false, index))
    r2 = true
    @index += match_len
  else
    terminal_parse_failure('\'(\'')
    r2 = nil
  end
  s1 << r2
  if r2
    r3 = _nt_description
    s1 << r3
    if r3
      if (match_len = has_terminal?(')', false, index))
        r4 = true
        @index += match_len
      else
        terminal_parse_failure('\')\'')
        r4 = nil
      end
      s1 << r4
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(Description0)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    s5, i5 = [], index
    loop do
      i6, s6 = index, []
      i7 = index
      i8 = index
      if has_terminal?(@regexps[gr = '\A[()]'] ||= Regexp.new(gr), :regexp, index)
        r9 = true
        @index += 1
      else
        terminal_parse_failure('[()]')
        r9 = nil
      end
      if r9
        r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
        r8 = r9
      else
        i10, s10 = index, []
        if (match_len = has_terminal?(',', false, index))
          r11 = true
          @index += match_len
        else
          terminal_parse_failure('\',\'')
          r11 = nil
        end
        s10 << r11
        if r11
          r12 = _nt_as_agreed_by
          s10 << r12
        end
        if s10.last
          r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
          r10.extend(Description1)
        else
          @index = i10
          r10 = nil
        end
        if r10
          r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
          r8 = r10
        else
          @index = i8
          r8 = nil
        end
      end
      if r8
        @index = i7
        r7 = nil
        terminal_parse_failure("(any alternative)", true)
      else
        @terminal_failures.pop
        @index = i7
        r7 = instantiate_node(SyntaxNode,input, index...index)
      end
      s6 << r7
      if r7
        if index < input_length
          r13 = true
          @index += 1
        else
          terminal_parse_failure("any character")
          r13 = nil
        end
        s6 << r13
      end
      if s6.last
        r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
        r6.extend(Description2)
      else
        @index = i6
        r6 = nil
      end
      if r6
        s5 << r6
      else
        break
      end
    end
    r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
    r5.extend(Description3)
    r5.extend(Description3)
    if r5
      r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
      r0 = r5
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:description][start_index] = r0

  r0
end

#_nt_who_saysObject



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
# File 'lib/activefacts/cql/parser/Context.rb', line 194

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

  i0, s0 = index, []
  r1 = _nt_according_to
  s0 << r1
  if r1
    r2 = _nt_agents
    s0 << r2
    if r2
      r3 = _nt_s
      s0 << r3
      if r3
        if (match_len = has_terminal?(',', false, index))
          r4 = true
          @index += match_len
        else
          terminal_parse_failure('\',\'')
          r4 = nil
        end
        s0 << r4
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(WhoSays0)
    r0.extend(WhoSays1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:who_says][start_index] = r0

  r0
end

#rootObject



15
16
17
# File 'lib/activefacts/cql/parser/Context.rb', line 15

def root
  @root ||= :context_note
end