fig 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/Changes +94 -0
  2. data/lib/fig.rb +1 -1
  3. data/lib/fig/command.rb +18 -7
  4. data/lib/fig/command/action/dump_package_definition_for_command_line.rb +2 -2
  5. data/lib/fig/command/action/dump_package_definition_parsed.rb +2 -2
  6. data/lib/fig/command/action/dump_package_definition_text.rb +2 -2
  7. data/lib/fig/command/action/source_package.rb +65 -0
  8. data/lib/fig/command/options.rb +64 -15
  9. data/lib/fig/command/options/parser.rb +24 -14
  10. data/lib/fig/command/package_applier.rb +32 -7
  11. data/lib/fig/command/package_loader.rb +16 -7
  12. data/lib/fig/external_program.rb +72 -0
  13. data/lib/fig/figrc.rb +1 -1
  14. data/lib/fig/grammar/v0.rb +2 -2
  15. data/lib/fig/grammar/v0.treetop +2 -2
  16. data/lib/fig/grammar/v1.rb +17 -1737
  17. data/lib/fig/grammar/v1.treetop +6 -217
  18. data/lib/fig/grammar/v1_base.rb +1750 -0
  19. data/lib/fig/grammar/v1_base.treetop +229 -0
  20. data/lib/fig/grammar/v2.rb +508 -0
  21. data/lib/fig/grammar/v2.treetop +65 -0
  22. data/lib/fig/grammar_monkey_patches.rb +7 -0
  23. data/lib/fig/no_such_package_config_error.rb +3 -1
  24. data/lib/fig/not_yet_parsed_package.rb +27 -0
  25. data/lib/fig/operating_system.rb +5 -5
  26. data/lib/fig/package.rb +20 -2
  27. data/lib/fig/package_definition_text_assembler.rb +2 -1
  28. data/lib/fig/package_descriptor.rb +11 -4
  29. data/lib/fig/parser.rb +44 -58
  30. data/lib/fig/parser_package_build_state.rb +39 -4
  31. data/lib/fig/protocol/file.rb +2 -2
  32. data/lib/fig/protocol/ftp.rb +15 -10
  33. data/lib/fig/protocol/http.rb +1 -1
  34. data/lib/fig/protocol/netrc_enabled.rb +29 -16
  35. data/lib/fig/protocol/sftp.rb +19 -12
  36. data/lib/fig/repository.rb +33 -21
  37. data/lib/fig/repository_package_publisher.rb +129 -8
  38. data/lib/fig/runtime_environment.rb +114 -28
  39. data/lib/fig/statement/include.rb +21 -4
  40. data/lib/fig/statement/include_file.rb +94 -0
  41. data/lib/fig/unparser.rb +15 -7
  42. data/lib/fig/unparser/v1.rb +2 -80
  43. data/lib/fig/unparser/v1_base.rb +85 -0
  44. data/lib/fig/unparser/v2.rb +55 -0
  45. data/lib/fig/working_directory_maintainer.rb +12 -0
  46. metadata +61 -51
@@ -71,6 +71,7 @@ class Fig::Command::PackageApplier
71
71
  @base_config,
72
72
  :description => @base_package.description
73
73
  ),
74
+ @base_package,
74
75
  nil
75
76
  )
76
77
  end
@@ -86,7 +87,13 @@ class Fig::Command::PackageApplier
86
87
  )
87
88
 
88
89
  return Fig::Package.new(
89
- nil, nil, 'command-line', '.', [configuration_statement]
90
+ nil, # Name
91
+ nil, # Version
92
+ 'command-line',
93
+ '.', # Working
94
+ '.', # Base
95
+ [configuration_statement],
96
+ :is_synthetic
90
97
  )
91
98
  end
92
99
 
@@ -99,10 +106,23 @@ class Fig::Command::PackageApplier
99
106
  source = derive_exception_source()
100
107
 
101
108
  message = %Q<There's no "#{@base_config}" config#{source}.>
102
- message += %q< Specify one that does like this: ">
103
- message +=
104
- Fig::PackageDescriptor.format(@descriptor.name, @descriptor.version, 'some_existing_config')
105
- message += %q<".>
109
+ config_names = exception.package.config_names
110
+ if config_names.empty?
111
+ message += ' Actually, there are no configs.'
112
+ else
113
+ example_config =
114
+ config_names.size == 1 ? config_names[0] : 'some_existing_config'
115
+ message += %q< Specify one that does like this: ">
116
+ message += Fig::PackageDescriptor.format(
117
+ @descriptor.name, @descriptor.version, example_config,
118
+ )
119
+ message += %q<".>
120
+
121
+ if config_names.size > 1
122
+ message +=
123
+ %Q< The valid configs are "#{config_names.join('", "')}".>
124
+ end
125
+ end
106
126
 
107
127
  raise Fig::UserInputError.new(message)
108
128
  end
@@ -114,7 +134,12 @@ class Fig::Command::PackageApplier
114
134
  source = derive_exception_source()
115
135
  message =
116
136
  %Q<No config was specified and there's no "#{Fig::Package::DEFAULT_CONFIG}" config#{source}.>
117
- config_names = @base_package.config_names()
137
+ append_config_names message, @base_package.config_names()
138
+
139
+ raise Fig::UserInputError.new(message)
140
+ end
141
+
142
+ def append_config_names(message, config_names)
118
143
  if config_names.size > 1
119
144
  message +=
120
145
  %Q< The valid configs are "#{config_names.join('", "')}".>
@@ -124,7 +149,7 @@ class Fig::Command::PackageApplier
124
149
  message += ' Actually, there are no configs.'
125
150
  end
126
151
 
127
- raise Fig::UserInputError.new(message)
152
+ return
128
153
  end
129
154
 
130
155
  def check_no_such_package_exception_is_for_command_line_package(exception)
@@ -1,3 +1,4 @@
1
+ require 'fig/not_yet_parsed_package'
1
2
  require 'fig/package_descriptor'
2
3
  require 'fig/parser'
3
4
 
@@ -79,6 +80,7 @@ class Fig::Command::PackageLoader
79
80
  def read_in_package_definition_file(config_file)
80
81
  if File.exist?(config_file)
81
82
  @package_loaded_from_path = config_file
83
+ @package_base_directory = File.dirname config_file
82
84
 
83
85
  return File.read(config_file)
84
86
  else
@@ -104,12 +106,17 @@ class Fig::Command::PackageLoader
104
106
  :source_description => source_description
105
107
  )
106
108
 
109
+ unparsed_package = Fig::NotYetParsedPackage.new
110
+ unparsed_package.descriptor = descriptor
111
+ unparsed_package.working_directory = '.'
112
+ unparsed_package.base_directory = @package_base_directory || '.'
113
+ unparsed_package.source_description = source_description
114
+ unparsed_package.unparsed_text = definition_text
115
+
107
116
  set_base_package(
108
117
  Fig::Parser.new(
109
118
  @application_configuration, :check_include_versions
110
- ).parse_package(
111
- descriptor, '.', source_description, definition_text
112
- )
119
+ ).parse_package(unparsed_package)
113
120
  )
