Module: SnipReference

Includes:
Treetop::Runtime
Included in:
SnipReferenceParser
Defined in:
lib/vanilla/snip_reference.rb,
lib/vanilla/snip_reference_parser.rb

Defined Under Namespace

Modules: ArgumentList, ArgumentList0, ArgumentList1, ArgumentSeparator0, NormalArgument, QuotedWord, QuotedWord0, QuotedWord1, SnipCall, SnipCall0, SnipCall1, SnipName, SnipName0, SnipNameWithAttribute

Instance Method Summary collapse

Instance Method Details

#_nt_argumentObject



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/vanilla/snip_reference.rb', line 211

def _nt_argument
  start_index = index
  if node_cache[:argument].has_key?(index)
    cached = node_cache[:argument][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0 = index
  r1 = _nt_unquoted_words
  r1.extend(NormalArgument)
  if r1
    r0 = r1
  else
    r2 = _nt_quoted_word
    r2.extend(NormalArgument)
    if r2
      r0 = r2
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:argument][start_index] = r0

  r0
end

#_nt_argument_listObject



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
# File 'lib/vanilla/snip_reference.rb', line 165

def _nt_argument_list
  start_index = index
  if node_cache[:argument_list].has_key?(index)
    cached = node_cache[:argument_list][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0, s0 = index, []
  r1 = _nt_argument
  s0 << r1
  if r1
    i3, s3 = index, []
    r4 = _nt_argument_separator
    s3 << r4
    if r4
      r5 = _nt_argument_list
      s3 << r5
    end
    if s3.last
      r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
      r3.extend(ArgumentList0)
    else
      @index = i3
      r3 = nil
    end
    if r3
      r2 = r3
    else
      r2 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r2
  end
  if s0.last
    r0 = instantiate_node(ArgumentList,input, i0...index, s0)
    r0.extend(ArgumentList1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:argument_list][start_index] = r0

  r0
end

#_nt_argument_separatorObject



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
# File 'lib/vanilla/snip_reference.rb', line 246

def _nt_argument_separator
  start_index = index
  if node_cache[:argument_separator].has_key?(index)
    cached = node_cache[:argument_separator][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0, s0 = index, []
  if has_terminal?(",", false, index)
    r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure(",")
    r1 = nil
  end
  s0 << r1
  if r1
    r2 = _nt_optional_spaces
    s0 << r2
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(ArgumentSeparator0)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:argument_separator][start_index] = r0

  r0
end

#_nt_optional_spacesObject



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/vanilla/snip_reference.rb', line 466

def _nt_optional_spaces
  start_index = index
  if node_cache[:optional_spaces].has_key?(index)
    cached = node_cache[:optional_spaces][index]
    @index = cached.interval.end if cached
    return cached
  end

  s0, i0 = [], index
  loop do
    if has_terminal?('\G[ ]', true, index)
      r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      r1 = nil
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  r0 = instantiate_node(SyntaxNode,input, i0...index, s0)

  node_cache[:optional_spaces][start_index] = r0

  r0
end

#_nt_quoted_wordObject



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
# File 'lib/vanilla/snip_reference.rb', line 347

def _nt_quoted_word
  start_index = index
  if node_cache[:quoted_word].has_key?(index)
    cached = node_cache[:quoted_word][index]
    @index = cached.interval.end if cached
    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_unquoted_words
    s1 << r3
    if r3
      if has_terminal?("\"", false, index)
        r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("\"")
        r4 = nil
      end
      s1 << r4
    end
  end
  if s1.last
    r1 = instantiate_node(QuotedWord,input, i1...index, s1)
    r1.extend(QuotedWord0)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r0 = r1
  else
    i5, s5 = index, []
    if has_terminal?("'", false, index)
      r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure("'")
      r6 = nil
    end
    s5 << r6
    if r6
      r7 = _nt_unquoted_words
      s5 << r7
      if r7
        if has_terminal?("'", false, index)
          r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("'")
          r8 = nil
        end
        s5 << r8
      end
    end
    if s5.last
      r5 = instantiate_node(QuotedWord,input, i5...index, s5)
      r5.extend(QuotedWord1)
    else
      @index = i5
      r5 = nil
    end
    if r5
      r0 = r5
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:quoted_word][start_index] = r0

  r0
