Module: Fig::Grammar::V2

Includes:
Base, V1Base, Version, Treetop::Runtime
Included in:
V2Parser
Defined in:
lib/fig/grammar/v2.rb

Defined Under Namespace

Modules: FilePath0, FilePath1, FilePath2, FilePath3, IncludeFile0, IncludeFile1, IncludeFile2, Package0, Package1

Instance Method Summary collapse

Methods included from V1Base

#_nt_archive, #_nt_command, #_nt_command_line, #_nt_config, #_nt_config_name, #_nt_config_statement_with_ws, #_nt_descriptor_string, #_nt_environment_variable_name, #_nt_environment_variable_name_value, #_nt_include, #_nt_override, #_nt_package_statement, #_nt_package_statement_with_ws, #_nt_path, #_nt_quoted_or_bare_string, #_nt_resource, #_nt_retrieve, #_nt_set

Methods included from Version

#_nt_grammar_version

Methods included from Base

#_nt_comment, #_nt_optional_ws, #_nt_optional_ws_or_comment, #_nt_ws, #_nt_ws_or_comment

Instance Method Details

#_nt_config_statementObject



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
# File 'lib/fig/grammar/v2.rb', line 110

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

  i0 = index
  r1 = _nt_override
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    r2 = _nt_include
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
    else
      r3 = _nt_include_file
      if r3
        r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
        r0 = r3
      else
        r4 = _nt_command
        if r4
          r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
          r0 = r4
        else
          r5 = _nt_path
          if r5
            r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
            r0 = r5
          else
            r6 = _nt_set
            if r6
              r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
              r0 = r6
            else
              @index = i0
              r0 = nil
            end
          end
        end
      end
    end
  end

  node_cache[:config_statement][start_index] = r0

  r0
end

#_nt_file_pathObject



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
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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'lib/fig/grammar/v2.rb', line 295

def _nt_file_path
  start_index = index
  if node_cache[:file_path].has_key?(index)
    cached = node_cache[:file_path][index]
    if cached
      node_cache[:file_path][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
    s3, i3 = [], index
    loop do
      i4 = index
      if has_terminal?(@regexps[gr = '\A[^"\\\\]'] ||= Regexp.new(gr), :regexp, index)
        r5 = true
        @index += 1
      else
        terminal_parse_failure('[^"\\\\]')
        r5 = nil
      end
      if r5
        r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
        r4 = r5
      else
        i6, s6 = index, []
        if (match_len = has_terminal?('\\', false, index))
          r7 = true
          @index += match_len
        else
          terminal_parse_failure('\\')
          r7 = nil
        end
        s6 << r7
        if r7
          if index < input_length
            r8 = true
            @index += 1
          else
            terminal_parse_failure("any character")
            r8 = nil
          end
          s6 << r8
        end
        if s6.last
          r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          r6.extend(FilePath0)
        else
          @index = i6
          r6 = nil
        end
        if r6
          r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
          r4 = r6
        else
          @index = i4
          r4 = nil
        end
      end
      if r4
        s3 << r4
      else
        break
      end
    end
    r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
    s1 << r3
    if r3
      if (match_len = has_terminal?('"', false, index))
        r9 = true
        @index += match_len
      else
        terminal_parse_failure('"')
        r9 = nil
      end
      s1 << r9
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(FilePath1)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  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
      s12, i12 = [], index
      loop do
        i13 = index
        if has_terminal?(@regexps[gr = '\A[^\'\\\\]'] ||= Regexp.new(gr), :regexp, index)
          r14 = true
          @index += 1
        else
          terminal_parse_failure('[^\'\\\\]')
          r14 = nil
        end
        if r14
          r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
          r13 = r14
        else
          i15, s15 = index, []
          if (match_len = has_terminal?('\\', false, index))
            r16 = true
            @index += match_len
          else
            terminal_parse_failure('\\')
            r16 = nil
          end
          s15 << r16
          if r16
            if index < input_length
              r17 = true
              @index += 1
            else
              terminal_parse_failure("any character")
              r17 = nil
            end
            s15 << r17
          end
          if s15.last
            r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
            r15.extend(FilePath2)
          else
            @index = i15
            r15 = nil
          end
          if r15
            r15 = SyntaxNode.new(input, (index-1)...index) if r15 == true
            r13 = r15
          else
            @index = i13
            r13 = nil
          end
        end
        if r13
          s12 << r13
        else
          break
        end
      end
      r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
      s10 << r12
      if r12
        if (match_len = has_terminal?("'", false, index))
          r18 = true
          @index += match_len
        else
          terminal_parse_failure("'")
          r18 = nil
        end
        s10 << r18
      end
    end
    if s10.last
      r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
      r10.extend(FilePath3)
    else
      @index = i10
      r10 = nil
    end
    if r10
      r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
      r0 = r10
    else
      s19, i19 = [], index
      loop do
        if has_terminal?(@regexps[gr = '\A[^\\s#:]'] ||= Regexp.new(gr), :regexp, index)
          r20 = true
          @index += 1
        else
          terminal_parse_failure('[^\\s#:]')
          r20 = nil
        end
        if r20
          s19 << r20
        else
          break
        end
      end
      if s19.empty?
        @index = i19
        r19 = nil
      else
        r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
      end
      if r19
        r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true
        r0 = r19
      else
        @index = i0
        r0 = nil
      end
    end
  end

  node_cache[:file_path][start_index] = r0

  r0
end

#_nt_include_fileObject



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
# File 'lib/fig/grammar/v2.rb', line 199

def _nt_include_file
  start_index = index
  if node_cache[:include_file].has_key?(index)
    cached = node_cache[:include_file][index]
    if cached
      node_cache[:include_file][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?('include-file', false, index))
    r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
    @index += match_len
  else
    terminal_parse_failure('include-file')
    r1 = nil
  end
  s0 << r1
  if r1
    s2, i2 = [], index
    loop do
      r3 = _nt_ws_or_comment
      if r3
        s2 << r3
      else
        break
      end
    end
    if s2.empty?
      @index = i2
      r2 = nil
    else
      r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
    end
    s0 << r2
    if r2
      r4 = _nt_file_path
      s0 << r4
      if r4
        i6, s6 = index, []
        if (match_len = has_terminal?(':', false, index))
          r7 = true
          @index += match_len
        else
          terminal_parse_failure(':')
          r7 = nil
        end
        s6 << r7
        if r7
          r8 = _nt_config_name
          s6 << r8
        end
        if s6.last
          r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          r6.extend(IncludeFile0)
        else
          @index = i6
          r6 = nil
        end
        if r6
          r5 = r6
        else
          r5 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r5
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(IncludeFile1)
    r0.extend(IncludeFile2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:include_file][start_index] = r0

  r0
end

#_nt_packageObject



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
108
# File 'lib/fig/grammar/v2.rb', line 56

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

  i0, s0 = index, []
  r1 = _nt_optional_ws_or_comment
  s0 << r1
  if r1
    r3 = _nt_grammar_version
    if r3
      r2 = r3
    else
      r2 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r2
    if r2
      s4, i4 = [], index
      loop do
        r5 = _nt_package_statement_with_ws
        if r5
          s4 << r5
        else
          break
        end
      end
      r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
      s0 << r4
      if r4
        r6 = _nt_optional_ws_or_comment
        s0 << r6
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Package0)
    r0.extend(Package1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:package][start_index] = r0

  r0
end

#rootObject



20
21
22
# File 'lib/fig/grammar/v2.rb', line 20

def root
  @root ||= :package
end