114
121
 
115
122
  return
@@ -118,10 +125,11 @@ class Fig::Command::PackageLoader
118
125
  def set_base_package_to_empty_synthetic_one()
119
126
  set_base_package(
120
127
  Fig::Package.new(
121
- nil,
122
- nil,
128
+ nil, # Name
129
+ nil, # Version
123
130
  'synthetic',
124
- '.',
131
+ '.', # Working
132
+ '.', # Base
125
133
  [
126
134
  Fig::Statement::Configuration.new(
127
135
  nil,
@@ -129,7 +137,8 @@ class Fig::Command::PackageLoader
129
137
  @base_config,
130
138
  []
131
139
  )
132
- ]
140
+ ],
141
+ :is_synthetic,
133
142
  )
134
143
  )
135
144
 
@@ -0,0 +1,72 @@
1
+ require 'stringio'
2
+
3
+ require 'fig/operating_system'
4
+
5
+ module Fig; end
6
+
7
+ class Fig::ExternalProgram
8
+ def self.set_up_open3
9
+ require 'open3'
10
+ def self.popen(*cmd)
11
+ exit_code = nil
12
+
13
+ Open3.popen3(*cmd) { |stdin, stdout, stderr, wait_thread|
14
+ yield stdin, stdout, stderr
15
+
16
+ exit_code = wait_thread.value
17
+ }
18
+
19
+ return exit_code
20
+ end
21
+ end
22
+
23
+ if Fig::OperatingSystem.windows?
24
+ set_up_open3
25
+ else
26
+ require 'open4'
27
+ def self.popen(*cmd)
28
+ return Open4::popen4(*cmd) { |pid, stdin, stdout, stderr|
29
+ yield stdin, stdout, stderr
30
+ }
31
+ end
32
+ end
33
+
34
+ def self.capture(command_line, input = nil)
35
+ output = nil
36
+ errors = nil
37
+
38
+ result = popen(*command_line) do
39
+ |stdin, stdout, stderr|
40
+
41
+ if ! input.nil?
42
+ stdin.puts input # Potential deadlock if input is bigger than pipe size.
43
+ end
44
+ stdin.close
45
+
46
+ output = StringIO.new
47
+ errors = StringIO.new
48
+ input_to_output = {stdout => output, stderr => errors}
49
+ while ! input_to_output.empty?
50
+ ready, * = IO.select input_to_output.keys
51
+ ready.each do
52
+ |handle|
53
+
54
+ begin
55
+ input_to_output[handle] << handle.readpartial(4096)
56
+ rescue EOFError
57
+ input_to_output.delete handle
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ if ! output.nil?
64
+ output = output.string
65
+ end
66
+ if ! errors.nil?
67
+ errors = errors.string
68
+ end
69
+
70
+ return output, errors, result
71
+ end
72
+ end
data/lib/fig/figrc.rb CHANGED
@@ -87,7 +87,7 @@ class Fig::FigRC
87
87
 
88
88
  repo_config_exists = nil
89
89
  begin
90
- operating_system.download figrc_url, repo_figrc_path
90
+ operating_system.download figrc_url, repo_figrc_path, :prompt_for_login
91
91
  repo_config_exists = true
92
92
  rescue Fig::FileNotFoundError
93
93
  repo_config_exists = false
@@ -49,9 +49,9 @@ module Fig
49
49
  end
50
50
 
51
51
  module Package1
52
- def to_package(directory, build_state)
52
+ def to_package(unparsed_package, build_state)
53
53
  return build_state.new_package_statement(
54
- directory, grammar_version, statements
54
+ unparsed_package, grammar_version, statements
55
55
  )
56
56
  end
57
57
  end
@@ -27,9 +27,9 @@ module Fig
27
27
  statements:(package_statement*)
28
28
  optional_ws
29
29
  {
30
- def to_package(directory, build_state)
30
+ def to_package(unparsed_package, build_state)
31
31
  return build_state.new_package_statement(
32
- directory, grammar_version, statements
32
+ unparsed_package, grammar_version, statements
33
33
  )
34
34
  end
35
35
  }
@@ -4,17 +4,10 @@
4
4
  # Treetop (http://treetop.rubyforge.org/) grammar for package definitions in v1
5
5
  # format.
6
6
 
7
- # Some aspects of this grammar are significantly dumber than they could be
8
- # because:
9
- #
10
- # * We want to treat statements as identically as possible to their
11
- # command-line equivalents.
12
- # * Treetop parse errors are pretty inscrutable at times and we can make
13
- # error messages clearer by validating a lot of the terminals ourselves.
14
-
15
7
  require 'treetop'
16
8
 
17
9
  require 'fig/grammar/base'
10
+ require 'fig/grammar/v1_base'
18
11
  require 'fig/grammar/version'
19
12
 
20
13
  module Fig
@@ -30,6 +23,8 @@ module Fig
30
23
 
31
24
  include Fig::Grammar::Version
32
25
 
26
+ include Fig::Grammar::V1Base
27
+
33
28
  module Package0
34
29
  def optional_ws_or_comment1
35
30
  elements[0]
@@ -49,9 +44,9 @@ module Fig
49
44
  end
50
45
 
51
46
  module Package1
52
- def to_package(directory, build_state)
47
+ def to_package(unparsed_package, build_state)
53
48
  return build_state.new_package_statement(
54
- directory, grammar_version, statements
49
+ unparsed_package, grammar_version, statements
55
50
  )
56
51
  end
57
52
  end
@@ -110,69 +105,10 @@ module Fig
110
105
  r0
111
106
  end
112
107
 
113
- module PackageStatementWithWs0
114
- def package_statement
115
- elements[0]
116
- end
117
-
118
- end
119
-
120
- module PackageStatementWithWs1
121
- def to_package_statement(build_state)
122
- return package_statement.to_package_statement(build_state)
123
- end
124
- end
125
-
126
- def _nt_package_statement_with_ws
127
- start_index = index
128
- if node_cache[:package_statement_with_ws].has_key?(index)
129
- cached = node_cache[:package_statement_with_ws][index]
130
- if cached
131
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
132
- @index = cached.interval.end
133
- end
134
- return cached
135
- end
136
-
137
- i0, s0 = index, []
138
- r1 = _nt_package_statement
139
- s0 << r1
140
- if r1
141
- s2, i2 = [], index
142
- loop do
143
- r3 = _nt_ws_or_comment
144
- if r3
145
- s2 << r3
146
- else
147
- break
148
- end
149
- end
150
- if s2.empty?
151
- @index = i2
152
- r2 = nil
153
- else
154
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
155
- end
156
- s0 << r2
157
- end
158
- if s0.last
159
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
160
- r0.extend(PackageStatementWithWs0)
161
- r0.extend(PackageStatementWithWs1)
162
- else
163
- @index = i0
164
- r0 = nil
165
- end
166
-
167
- node_cache[:package_statement_with_ws][start_index] = r0
168
-
169
- r0
170
- end
171
-
172
- def _nt_package_statement
108
+ def _nt_config_statement
173
109
  start_index = index