end

#_nt_snip_callObject



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
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
# File 'lib/vanilla/snip_reference.rb', line 21

def _nt_snip_call
  start_index = index
  if node_cache[:snip_call].has_key?(index)
    cached = node_cache[:snip_call][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0, s0 = index, []
  if has_terminal?("{", false, index)
    r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure("{")
    r1 = nil
  end
  s0 << r1
  if r1
    r2 = _nt_snip_name
    s0 << r2
    if r2
      i4, s4 = index, []
      r5 = _nt_spaces
      s4 << r5
      if r5
        r6 = _nt_argument_list
        s4 << r6
      end
      if s4.last
        r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
        r4.extend(SnipCall0)
      else
        @index = i4
        r4 = nil
      end
      if r4
        r3 = r4
      else
        r3 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r3
      if r3
        if has_terminal?("}", false, index)
          r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("}")
          r7 = nil
        end
        s0 << r7
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SnipCall,input, i0...index, s0)
    r0.extend(SnipCall1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:snip_call][start_index] = r0

  r0
end

#_nt_snip_nameObject



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
# File 'lib/vanilla/snip_reference.rb', line 97

def _nt_snip_name
  start_index = index
  if node_cache[:snip_name].has_key?(index)
    cached = node_cache[:snip_name][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0 = index
  i1, s1 = index, []
  r2 = _nt_word
  s1 << r2
  if r2
    if has_terminal?(".", false, index)
      r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure(".")
      r3 = nil
    end
    s1 << r3
    if r3
      r4 = _nt_word
      s1 << r4
    end
  end
  if s1.last
    r1 = instantiate_node(SnipNameWithAttribute,input, i1...index, s1)
    r1.extend(SnipName0)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r0 = r1
  else
    r5 = _nt_word
    r5.extend(SnipName)
    if r5
      r0 = r5
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:snip_name][start_index] = r0

  r0
end

#_nt_spacesObject



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/vanilla/snip_reference.rb', line 495

def _nt_spaces
  start_index = index
  if node_cache[:spaces].has_key?(index)
    cached = node_cache[:spaces][index]
    @index = cached.interval.end if cached
    return cached
  end

  s0, i0 = [], index
  loop do
    if has_terminal?('\G[ ]', true, index)
      r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      r1 = nil
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  if s0.empty?
    @index = i0
    r0 = nil
  else
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
  end

  node_cache[:spaces][start_index] = r0

  r0
end

#_nt_unquoted_wordObject



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
# File 'lib/vanilla/snip_reference.rb', line 307

def _nt_unquoted_word
  start_index = index
  if node_cache[:unquoted_word].has_key?(index)
    cached = node_cache[:unquoted_word][index]
    @index = cached.interval.end if cached
    return cached
  end

  s0, i0 = [], index
  loop do
    if has_terminal?('\G[a-zA-Z0-9_\\-]', true, index)
      r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      r1 = nil
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  if s0.empty?
    @index = i0
    r0 = nil
  else
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
  end

  node_cache[:unquoted_word][start_index] = r0

  r0
end

#_nt_unquoted_wordsObject



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
# File 'lib/vanilla/snip_reference.rb', line 432

def _nt_unquoted_words
  start_index = index
  if node_cache[:unquoted_words].has_key?(index)
    cached = node_cache[:unquoted_words][index]
    @index = cached.interval.end if cached
    return cached
  end

  s0, i0 = [], index
  loop do
    if has_terminal?('\G[a-zA-Z0-9_\\- ]', true, index)
      r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      r1 = nil
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  if s0.empty?
    @index = i0
    r0 = nil
  else
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
  end

  node_cache[:unquoted_words][start_index] = r0

  r0
end

#_nt_wordObject



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
# File 'lib/vanilla/snip_reference.rb', line 280

def _nt_word
  start_index = index
  if node_cache[:word].has_key?(index)
    cached = node_cache[:word][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0 = index
  r1 = _nt_unquoted_word
  if r1
    r0 = r1
  else
    r2 = _nt_quoted_word
    if r2
      r0 = r2
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:word][start_index] = r0

  r0
end

#rootObject



4
5
6
# File 'lib/vanilla/snip_reference.rb', line 4

def root
  @root || :snip_call
end