174
- if node_cache[:package_statement].has_key?(index)
175
- cached = node_cache[:package_statement][index]
110
+ if node_cache[:config_statement].has_key?(index)
111
+ cached = node_cache[:config_statement][index]
176
112
  if cached
177
113
  cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
178
114
  @index = cached.interval.end
@@ -181,487 +117,28 @@ module Fig
181
117
  end
182
118
 
183
119
  i0 = index
184
- r1 = _nt_archive
120
+ r1 = _nt_override
185
121
  if r1
186
122
  r0 = r1
187
123
  else
188
- r2 = _nt_resource
124
+ r2 = _nt_include
189
125
  if r2
190
126
  r0 = r2
191
127
  else
192
- r3 = _nt_retrieve
128
+ r3 = _nt_command
193
129
  if r3
194
130
  r0 = r3
195
131
  else
196
- r4 = _nt_config
132
+ r4 = _nt_path
197
133
  if r4
198
134
  r0 = r4
199
135
  else
200
- @index = i0
201
- r0 = nil
202
- end
203
- end
204
- end
205
- end
206
-
207
- node_cache[:package_statement][start_index] = r0
208
-
209
- r0
210
- end
211
-
212
- module Archive0
213
- def statement_start
214
- elements[0]
215
- end
216
-
217
- def location
218
- elements[2]
219
- end
220
- end
221
-
222
- module Archive1
223
- def to_package_statement(build_state)
224
- return build_state.new_asset_statement(
225
- Statement::Archive, statement_start, location
226
- )
227
- end
228
- end
229
-
230
- def _nt_archive
231
- start_index = index
232
- if node_cache[:archive].has_key?(index)
233
- cached = node_cache[:archive][index]
234
- if cached
235
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
236
- @index = cached.interval.end
237
- end
238
- return cached
239
- end
240
-
241
- i0, s0 = index, []
242
- if has_terminal?('archive', false, index)
243
- r1 = instantiate_node(SyntaxNode,input, index...(index + 7))
244
- @index += 7
245
- else
246
- terminal_parse_failure('archive')
247
- r1 = nil
248
- end
249
- s0 << r1
250
- if r1
251
- s2, i2 = [], index
252
- loop do
253
- r3 = _nt_ws_or_comment
254
- if r3
255
- s2 << r3
256
- else
257
- break
258
- end
259
- end
260
- if s2.empty?
261
- @index = i2
262
- r2 = nil
263
- else
264
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
265
- end
266
- s0 << r2
267
- if r2
268
- r4 = _nt_quoted_or_bare_string
269
- s0 << r4
270
- end
271
- end
272
- if s0.last
273
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
274
- r0.extend(Archive0)
275
- r0.extend(Archive1)
276
- else
277
- @index = i0
278
- r0 = nil
279
- end
280
-
281
- node_cache[:archive][start_index] = r0
282
-
283
- r0
284
- end
285
-
286
- module Resource0
287
- def statement_start
288
- elements[0]
289
- end
290
-
291
- def location
292
- elements[2]
293
- end
294
- end
295
-
296
- module Resource1
297
- def to_package_statement(build_state)
298
- return build_state.new_asset_statement(
299
- Statement::Resource, statement_start, location
300
- )
301
- end
302
- end
303
-
304
- def _nt_resource
305
- start_index = index
306
- if node_cache[:resource].has_key?(index)
307
- cached = node_cache[:resource][index]
308
- if cached
309
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
310
- @index = cached.interval.end
311
- end
312
- return cached
313
- end
314
-
315
- i0, s0 = index, []
316
- if has_terminal?('resource', false, index)
317
- r1 = instantiate_node(SyntaxNode,input, index...(index + 8))
318
- @index += 8
319
- else
320
- terminal_parse_failure('resource')
321
- r1 = nil
322
- end
323
- s0 << r1
324
- if r1
325
- s2, i2 = [], index
326
- loop do
327
- r3 = _nt_ws_or_comment
328
- if r3
329
- s2 << r3
330
- else
331
- break
332
- end
333
- end
334
- if s2.empty?
335
- @index = i2
336
- r2 = nil
337
- else
338
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
339
- end
340
- s0 << r2
341
- if r2
342
- r4 = _nt_quoted_or_bare_string
343
- s0 << r4
344
- end
345
- end
346
- if s0.last
347
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
348
- r0.extend(Resource0)
349
- r0.extend(Resource1)
350
- else
351
- @index = i0
352
- r0 = nil
353
- end
354
-
355
- node_cache[:resource][start_index] = r0
356
-
357
- r0
358
- end
359
-
360
- module Retrieve0
361
- def statement_start
362
- elements[0]
363
- end
364
-
365
- def variable
366
- elements[2]
367
- end
368
-
369
- def path
370
- elements[4]
371
- end
372
- end
373
-
374
- module Retrieve1
375
- def to_package_statement(build_state)
376
- return build_state.new_retrieve_statement(
377
- statement_start, variable, path
378
- )
379
- end
380
- end
381
-
382
- def _nt_retrieve
383
- start_index = index
384
- if node_cache[:retrieve].has_key?(index)
385
- cached = node_cache[:retrieve][index]
386
- if cached
387
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
388
- @index = cached.interval.end
389
- end
390
- return cached
391
- end
392
-
393
- i0, s0 = index, []
394
- if has_terminal?('retrieve', false, index)
395
- r1 = instantiate_node(SyntaxNode,input, index...(index + 8))
396
- @index += 8
397
- else
398
- terminal_parse_failure('retrieve')
399
- r1 = nil
400
- end
401
- s0 << r1
402
- if r1
403
- s2, i2 = [], index
404
- loop do
405
- r3 = _nt_ws_or_comment
406
- if r3
407
- s2 << r3
408
- else
409
- break
410
- end
411
- end
412
- if s2.empty?
413
- @index = i2
414
- r2 = nil
415
- else
416
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
417
- end
418
- s0 << r2
419
- if r2
420
- r4 = _nt_environment_variable_name
421
- s0 << r4
422
- if r4
423
- if has_terminal?('->', false, index)
424
- r5 = instantiate_node(SyntaxNode,input, index...(index + 2))
425
- @index += 2
426
- else
427
- terminal_parse_failure('->')
428
- r5 = nil
429
- end
430
- s0 << r5
431
- if r5
432
- r6 = _nt_quoted_or_bare_string
433
- s0 << r6
434
- end
435
- end
436
- end
437
- end
438
- if s0.last
439
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
440
- r0.extend(Retrieve0)
441
- r0.extend(Retrieve1)
442
- else
443
- @index = i0
444
- r0 = nil
445
- end
446
-
447
- node_cache[:retrieve][start_index] = r0
448
-
449
- r0
450
- end
451
-
452
- module Config0
453
- def statement_start
454
- elements[0]
455
- end
456
-
457
- def config_name
458
- elements[2]
459
- end
460
-
461
- def statements
462
- elements[4]
463
- end
464
-
465
- end
466
-
467
- module Config1
468
- def to_package_statement(build_state)
469
- return build_state.new_configuration_statement(
470
- statement_start, config_name, statements
471
- )
472
- end
473
- end
474
-
475
- def _nt_config
476
- start_index = index
477
- if node_cache[:config].has_key?(index)
478
- cached = node_cache[:config][index]
479
- if cached
480
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
481
- @index = cached.interval.end
482
- end
483
- return cached
484
- end
485
-
486
- i0, s0 = index, []
487
- if has_terminal?('config', false, index)
488
- r1 = instantiate_node(SyntaxNode,input, index...(index + 6))
489
- @index += 6
490
- else
491
- terminal_parse_failure('config')
492
- r1 = nil
493
- end
494
- s0 << r1
495
- if r1
496
- s2, i2 = [], index
497
- loop do
498
- r3 = _nt_ws_or_comment
499
- if r3
500
- s2 << r3
501
- else
502
- break
503
- end
504
- end
505
- if s2.empty?
506
- @index = i2
507
- r2 = nil
508
- else
509
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
510
- end
511
- s0 << r2
512
- if r2
513
- r4 = _nt_config_name
514
- s0 << r4
515
- if r4
516
- s5, i5 = [], index
517
- loop do
518
- r6 = _nt_ws_or_comment
519
- if r6
520
- s5 << r6
136
+ r5 = _nt_set
137
+ if r5
138
+ r0 = r5
521
139
  else
522
- break
523
- end
524
- end
525
- if s5.empty?
526
- @index = i5
527
- r5 = nil
528
- else
529
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
530
- end
531
- s0 << r5
532
- if r5
533
- s7, i7 = [], index
534
- loop do
535
- r8 = _nt_config_statement_with_ws
536
- if r8
537
- s7 << r8
538
- else
539
- break
540
- end
541
- end
542
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
543
- s0 << r7
544
- if r7
545
- if has_terminal?('end', false, index)
546
- r9 = instantiate_node(SyntaxNode,input, index...(index + 3))
547
- @index += 3
548
- else
549
- terminal_parse_failure('end')
550
- r9 = nil
551
- end
552
- s0 << r9
553
- end
554
- end
555
- end
556
- end
557
- end
558
- if s0.last
559
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
560
- r0.extend(Config0)
561
- r0.extend(Config1)
562
- else
563
- @index = i0
564
- r0 = nil
565
- end
566
-
567
- node_cache[:config][start_index] = r0
568
-
569
- r0
570
- end
571
-
572
- module ConfigStatementWithWs0
573
- def config_statement
574
- elements[0]
575
- end
576
-
577
- end
578
-
579
- module ConfigStatementWithWs1
580
- def to_config_statement(build_state)
581
- return config_statement.to_config_statement(build_state)
582
- end
583
- end
584
-
585
- def _nt_config_statement_with_ws
586
- start_index = index
587
- if node_cache[:config_statement_with_ws].has_key?(index)
588
- cached = node_cache[:config_statement_with_ws][index]
589
- if cached
590
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
591
- @index = cached.interval.end
592
- end
593
- return cached
594
- end
595
-
596
- i0, s0 = index, []
597
- r1 = _nt_config_statement
598
- s0 << r1
599
- if r1
600
- s2, i2 = [], index
601
- loop do
602
- r3 = _nt_ws_or_comment
603
- if r3
604
- s2 << r3
605
- else
606
- break
607
- end
608
- end
609
- if s2.empty?
610
- @index = i2
611
- r2 = nil
612
- else
613
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
614
- end
615
- s0 << r2
616
- end
617
- if s0.last
618
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
619
- r0.extend(ConfigStatementWithWs0)
620
- r0.extend(ConfigStatementWithWs1)
621
- else
622
- @index = i0
623
- r0 = nil
624
- end
625
-
626
- node_cache[:config_statement_with_ws][start_index] = r0
627
-
628
- r0
629
- end
630
-
631
- def _nt_config_statement
632
- start_index = index
633
- if node_cache[:config_statement].has_key?(index)
634
- cached = node_cache[:config_statement][index]
635
- if cached
636
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
637
- @index = cached.interval.end
638
- end
639
- return cached
640
- end
641
-
642
- i0 = index
643
- r1 = _nt_override
644
- if r1
645
- r0 = r1
646
- else
647
- r2 = _nt_include
648
- if r2
649
- r0 = r2
650
- else
651
- r3 = _nt_command
652
- if r3
653
- r0 = r3
654
- else
655
- r4 = _nt_path
656
- if r4
657
- r0 = r4
658
- else
659
- r5 = _nt_set
660
- if r5
661
- r0 = r5
662
- else
663
- @index = i0
664
- r0 = nil
140
+ @index = i0
141
+ r0 = nil
665
142
  end
666
143
  end
667
144
  end
@@ -673,1203 +150,6 @@ module Fig
673
150
  r0
674
151
  end
675
152
 
676
- module Include0
677
- def statement_start
678
- elements[0]
679
- end
680
-
681
- def descriptor_string
682
- elements[2]
683
- end
684
- end
685
-
686
- module Include1
687
- def to_config_statement(build_state)
688
- return build_state.new_include_statement(
689
- statement_start, descriptor_string
690
- )
691
- end
692
- end
693
-
694
- def _nt_include
695
- start_index = index
696
- if node_cache[:include].has_key?(index)
697
- cached = node_cache[:include][index]
698
- if cached
699
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
700
- @index = cached.interval.end
701
- end
702
- return cached
703
- end
704
-
705
- i0, s0 = index, []
706
- if has_terminal?('include', false, index)
707
- r1 = instantiate_node(SyntaxNode,input, index...(index + 7))
708
- @index += 7
709
- else
710
- terminal_parse_failure('include')
711
- r1 = nil
712
- end
713
- s0 << r1
714
- if r1
715
- s2, i2 = [], index
716
- loop do
717
- r3 = _nt_ws_or_comment
718
- if r3
719
- s2 << r3
720
- else
721
- break
722
- end
723
- end
724
- if s2.empty?
725
- @index = i2
726
- r2 = nil
727
- else
728
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
729
- end
730
- s0 << r2
731
- if r2
732
- r4 = _nt_descriptor_string
733
- s0 << r4
734
- end
735
- end
736
- if s0.last
737
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
738
- r0.extend(Include0)
739
- r0.extend(Include1)
740
- else
741
- @index = i0
742
- r0 = nil
743
- end
744
-
745
- node_cache[:include][start_index] = r0
746
-
747
- r0
748
- end
749
-
750
- module Override0
751
- def statement_start
752
- elements[0]
753
- end
754
-
755
- def descriptor_string
756
- elements[2]
757
- end
758
- end
759
-
760
- module Override1
761
- def to_config_statement(build_state)
762
- return build_state.new_override_statement(
763
- statement_start, descriptor_string
764
- )
765
- end
766
- end
767
-
768
- def _nt_override
769
- start_index = index
770
- if node_cache[:override].has_key?(index)
771
- cached = node_cache[:override][index]
772
- if cached
773
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
774
- @index = cached.interval.end
775
- end
776
- return cached
777
- end
778
-
779
- i0, s0 = index, []
780
- if has_terminal?('override', false, index)
781
- r1 = instantiate_node(SyntaxNode,input, index...(index + 8))
782
- @index += 8
783
- else
784
- terminal_parse_failure('override')
785
- r1 = nil
786
- end
787
- s0 << r1
788
- if r1
789
- s2, i2 = [], index
790
- loop do
791
- r3 = _nt_ws_or_comment
792
- if r3
793
- s2 << r3
794
- else
795
- break
796
- end
797
- end
798
- if s2.empty?
799
- @index = i2
800
- r2 = nil
801
- else
802
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
803
- end
804
- s0 << r2
805
- if r2
806
- r4 = _nt_descriptor_string
807
- s0 << r4
808
- end
809
- end
810
- if s0.last
811
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
812
- r0.extend(Override0)
813
- r0.extend(Override1)
814
- else
815
- @index = i0
816
- r0 = nil
817
- end
818
-
819
- node_cache[:override][start_index] = r0
820
-
821
- r0
822
- end
823
-
824
- module Set0
825
- def statement_start
826
- elements[0]
827
- end
828
-
829
- def environment_variable_name_value
830
- elements[2]
831
- end
832
- end
833
-
834
- module Set1
835
- def to_config_statement(build_state)
836
- return build_state.new_environment_variable_statement(
837
- Statement::Set, statement_start, environment_variable_name_value
838
- )
839
- end
840
- end
841
-
842
- def _nt_set
843
- start_index = index
844
- if node_cache[:set].has_key?(index)
845
- cached = node_cache[:set][index]
846
- if cached
847
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
848
- @index = cached.interval.end
849
- end
850
- return cached
851
- end
852
-
853
- i0, s0 = index, []
854
- if has_terminal?('set', false, index)
855
- r1 = instantiate_node(SyntaxNode,input, index...(index + 3))
856
- @index += 3
857
- else
858
- terminal_parse_failure('set')
859
- r1 = nil
860
- end
861
- s0 << r1
862
- if r1
863
- s2, i2 = [], index
864
- loop do
865
- r3 = _nt_ws_or_comment
866
- if r3
867
- s2 << r3
868
- else
869
- break
870
- end
871
- end
872
- if s2.empty?
873
- @index = i2
874
- r2 = nil
875
- else
876
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
877
- end
878
- s0 << r2
879
- if r2
880
- r4 = _nt_environment_variable_name_value
881
- s0 << r4
882
- end
883
- end
884
- if s0.last
885
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
886
- r0.extend(Set0)
887
- r0.extend(Set1)
888
- else
889
- @index = i0
890
- r0 = nil
891
- end
892
-
893
- node_cache[:set][start_index] = r0
894
-
895
- r0
896
- end
897
-
898
- module Path0
899
- def statement_start
900
- elements[0]
901
- end
902
-
903
- def environment_variable_name_value
904
- elements[2]
905
- end
906
- end
907
-
908
- module Path1
909
- def to_config_statement(build_state)
910
- return build_state.new_environment_variable_statement(
911
- Statement::Path, statement_start, environment_variable_name_value
912
- )
913
- end
914
- end
915
-
916
- def _nt_path
917
- start_index = index
918
- if node_cache[:path].has_key?(index)
919
- cached = node_cache[:path][index]
920
- if cached
921
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
922
- @index = cached.interval.end
923
- end
924
- return cached
925
- end
926
-
927
- i0, s0 = index, []
928
- i1 = index
929
- if has_terminal?('add', false, index)
930
- r2 = instantiate_node(SyntaxNode,input, index...(index + 3))
931
- @index += 3
932
- else
933
- terminal_parse_failure('add')
934
- r2 = nil
935
- end
936
- if r2
937
- r1 = r2
938
- else
939
- if has_terminal?('append', false, index)
940
- r3 = instantiate_node(SyntaxNode,input, index...(index + 6))
941
- @index += 6
942
- else
943
- terminal_parse_failure('append')
944
- r3 = nil
945
- end
946
- if r3
947
- r1 = r3
948
- else
949
- if has_terminal?('path', false, index)
950
- r4 = instantiate_node(SyntaxNode,input, index...(index + 4))
951
- @index += 4
952
- else
953
- terminal_parse_failure('path')
954
- r4 = nil
955
- end
956
- if r4
957
- r1 = r4
958
- else
959
- @index = i1
960
- r1 = nil
961
- end
962
- end
963
- end
964
- s0 << r1
965
- if r1
966
- s5, i5 = [], index
967
- loop do
968
- r6 = _nt_ws_or_comment
969
- if r6
970
- s5 << r6
971
- else
972
- break
973
- end
974
- end
975
- if s5.empty?
976
- @index = i5
977
- r5 = nil
978
- else
979
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
980
- end
981
- s0 << r5
982
- if r5
983
- r7 = _nt_environment_variable_name_value
984
- s0 << r7
985
- end
986
- end
987
- if s0.last
988
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
989
- r0.extend(Path0)
990
- r0.extend(Path1)
991
- else
992
- @index = i0
993
- r0 = nil
994
- end
995
-
996
- node_cache[:path][start_index] = r0
997
-
998
- r0
999
- end
1000
-
1001
- module Command0
1002
- def statement_start
1003
- elements[0]
1004
- end
1005
-
1006
- def command_line
1007
- elements[2]
1008
- end
1009
-
1010
- end
1011
-
1012
- module Command1
1013
- def to_config_statement(build_state)
1014
- return build_state.new_v1_command_statement(
1015
- statement_start, gather_command_argument_nodes(command_line)
1016
- )
1017
- end
1018
-
1019
- def gather_command_argument_nodes(node, arguments = [])
1020
- if node.respond_to? 'quoted_or_bare_string?'
1021
- arguments << node
1022
- return arguments
1023
- end
1024
-
1025
- return arguments if not node.elements
1026
-
1027
- node.elements.each do
1028
- |element|
1029
- gather_command_argument_nodes(element, arguments)
1030
- end
1031
-
1032
- return arguments
1033
- end
1034
- end
1035
-
1036
- def _nt_command
1037
- start_index = index
1038
- if node_cache[:command].has_key?(index)
1039
- cached = node_cache[:command][index]
1040
- if cached
1041
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1042
- @index = cached.interval.end
1043
- end
1044
- return cached
1045
- end
1046
-
1047
- i0, s0 = index, []
1048
- if has_terminal?('command', false, index)
1049
- r1 = instantiate_node(SyntaxNode,input, index...(index + 7))
1050
- @index += 7
1051
- else
1052
- terminal_parse_failure('command')
1053
- r1 = nil
1054
- end
1055
- s0 << r1
1056
- if r1
1057
- s2, i2 = [], index
1058
- loop do
1059
- r3 = _nt_ws_or_comment
1060
- if r3
1061
- s2 << r3
1062
- else
1063
- break
1064
- end
1065
- end
1066
- if s2.empty?
1067
- @index = i2
1068
- r2 = nil
1069
- else
1070
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1071
- end
1072
- s0 << r2
1073
- if r2
1074
- r4 = _nt_command_line
1075
- s0 << r4
1076
- if r4
1077
- s5, i5 = [], index
1078
- loop do
1079
- r6 = _nt_ws_or_comment
1080
- if r6
1081
- s5 << r6
1082
- else
1083
- break
1084
- end
1085
- end
1086
- if s5.empty?
1087
- @index = i5
1088
- r5 = nil
1089
- else
1090
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1091
- end
1092
- s0 << r5
1093
- if r5
1094
- if has_terminal?('end', false, index)
1095
- r7 = instantiate_node(SyntaxNode,input, index...(index + 3))
1096
- @index += 3
1097
- else
1098
- terminal_parse_failure('end')
1099
- r7 = nil
1100
- end
1101
- s0 << r7
1102
- end
1103
- end
1104
- end
1105
- end
1106
- if s0.last
1107
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1108
- r0.extend(Command0)
1109
- r0.extend(Command1)
1110
- else
1111
- @index = i0
1112
- r0 = nil
1113
- end
1114
-
1115
- node_cache[:command][start_index] = r0
1116
-
1117
- r0
1118
- end
1119
-
1120
- module CommandLine0
1121
- def quoted_or_bare_string
1122
- elements[1]
1123
- end
1124
-
1125
- end
1126
-
1127
- module CommandLine1
1128
- def quoted_or_bare_string
1129
- elements[0]
1130
- end
1131
-
1132
- end
1133
-
1134
- def _nt_command_line
1135
- start_index = index
1136
- if node_cache[:command_line].has_key?(index)
1137
- cached = node_cache[:command_line][index]
1138
- if cached
1139
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1140
- @index = cached.interval.end
1141
- end
1142
- return cached
1143
- end
1144
-
1145
- i0, s0 = index, []
1146
- r1 = _nt_quoted_or_bare_string
1147
- s0 << r1
1148
- if r1
1149
- i2 = index
1150
- r3 = lambda { |sequence| sequence[-1].text_value == 'end' }.call(s0)
1151
- if r3
1152
- r2 = nil
1153
- else
1154
- @index = i2
1155
- r2 = instantiate_node(SyntaxNode,input, index...index)
1156
- end
1157
- s0 << r2
1158
- if r2
1159
- s4, i4 = [], index
1160
- loop do
1161
- i5, s5 = index, []
1162
- s6, i6 = [], index
1163
- loop do
1164
- r7 = _nt_ws_or_comment
1165
- if r7
1166
- s6 << r7
1167
- else
1168
- break
1169
- end
1170
- end
1171
- if s6.empty?
1172
- @index = i6
1173
- r6 = nil
1174
- else
1175
- r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
1176
- end
1177
- s5 << r6
1178
- if r6
1179
- r8 = _nt_quoted_or_bare_string
1180
- s5 << r8
1181
- if r8
1182
- i9 = index
1183
- r10 = lambda { |sequence| sequence[-1].text_value == 'end' }.call(s5)
1184
- if r10
1185
- r9 = nil
1186
- else
1187
- @index = i9
1188
- r9 = instantiate_node(SyntaxNode,input, index...index)
1189
- end
1190
- s5 << r9
1191
- end
1192
- end
1193
- if s5.last
1194
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1195
- r5.extend(CommandLine0)
1196
- else
1197
- @index = i5
1198
- r5 = nil
1199
- end
1200
- if r5
1201
- s4 << r5
1202
- else
1203
- break
1204
- end
1205
- end
1206
- r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1207
- s0 << r4
1208
- end
1209
- end
1210
- if s0.last
1211
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1212
- r0.extend(CommandLine1)
1213
- else
1214
- @index = i0
1215
- r0 = nil
1216
- end
1217
-
1218
- node_cache[:command_line][start_index] = r0
1219
-
1220
- r0
1221
- end
1222
-
1223
- def _nt_descriptor_string
1224
- start_index = index
1225
- if node_cache[:descriptor_string].has_key?(index)
1226
- cached = node_cache[:descriptor_string][index]
1227
- if cached
1228
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1229
- @index = cached.interval.end
1230
- end
1231
- return cached
1232
- end
1233
-
1234
- s0, i0 = [], index
1235
- loop do
1236
- if has_terminal?('\G[^\\s#]', true, index)
1237
- r1 = true
1238
- @index += 1
1239
- else
1240
- r1 = nil
1241
- end
1242
- if r1
1243
- s0 << r1
1244
- else
1245
- break
1246
- end
1247
- end
1248
- if s0.empty?
1249
- @index = i0
1250
- r0 = nil
1251
- else
1252
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1253
- end
1254
-
1255
- node_cache[:descriptor_string][start_index] = r0
1256
-
1257
- r0
1258
- end
1259
-
1260
- def _nt_config_name
1261
- start_index = index
1262
- if node_cache[:config_name].has_key?(index)
1263
- cached = node_cache[:config_name][index]
1264
- if cached
1265
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1266
- @index = cached.interval.end
1267
- end
1268
- return cached
1269
- end
1270
-
1271
- s0, i0 = [], index
1272
- loop do
1273
- if has_terminal?('\G[a-zA-Z0-9_.-]', true, index)
1274
- r1 = true
1275
- @index += 1
1276
- else
1277
- r1 = nil
1278
- end
1279
- if r1
1280
- s0 << r1
1281
- else
1282
- break
1283
- end
1284
- end
1285
- if s0.empty?
1286
- @index = i0
1287
- r0 = nil
1288
- else
1289
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1290
- end
1291
-
1292
- node_cache[:config_name][start_index] = r0
1293
-
1294
- r0
1295
- end
1296
-
1297
- module QuotedOrBareString0
1298
- end
1299
-
1300
- module QuotedOrBareString1
1301
- end
1302
-
1303
- module QuotedOrBareString2
1304
- def quoted_or_bare_string?() return true end
1305
- end
1306
-
1307
- module QuotedOrBareString3
1308
- end
1309
-
1310
- module QuotedOrBareString4
1311
- end
1312
-
1313
- module QuotedOrBareString5
1314
- def quoted_or_bare_string?() return true end
1315
- end
1316
-
1317
- module QuotedOrBareString6
1318
- def quoted_or_bare_string?() return true end
1319
- end
1320
-
1321
- def _nt_quoted_or_bare_string
1322
- start_index = index
1323
- if node_cache[:quoted_or_bare_string].has_key?(index)
1324
- cached = node_cache[:quoted_or_bare_string][index]
1325
- if cached
1326
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1327
- @index = cached.interval.end
1328
- end
1329
- return cached
1330
- end
1331
-
1332
- i0 = index
1333
- i1, s1 = index, []
1334
- s2, i2 = [], index
1335
- loop do
1336
- if has_terminal?('\G[^\\s#\\\\"]', true, index)
1337
- r3 = true
1338
- @index += 1
1339
- else
1340
- r3 = nil
1341
- end
1342
- if r3
1343
- s2 << r3
1344
- else
1345
- break
1346
- end
1347
- end
1348
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1349
- s1 << r2
1350
- if r2
1351
- if has_terminal?('"', false, index)
1352
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
1353
- @index += 1
1354
- else
1355
- terminal_parse_failure('"')
1356
- r4 = nil
1357
- end
1358
- s1 << r4
1359
- if r4
1360
- s5, i5 = [], index
1361
- loop do
1362
- i6 = index
1363
- if has_terminal?('\G[^"\\\\]', true, index)
1364
- r7 = true
1365
- @index += 1
1366
- else
1367
- r7 = nil
1368
- end
1369
- if r7
1370
- r6 = r7
1371
- else
1372
- i8, s8 = index, []
1373
- if has_terminal?('\\', false, index)
1374
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
1375
- @index += 1
1376
- else
1377
- terminal_parse_failure('\\')
1378
- r9 = nil
1379
- end
1380
- s8 << r9
1381
- if r9
1382
- if index < input_length
1383
- r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
1384
- @index += 1
1385
- else
1386
- terminal_parse_failure("any character")
1387
- r10 = nil
1388
- end
1389
- s8 << r10
1390
- end
1391
- if s8.last
1392
- r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
1393
- r8.extend(QuotedOrBareString0)
1394
- else
1395
- @index = i8
1396
- r8 = nil
1397
- end
1398
- if r8
1399
- r6 = r8
1400
- else
1401
- @index = i6
1402
- r6 = nil
1403
- end
1404
- end
1405
- if r6
1406
- s5 << r6
1407
- else
1408
- break
1409
- end
1410
- end
1411
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1412
- s1 << r5
1413
- if r5
1414
- if has_terminal?('"', false, index)
1415
- r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
1416
- @index += 1
1417
- else
1418
- terminal_parse_failure('"')
1419
- r11 = nil
1420
- end
1421
- s1 << r11
1422
- end
1423
- end
1424
- end
1425
- if s1.last
1426
- r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1427
- r1.extend(QuotedOrBareString1)
1428
- r1.extend(QuotedOrBareString2)
1429
- else
1430
- @index = i1
1431
- r1 = nil
1432
- end
1433
- if r1
1434
- r0 = r1
1435
- else
1436
- i12, s12 = index, []
1437
- s13, i13 = [], index
1438
- loop do
1439
- if has_terminal?('\G[^\\s#\\\\\']', true, index)
1440
- r14 = true
1441
- @index += 1
1442
- else
1443
- r14 = nil
1444
- end
1445
- if r14
1446
- s13 << r14
1447
- else
1448
- break
1449
- end
1450
- end
1451
- r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
1452
- s12 << r13
1453
- if r13
1454
- if has_terminal?("'", false, index)
1455
- r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
1456
- @index += 1
1457
- else
1458
- terminal_parse_failure("'")
1459
- r15 = nil
1460
- end
1461
- s12 << r15
1462
- if r15
1463
- s16, i16 = [], index
1464
- loop do
1465
- i17 = index
1466
- if has_terminal?('\G[^\'\\\\]', true, index)
1467
- r18 = true
1468
- @index += 1
1469
- else
1470
- r18 = nil
1471
- end
1472
- if r18
1473
- r17 = r18
1474
- else
1475
- i19, s19 = index, []
1476
- if has_terminal?('\\', false, index)
1477
- r20 = instantiate_node(SyntaxNode,input, index...(index + 1))
1478
- @index += 1
1479
- else
1480
- terminal_parse_failure('\\')
1481
- r20 = nil
1482
- end
1483
- s19 << r20
1484
- if r20
1485
- if index < input_length
1486
- r21 = instantiate_node(SyntaxNode,input, index...(index + 1))
1487
- @index += 1
1488
- else
1489
- terminal_parse_failure("any character")
1490
- r21 = nil
1491
- end
1492
- s19 << r21
1493
- end
1494
- if s19.last
1495
- r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
1496
- r19.extend(QuotedOrBareString3)
1497
- else
1498
- @index = i19
1499
- r19 = nil
1500
- end
1501
- if r19
1502
- r17 = r19
1503
- else
1504
- @index = i17
1505
- r17 = nil
1506
- end
1507
- end
1508
- if r17
1509
- s16 << r17
1510
- else
1511
- break
1512
- end
1513
- end
1514
- r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
1515
- s12 << r16
1516
- if r16
1517
- if has_terminal?("'", false, index)
1518
- r22 = instantiate_node(SyntaxNode,input, index...(index + 1))
1519
- @index += 1
1520
- else
1521
- terminal_parse_failure("'")
1522
- r22 = nil
1523
- end
1524
- s12 << r22
1525
- end
1526
- end
1527
- end
1528
- if s12.last
1529
- r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
1530
- r12.extend(QuotedOrBareString4)
1531
- r12.extend(QuotedOrBareString5)
1532
- else
1533
- @index = i12
1534
- r12 = nil
1535
- end
1536
- if r12
1537
- r0 = r12
1538
- else
1539
- s23, i23 = [], index
1540
- loop do
1541
- if has_terminal?('\G[^\\s#]', true, index)
1542
- r24 = true
1543
- @index += 1
1544
- else
1545
- r24 = nil
1546
- end
1547
- if r24
1548
- s23 << r24
1549
- else
1550
- break
1551
- end
1552
- end
1553
- if s23.empty?
1554
- @index = i23
1555
- r23 = nil
1556
- else
1557
- r23 = instantiate_node(SyntaxNode,input, i23...index, s23)
1558
- r23.extend(QuotedOrBareString6)
1559
- end
1560
- if r23
1561
- r0 = r23
1562
- else
1563
- @index = i0
1564
- r0 = nil
1565
- end
1566
- end
1567
- end
1568
-
1569
- node_cache[:quoted_or_bare_string][start_index] = r0
1570
-
1571
- r0
1572
- end
1573
-
1574
- def _nt_environment_variable_name
1575
- start_index = index
1576
- if node_cache[:environment_variable_name].has_key?(index)
1577
- cached = node_cache[:environment_variable_name][index]
1578
- if cached
1579
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1580
- @index = cached.interval.end
1581
- end
1582
- return cached
1583
- end
1584
-
1585
- s0, i0 = [], index
1586
- loop do
1587
- if has_terminal?('\G[a-zA-Z0-9_]', true, index)
1588
- r1 = true
1589
- @index += 1
1590
- else
1591
- r1 = nil
1592
- end
1593
- if r1
1594
- s0 << r1
1595
- else
1596
- break
1597
- end
1598
- end
1599
- if s0.empty?
1600
- @index = i0
1601
- r0 = nil
1602
- else
1603
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1604
- end
1605
-
1606
- node_cache[:environment_variable_name][start_index] = r0
1607
-
1608
- r0
1609
- end
1610
-
1611
- module EnvironmentVariableNameValue0
1612
- end
1613
-
1614
- module EnvironmentVariableNameValue1
1615
- end
1616
-
1617
- module EnvironmentVariableNameValue2
1618
- end
1619
-
1620
- module EnvironmentVariableNameValue3
1621
- end
1622
-
1623
- def _nt_environment_variable_name_value
1624
- start_index = index
1625
- if node_cache[:environment_variable_name_value].has_key?(index)
1626
- cached = node_cache[:environment_variable_name_value][index]
1627
- if cached
1628
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1629
- @index = cached.interval.end
1630
- end
1631
- return cached
1632
- end
1633
-
1634
- i0 = index
1635
- i1, s1 = index, []
1636
- s2, i2 = [], index
1637
- loop do
1638
- if has_terminal?('\G[^\\s#\\\\\'"]', true, index)
1639
- r3 = true
1640
- @index += 1
1641
- else
1642
- r3 = nil
1643
- end
1644
- if r3
1645
- s2 << r3
1646
- else
1647
- break
1648
- end
1649
- end
1650
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1651
- s1 << r2
1652
- if r2
1653
- if has_terminal?('"', false, index)
1654
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
1655
- @index += 1
1656
- else
1657
- terminal_parse_failure('"')
1658
- r4 = nil
1659
- end
1660
- s1 << r4
1661
- if r4
1662
- s5, i5 = [], index
1663
- loop do
1664
- i6 = index
1665
- if has_terminal?('\G[^"\\\\]', true, index)
1666
- r7 = true
1667
- @index += 1
1668
- else
1669
- r7 = nil
1670
- end
1671
- if r7
1672
- r6 = r7
1673
- else
1674
- i8, s8 = index, []
1675
- if has_terminal?('\\', false, index)
1676
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
1677
- @index += 1
1678
- else
1679
- terminal_parse_failure('\\')
1680
- r9 = nil
1681
- end
1682
- s8 << r9
1683
- if r9
1684
- if index < input_length
1685
- r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
1686
- @index += 1
1687
- else
1688
- terminal_parse_failure("any character")
1689
- r10 = nil
1690
- end
1691
- s8 << r10
1692
- end
1693
- if s8.last
1694
- r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
1695
- r8.extend(EnvironmentVariableNameValue0)
1696
- else
1697
- @index = i8
1698
- r8 = nil
1699
- end
1700
- if r8
1701
- r6 = r8
1702
- else
1703
- @index = i6
1704
- r6 = nil
1705
- end
1706
- end
1707
- if r6
1708
- s5 << r6
1709
- else
1710
- break
1711
- end
1712
- end
1713
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1714
- s1 << r5
1715
- if r5
1716
- if has_terminal?('"', false, index)
1717
- r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
1718
- @index += 1
1719
- else
1720
- terminal_parse_failure('"')
1721
- r11 = nil
1722
- end
1723
- s1 << r11
1724
- end
1725
- end
1726
- end
1727
- if s1.last
1728
- r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1729
- r1.extend(EnvironmentVariableNameValue1)
1730
- else
1731
- @index = i1
1732
- r1 = nil
1733
- end
1734
- if r1
1735
- r0 = r1
1736
- else
1737
- i12, s12 = index, []
1738
- s13, i13 = [], index
1739
- loop do
1740
- if has_terminal?('\G[^\\s#\\\\\'"]', true, index)
1741
- r14 = true
1742
- @index += 1
1743
- else
1744
- r14 = nil
1745
- end
1746
- if r14
1747
- s13 << r14
1748
- else
1749
- break
1750
- end
1751
- end
1752
- r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
1753
- s12 << r13
1754
- if r13
1755
- if has_terminal?("'", false, index)
1756
- r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
1757
- @index += 1
1758
- else
1759
- terminal_parse_failure("'")
1760
- r15 = nil
1761
- end
1762
- s12 << r15
1763
- if r15
1764
- s16, i16 = [], index
1765
- loop do
1766
- i17 = index
1767
- if has_terminal?('\G[^\'\\\\]', true, index)
1768
- r18 = true
1769
- @index += 1
1770
- else
1771
- r18 = nil
1772
- end
1773
- if r18
1774
- r17 = r18
1775
- else
1776
- i19, s19 = index, []
1777
- if has_terminal?('\\', false, index)
1778
- r20 = instantiate_node(SyntaxNode,input, index...(index + 1))
1779
- @index += 1
1780
- else
1781
- terminal_parse_failure('\\')
1782
- r20 = nil
1783
- end
1784
- s19 << r20
1785
- if r20
1786
- if index < input_length
1787
- r21 = instantiate_node(SyntaxNode,input, index...(index + 1))
1788
- @index += 1
1789
- else
1790
- terminal_parse_failure("any character")
1791
- r21 = nil
1792
- end
1793
- s19 << r21
1794
- end
1795
- if s19.last
1796
- r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
1797
- r19.extend(EnvironmentVariableNameValue2)
1798
- else
1799
- @index = i19
1800
- r19 = nil
1801
- end
1802
- if r19
1803
- r17 = r19
1804
- else
1805
- @index = i17
1806
- r17 = nil
1807
- end
1808
- end
1809
- if r17
1810
- s16 << r17
1811
- else
1812
- break
1813
- end
1814
- end
1815
- r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
1816
- s12 << r16
1817
- if r16
1818
- if has_terminal?("'", false, index)
1819
- r22 = instantiate_node(SyntaxNode,input, index...(index + 1))
1820
- @index += 1
1821
- else
1822
- terminal_parse_failure("'")
1823
- r22 = nil
1824
- end
1825
- s12 << r22
1826
- end
1827
- end
1828
- end
1829
- if s12.last
1830
- r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
1831
- r12.extend(EnvironmentVariableNameValue3)
1832
- else
1833
- @index = i12
1834
- r12 = nil
1835
- end
1836
- if r12
1837
- r0 = r12
1838
- else
1839
- s23, i23 = [], index
1840
- loop do
1841
- if has_terminal?('\G[^\\s#]', true, index)
1842
- r24 = true
1843
- @index += 1
1844
- else
1845
- r24 = nil
1846
- end
1847
- if r24
1848
- s23 << r24
1849
- else
1850
- break
1851
- end
1852
- end
1853
- if s23.empty?
1854
- @index = i23
1855
- r23 = nil
1856
- else
1857
- r23 = instantiate_node(SyntaxNode,input, i23...index, s23)
1858
- end
1859
- if r23
1860
- r0 = r23
1861
- else
1862
- @index = i0
1863
- r0 = nil
1864
- end
1865
- end
1866
- end
1867
-
1868
- node_cache[:environment_variable_name_value][start_index] = r0
1869
-
1870
- r0
1871
- end
1872
-
1873
153
  end
1874
154
 
1875
155
  class V1Parser < Treetop::Runtime::CompiledParser