bolt 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bolt might be problematic. Click here for more details.

Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/exe/bolt +1 -1
  3. data/lib/bolt.rb +0 -3
  4. data/lib/bolt/cli.rb +66 -32
  5. data/lib/bolt/config.rb +19 -0
  6. data/lib/bolt/executor.rb +21 -16
  7. data/lib/bolt/node.rb +13 -10
  8. data/lib/bolt/node/errors.rb +22 -0
  9. data/lib/bolt/node/ssh.rb +25 -2
  10. data/lib/bolt/node/winrm.rb +14 -2
  11. data/lib/bolt/node_uri.rb +15 -14
  12. data/lib/bolt/result.rb +22 -0
  13. data/lib/bolt/version.rb +1 -1
  14. data/vendored/puppet/lib/puppet/application/script.rb +7 -1
  15. data/vendored/puppet/lib/puppet/configurer.rb +1 -1
  16. data/vendored/puppet/lib/puppet/defaults.rb +18 -1
  17. data/vendored/puppet/lib/puppet/functions/run_command.rb +5 -2
  18. data/vendored/puppet/lib/puppet/functions/run_script.rb +5 -2
  19. data/vendored/puppet/lib/puppet/functions/run_task.rb +7 -2
  20. data/vendored/puppet/lib/puppet/gettext/config.rb +47 -26
  21. data/vendored/puppet/lib/puppet/graph/relationship_graph.rb +6 -0
  22. data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +19 -3
  23. data/vendored/puppet/lib/puppet/module.rb +8 -7
  24. data/vendored/puppet/lib/puppet/network/http/webrick.rb +1 -0
  25. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +9 -0
  26. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +8 -0
  27. data/vendored/puppet/lib/puppet/pops/types/p_error_type.rb +12 -0
  28. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +9 -3
  29. data/vendored/puppet/lib/puppet/pops/types/ruby_generator.rb +65 -24
  30. data/vendored/puppet/lib/puppet/provider/mount.rb +25 -8
  31. data/vendored/puppet/lib/puppet/provider/package/dnf.rb +1 -1
  32. data/vendored/puppet/lib/puppet/provider/package/gem.rb +1 -1
  33. data/vendored/puppet/lib/puppet/provider/package/pkg.rb +3 -0
  34. data/vendored/puppet/lib/puppet/provider/service/launchd.rb +1 -1
  35. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +20 -1
  36. data/vendored/puppet/lib/puppet/type/mount.rb +6 -2
  37. data/vendored/puppet/lib/puppet/type/yumrepo.rb +9 -0
  38. data/vendored/puppet/lib/puppet/version.rb +1 -1
  39. data/vendored/puppet/lib/puppet_pal.rb +33 -7
  40. metadata +45 -83
  41. data/.gitignore +0 -33
  42. data/.gitmodules +0 -12
  43. data/.rspec +0 -2
  44. data/.rubocop.yml +0 -61
  45. data/.travis.yml +0 -18
  46. data/CODE_OF_CONDUCT.md +0 -46
  47. data/CONTRIBUTING.md +0 -27
  48. data/Gemfile +0 -9
  49. data/INSTALL.md +0 -70
  50. data/LICENSE +0 -201
  51. data/README.md +0 -353
  52. data/Rakefile +0 -27
  53. data/Vagrantfile +0 -13
  54. data/appveyor.yml +0 -29
  55. data/bolt.gemspec +0 -50
  56. data/docs/writing_tasks_and_plans.pdf +0 -0
  57. data/metadata.json +0 -13
  58. data/tasks/init.json +0 -3
  59. data/tasks/init.rb +0 -44
  60. data/ux/bolt-CLI-spec.md +0 -186
  61. data/vendored/puppet/lib/puppet/external/nagios/grammar.ry +0 -248
  62. data/vendored/puppet/lib/puppet/external/nagios/makefile +0 -9
  63. data/vendored/puppet/lib/puppet/face/help/action.erb +0 -86
  64. data/vendored/puppet/lib/puppet/face/help/face.erb +0 -114
  65. data/vendored/puppet/lib/puppet/face/help/global.erb +0 -16
  66. data/vendored/puppet/lib/puppet/face/help/man.erb +0 -152
  67. data/vendored/puppet/lib/puppet/generate/templates/type/pcore.erb +0 -42
  68. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.fixtures.yml.erb +0 -7
  69. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.gitignore +0 -18
  70. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.rubocop.yml +0 -42
  71. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.yardopts +0 -1
  72. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +0 -18
  73. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +0 -89
  74. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +0 -32
  75. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/examples/init.pp.erb +0 -12
  76. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +0 -48
  77. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +0 -1
  78. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +0 -6
  79. data/vendored/puppet/lib/puppet/pops/model/ast.pp +0 -695
  80. data/vendored/puppet/lib/puppet/pops/parser/egrammar.ra +0 -937
  81. data/vendored/puppet/lib/puppet/pops/resource/resource_type_set.pcore +0 -22
  82. data/vendored/puppet/lib/puppet/util/libuser.conf +0 -15
  83. data/vendored/puppet/lib/puppet/vendor/deep_merge/CHANGELOG +0 -45
  84. data/vendored/puppet/lib/puppet/vendor/deep_merge/Gemfile +0 -3
  85. data/vendored/puppet/lib/puppet/vendor/deep_merge/LICENSE +0 -21
  86. data/vendored/puppet/lib/puppet/vendor/deep_merge/PUPPET_README.md +0 -6
  87. data/vendored/puppet/lib/puppet/vendor/deep_merge/README.md +0 -113
  88. data/vendored/puppet/lib/puppet/vendor/deep_merge/Rakefile +0 -19
  89. data/vendored/puppet/lib/puppet/vendor/deep_merge/deep_merge.gemspec +0 -35
  90. data/vendored/puppet/lib/puppet/vendor/pathspec/CHANGELOG.md +0 -2
  91. data/vendored/puppet/lib/puppet/vendor/pathspec/LICENSE +0 -201
  92. data/vendored/puppet/lib/puppet/vendor/pathspec/PUPPET_README.md +0 -6
  93. data/vendored/puppet/lib/puppet/vendor/pathspec/README.md +0 -53
  94. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/locales/config.yaml +0 -21
@@ -1,937 +0,0 @@
1
- # vim: syntax=ruby
2
-
3
- # Parser using the Pops model, expression based
4
-
5
- class Puppet::Pops::Parser::Parser
6
-
7
- token STRING DQPRE DQMID DQPOST
8
- token WORD
9
- token LBRACK RBRACK LBRACE RBRACE SYMBOL FARROW COMMA TRUE
10
- token FALSE EQUALS APPENDS DELETES LESSEQUAL NOTEQUAL DOT COLON LLCOLLECT RRCOLLECT
11
- token QMARK WSLPAREN LPAREN RPAREN ISEQUAL GREATEREQUAL GREATERTHAN LESSTHAN
12
- token IF ELSE
13
- token DEFINE ELSIF VARIABLE CLASS INHERITS NODE BOOLEAN
14
- token NAME SEMIC CASE DEFAULT AT ATAT LCOLLECT RCOLLECT CLASSREF
15
- token NOT OR AND UNDEF PARROW PLUS MINUS TIMES DIV LSHIFT RSHIFT UMINUS
16
- token MATCH NOMATCH REGEX IN_EDGE OUT_EDGE IN_EDGE_SUB OUT_EDGE_SUB
17
- token IN UNLESS PIPE
18
- token LAMBDA SELBRACE
19
- token NUMBER
20
- token HEREDOC SUBLOCATE
21
- token RENDER_STRING RENDER_EXPR EPP_START EPP_END EPP_END_TRIM
22
- token FUNCTION
23
- token TYPE
24
- token PRIVATE ATTR
25
- token APPLICATION PRODUCES CONSUMES SITE
26
- token PLAN
27
- token PLAN_R
28
- token LOW
29
-
30
- prechigh
31
- left HIGH
32
- left SEMIC
33
- left PIPE
34
- left LPAREN WSLPAREN
35
- left RPAREN
36
- left DOT
37
- nonassoc EPP_START
38
- left LBRACK LISTSTART
39
- left RBRACK
40
- left QMARK
41
- left LCOLLECT LLCOLLECT
42
- right NOT
43
- nonassoc SPLAT
44
- nonassoc UMINUS
45
- left IN
46
- left MATCH NOMATCH
47
- left TIMES DIV MODULO
48
- left MINUS PLUS
49
- left LSHIFT RSHIFT
50
- left NOTEQUAL ISEQUAL
51
- left GREATEREQUAL GREATERTHAN LESSTHAN LESSEQUAL
52
- left AND
53
- left OR
54
- left LBRACE
55
- left SELBRACE
56
- left RBRACE
57
- right AT ATAT
58
- right APPENDS DELETES EQUALS
59
- left IN_EDGE OUT_EDGE IN_EDGE_SUB OUT_EDGE_SUB
60
- left FARROW
61
- left COMMA
62
- nonassoc RENDER_EXPR
63
- nonassoc RENDER_STRING
64
- left LOW
65
- preclow
66
-
67
- rule
68
- # Produces [Model::Program] with a body containing what was parsed
69
- program
70
- : statements { result = create_program(Factory.block_or_expression(val[0])) }
71
- | epp_expression { result = create_program(val[0]) }
72
- | { result = create_empty_program }
73
-
74
- # Produces a semantic model (non validated, but semantically adjusted).
75
- statements
76
- : syntactic_statements { result = transform_calls(val[0]) }
77
-
78
- # Collects sequence of elements into a list that the statements rule can transform
79
- # (Needed because language supports function calls without parentheses around arguments).
80
- # Produces Array<Model::Expression>
81
- #
82
- syntactic_statements
83
- : syntactic_statement { result = [val[0]]}
84
- | syntactic_statements SEMIC syntactic_statement { result = val[0].push val[2] }
85
- | syntactic_statements syntactic_statement { result = val[0].push val[1] }
86
-
87
- # Produce a single expression or Array of expression
88
- # This exists to handle multiple arguments to non parenthesized function call. If e is expression,
89
- # the a program can consists of e [e,e,e] where the first may be a name of a function to call.
90
- #
91
- syntactic_statement
92
- : assignment =LOW { result = val[0] }
93
- | syntactic_statement COMMA assignment =LOW { result = aryfy(val[0]).push(val[1]).push(val[2]) }
94
-
95
- # Assignment (is right recursive since assignment is right associative)
96
- assignment
97
- : relationship =LOW
98
- | relationship EQUALS assignment { result = val[0].set(val[2]) ; loc result, val[1] }
99
- | relationship APPENDS assignment { result = val[0].plus_set(val[2]) ; loc result, val[1] }
100
- | relationship DELETES assignment { result = val[0].minus_set(val[2]); loc result, val[1] }
101
-
102
- # Argument is like assignment but permits KEY_ENTRY which it converts it to a HASH_UNFOLDED
103
- argument
104
- : assignment
105
- | hashpair { result = Factory.HASH_UNFOLDED([val[0]]); loc result, val[0] }
106
-
107
- # Repeated adjacent HASH_UNFOLDED entries merged into one HASH_UNFOLDED
108
- arguments
109
- : argument { result = [val[0]] }
110
- | arguments COMMA argument { result = Factory.ARGUMENTS(val[0], val[2]) }
111
-
112
- relationship
113
- : resource =LOW
114
- | relationship IN_EDGE resource { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] }
115
- | relationship IN_EDGE_SUB resource { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] }
116
- | relationship OUT_EDGE resource { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] }
117
- | relationship OUT_EDGE_SUB resource { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] }
118
-
119
- #-- RESOURCE
120
- #
121
- resource
122
- : expression = LOW
123
-
124
- #---VIRTUAL
125
- | AT resource {
126
- result = val[1]
127
- unless Factory.set_resource_form(result, 'virtual')
128
- # This is equivalent to a syntax error - additional semantic restrictions apply
129
- error val[0], "Virtual (@) can only be applied to a Resource Expression"
130
- end
131
- # relocate the result
132
- loc result, val[0], val[1]
133
- }
134
-
135
- #---EXPORTED
136
- | ATAT resource {
137
- result = val[1]
138
- unless Factory.set_resource_form(result, 'exported')
139
- # This is equivalent to a syntax error - additional semantic restrictions apply
140
- error val[0], "Exported (@@) can only be applied to a Resource Expression"
141
- end
142
- # relocate the result
143
- loc result, val[0], val[1]
144
- }
145
-
146
- #---RESOURCE TITLED 3x and 4x
147
- | resource LBRACE expression COLON attribute_operations additional_resource_bodies RBRACE {
148
- bodies = [Factory.RESOURCE_BODY(val[2], val[4])] + val[5]
149
- result = Factory.RESOURCE(val[0], bodies)
150
- loc result, val[0], val[6]
151
- }
152
-
153
- #---CLASS RESOURCE
154
- | CLASS LBRACE resource_bodies endsemi RBRACE {
155
- result = Factory.RESOURCE(Factory.fqn(token_text(val[0])), val[2])
156
- loc result, val[0], val[4]
157
- }
158
-
159
- # --RESOURCE 3X Expression
160
- # Handles both 3x overrides and defaults (i.e. single resource_body without title colon)
161
- # Slated for possible deprecation since it requires transformation and mix static/evaluation check
162
- #
163
- | resource LBRACE attribute_operations endcomma RBRACE {
164
- result = case Factory.resource_shape(val[0])
165
- when :resource, :class
166
- # This catches deprecated syntax.
167
- # If the attribute operations does not include +>, then the found expression
168
- # is actually a LEFT followed by LITERAL_HASH
169
- #
170
- unless tmp = transform_resource_wo_title(val[0], val[2], val[1], val[4])
171
- error val[1], "Syntax error resource body without title or hash with +>"
172
- end
173
- tmp
174
- when :defaults
175
- Factory.RESOURCE_DEFAULTS(val[0], val[2])
176
- when :override
177
- # This was only done for override in original - TODO should it be here at all
178
- Factory.RESOURCE_OVERRIDE(val[0], val[2])
179
- else
180
- error val[0], "Expression is not valid as a resource, resource-default, or resource-override"
181
- end
182
- loc result, val[0], val[4]
183
- }
184
-
185
- resource_body
186
- : expression COLON attribute_operations endcomma { result = Factory.RESOURCE_BODY(val[0], val[2]) }
187
-
188
- resource_bodies
189
- : resource_body =HIGH { result = [val[0]] }
190
- | resource_bodies SEMIC resource_body =HIGH { result = val[0].push val[2] }
191
-
192
- # This is a rule for the intermediate state where RACC has seen enough tokens to understand that
193
- # what is expressed is a Resource Expression, it now has to get to the finishing line
194
- #
195
- additional_resource_bodies
196
- : endcomma { result = [] }
197
- | endcomma SEMIC { result = [] }
198
- | endcomma SEMIC resource_bodies endsemi { result = val[2] }
199
-
200
- #-- EXPRESSION
201
- #
202
- expression
203
- : primary_expression
204
- | capability_mapping
205
- | call_function_expression
206
- | bracketed_expression
207
- | expression IN expression { result = val[0].in val[2] ; loc result, val[1] }
208
- | expression MATCH expression { result = val[0] =~ val[2] ; loc result, val[1] }
209
- | expression NOMATCH expression { result = val[0].mne val[2] ; loc result, val[1] }
210
- | expression PLUS expression { result = val[0] + val[2] ; loc result, val[1] }
211
- | expression MINUS expression { result = val[0] - val[2] ; loc result, val[1] }
212
- | expression DIV expression { result = val[0] / val[2] ; loc result, val[1] }
213
- | expression TIMES expression { result = val[0] * val[2] ; loc result, val[1] }
214
- | expression MODULO expression { result = val[0] % val[2] ; loc result, val[1] }
215
- | expression LSHIFT expression { result = val[0] << val[2] ; loc result, val[1] }
216
- | expression RSHIFT expression { result = val[0] >> val[2] ; loc result, val[1] }
217
- | MINUS expression =UMINUS { result = val[1].minus ; loc result, val[0] }
218
- | TIMES expression =SPLAT { result = val[1].unfold ; loc result, val[0] }
219
- | expression NOTEQUAL expression { result = val[0].ne val[2] ; loc result, val[1] }
220
- | expression ISEQUAL expression { result = val[0].eq val[2] ; loc result, val[1] }
221
- | expression GREATERTHAN expression { result = val[0] > val[2] ; loc result, val[1] }
222
- | expression GREATEREQUAL expression { result = val[0] >= val[2] ; loc result, val[1] }
223
- | expression LESSTHAN expression { result = val[0] < val[2] ; loc result, val[1] }
224
- | expression LESSEQUAL expression { result = val[0] <= val[2] ; loc result, val[1] }
225
- | NOT expression { result = val[1].not ; loc result, val[0] }
226
- | expression AND expression { result = val[0].and val[2] ; loc result, val[1] }
227
- | expression OR expression { result = val[0].or val[2] ; loc result, val[1] }
228
- | expression QMARK selector_entries { result = val[0].select(*val[2]) ; loc result, val[0] }
229
- | LPAREN assignment RPAREN { result = val[1].paren ; loc result, val[0] }
230
- | WSLPAREN assignment RPAREN { result = val[1].paren ; loc result, val[0] }
231
-
232
- bracketed_expression
233
- : expression LBRACK access_args endcomma RBRACK =LBRACK { result = val[0].access(val[2]); loc result, val[0], val[4] }
234
-
235
- access_args
236
- : access_arg { result = [val[0]] }
237
- | access_args COMMA access_arg { result = Factory.ARGUMENTS(val[0], val[2]) }
238
-
239
- access_arg
240
- : expression
241
- | hashpair { result = Factory.HASH_UNFOLDED([val[0]]); loc result, val[0] }
242
-
243
- #---EXPRESSIONS
244
- # (i.e. "argument list")
245
- #
246
- # This expression list can not contain function calls without parentheses around arguments
247
- # Produces Array<Model::Expression>
248
- #
249
- expressions
250
- : expression { result = [val[0]] }
251
- | expressions COMMA expression { result = val[0].push(val[2]) }
252
-
253
- primary_expression
254
- : variable
255
- | call_method_with_lambda_expression
256
- | collection_expression
257
- | case_expression
258
- | if_expression
259
- | unless_expression
260
- | definition_expression
261
- | application_expression
262
- | hostclass_expression
263
- | plan_expression
264
- | node_definition_expression
265
- | site_definition_expression
266
- | epp_render_expression
267
- | function_definition
268
- | type_alias
269
- | type_definition
270
- | reserved_word
271
- | array
272
- | hash
273
- | regex
274
- | quotedtext
275
- | type
276
- | NUMBER { result = Factory.NUMBER(val[0][:value]) ; loc result, val[0] }
277
- | BOOLEAN { result = Factory.literal(val[0][:value]) ; loc result, val[0] }
278
- | DEFAULT { result = Factory.literal(:default) ; loc result, val[0] }
279
- | UNDEF { result = Factory.literal(:undef) ; loc result, val[0] }
280
- | NAME { result = Factory.QNAME_OR_NUMBER(val[0][:value]) ; loc result, val[0] }
281
-
282
-
283
- #---CALL FUNCTION
284
- #
285
- # Produces Model::CallNamedFunction
286
-
287
- call_function_expression
288
- : call_function_start arguments endcomma RPAREN {
289
- result = Factory.CALL_NAMED(val[0], true, val[1])
290
- loc result, val[0], val[3]
291
- }
292
- | call_function_start RPAREN {
293
- result = Factory.CALL_NAMED(val[0], true, [])
294
- loc result, val[0], val[1]
295
- }
296
- | call_function_start arguments endcomma RPAREN lambda {
297
- result = Factory.CALL_NAMED(val[0], true, val[1])
298
- loc result, val[0], val[4]
299
- result.lambda = val[4]
300
- }
301
- | call_function_start RPAREN lambda {
302
- result = Factory.CALL_NAMED(val[0], true, [])
303
- loc result, val[0], val[2]
304
- result.lambda = val[2]
305
- }
306
-
307
- call_function_start
308
- : expression LPAREN { result = val[0] }
309
- | TYPE LPAREN { result = Factory.QNAME(val[0][:value]); loc result, val[0] }
310
-
311
- #---CALL METHOD
312
- #
313
- call_method_with_lambda_expression
314
- : call_method_expression =LOW { result = val[0] }
315
- | call_method_expression lambda { result = val[0]; val[0].lambda = val[1] }
316
-
317
- call_method_expression
318
- : named_access LPAREN arguments RPAREN { result = Factory.CALL_METHOD(val[0], val[2]); loc result, val[1], val[3] }
319
- | named_access LPAREN RPAREN { result = Factory.CALL_METHOD(val[0], []); loc result, val[1], val[3] }
320
- | named_access =LOW { result = Factory.CALL_METHOD(val[0], []); loc result, val[0] }
321
-
322
- named_access
323
- : expression DOT NAME {
324
- result = val[0].dot(Factory.fqn(val[2][:value]))
325
- loc result, val[1], val[2]
326
- }
327
- | expression DOT TYPE {
328
- result = val[0].dot(Factory.fqn(val[2][:value]))
329
- loc result, val[1], val[2]
330
- }
331
-
332
- #---LAMBDA
333
- #
334
- lambda
335
- : lambda_parameter_list opt_return_type lambda_rest {
336
- result = Factory.LAMBDA(val[0][:value], val[2][:value], val[1])
337
- loc result, val[0][:start], val[2][:end]
338
- }
339
-
340
- lambda_rest
341
- : LBRACE statements RBRACE { result = {:end => val[2], :value =>val[1] } }
342
- | LBRACE RBRACE { result = {:end => val[1], :value => nil } }
343
-
344
-
345
- lambda_parameter_list
346
- : PIPE PIPE { result = {:start => val[0], :value => [] } }
347
- | PIPE parameters endcomma PIPE { result = {:start => val[0], :value => val[1] } }
348
-
349
- #---CONDITIONALS
350
-
351
- #--IF
352
- #
353
- if_expression
354
- : IF if_part {
355
- result = val[1]
356
- loc(result, val[0], val[1])
357
- }
358
-
359
- # Produces Model::IfExpression
360
- if_part
361
- : expression LBRACE statements RBRACE else {
362
- result = Factory.IF(val[0], Factory.block_or_expression(val[2], val[1], val[3]), val[4])
363
- loc(result, val[0], (val[4] ? val[4] : val[3]))
364
- }
365
- | expression LBRACE RBRACE else {
366
- result = Factory.IF(val[0], nil, val[3])
367
- loc(result, val[0], (val[3] ? val[3] : val[2]))
368
- }
369
-
370
- # Produces [Model::Expression, nil] - nil if there is no else or elsif part
371
- else
372
- : # nothing
373
- | ELSIF if_part {
374
- result = val[1]
375
- loc(result, val[0], val[1])
376
- }
377
- | ELSE LBRACE statements RBRACE {
378
- result = Factory.block_or_expression(val[2], val[1], val[3])
379
- }
380
- | ELSE LBRACE RBRACE {
381
- result = nil # don't think a nop is needed here either
382
- }
383
-
384
- #--UNLESS
385
- #
386
- unless_expression
387
- : UNLESS expression LBRACE statements RBRACE unless_else {
388
- result = Factory.UNLESS(val[1], Factory.block_or_expression(val[3], val[2], val[4]), val[5])
389
- loc result, val[0], val[4]
390
- }
391
- | UNLESS expression LBRACE RBRACE unless_else {
392
- result = Factory.UNLESS(val[1], nil, val[4])
393
- loc result, val[0], val[4]
394
- }
395
-
396
- # Different from else part of if, since "elsif" is not supported, but 'else' is
397
- #
398
- # Produces [Model::Expression, nil] - nil if there is no else or elsif part
399
- unless_else
400
- : # nothing
401
- | ELSE LBRACE statements RBRACE {
402
- result = Factory.block_or_expression(val[2], val[1], val[3])
403
- }
404
- | ELSE LBRACE RBRACE {
405
- result = nil # don't think a nop is needed here either
406
- }
407
-
408
- #--- CASE EXPRESSION
409
- #
410
- case_expression
411
- : CASE expression LBRACE case_options RBRACE {
412
- result = Factory.CASE(val[1], *val[3])
413
- loc result, val[0], val[4]
414
- }
415
-
416
- # Produces Array<Model::CaseOption>
417
- case_options
418
- : case_option { result = [val[0]] }
419
- | case_options case_option { result = val[0].push val[1] }
420
-
421
- # Produced Model::CaseOption (aka When)
422
- case_option
423
- : expressions COLON LBRACE options_statements RBRACE {
424
- result = Factory.WHEN(val[0], val[3]); loc result, val[1], val[4]
425
- }
426
-
427
- options_statements
428
- : nil
429
- | statements
430
-
431
- # This special construct is required or racc will produce the wrong result when the selector entry
432
- # LHS is generalized to any expression (LBRACE looks like a hash). Thus it is not possible to write
433
- # a selector with a single entry where the entry LHS is a hash.
434
- # The SELBRACE token is a LBRACE that follows a QMARK, and this is produced by the lexer with a lookback
435
- # Produces Array<Model::SelectorEntry>
436
- #
437
- selector_entries
438
- : selector_entry
439
- | SELBRACE selector_entry_list endcomma RBRACE {
440
- result = val[1]
441
- }
442
-
443
- # Produces Array<Model::SelectorEntry>
444
- selector_entry_list
445
- : selector_entry { result = [val[0]] }
446
- | selector_entry_list COMMA selector_entry { result = val[0].push val[2] }
447
-
448
- # Produces a Model::SelectorEntry
449
- # This FARROW wins over FARROW in Hash
450
- selector_entry
451
- : expression FARROW expression { result = Factory.MAP(val[0], val[2]) ; loc result, val[1] }
452
-
453
- #---COLLECTION
454
- #
455
- # A Collection is a predicate applied to a set of objects with an implied context (used variables are
456
- # attributes of the object.
457
- # i.e. this is equivalent to source.select(QUERY).apply(ATTRIBUTE_OPERATIONS)
458
- #
459
- collection_expression
460
- : expression collect_query LBRACE attribute_operations endcomma RBRACE {
461
- result = Factory.COLLECT(val[0], val[1], val[3])
462
- loc result, val[0], val[5]
463
- }
464
- | expression collect_query =LOW {
465
- result = Factory.COLLECT(val[0], val[1], [])
466
- loc result, val[0], val[1]
467
- }
468
-
469
- collect_query
470
- : LCOLLECT optional_query RCOLLECT { result = Factory.VIRTUAL_QUERY(val[1]) ; loc result, val[0], val[2] }
471
- | LLCOLLECT optional_query RRCOLLECT { result = Factory.EXPORTED_QUERY(val[1]) ; loc result, val[0], val[2] }
472
-
473
- optional_query
474
- : nil
475
- | expression
476
-
477
- #---ATTRIBUTE OPERATIONS (Not an expression)
478
- #
479
- attribute_operations
480
- : { result = [] }
481
- | attribute_operation { result = [val[0]] }
482
- | attribute_operations COMMA attribute_operation { result = val[0].push(val[2]) }
483
-
484
- # Produces String
485
- # QUESTION: Why is BOOLEAN valid as an attribute name?
486
- #
487
- attribute_name
488
- : NAME
489
- | keyword
490
- | PLAN_R
491
-
492
- # In this version, illegal combinations are validated instead of producing syntax errors
493
- # (Can give nicer error message "+> is not applicable to...")
494
- # Produces Model::AttributeOperation
495
- #
496
- attribute_operation
497
- : attribute_name FARROW expression {
498
- result = Factory.ATTRIBUTE_OP(val[0][:value], '=>', val[2])
499
- loc result, val[0], val[2]
500
- }
501
- | attribute_name PARROW expression {
502
- result = Factory.ATTRIBUTE_OP(val[0][:value], '+>', val[2])
503
- loc result, val[0], val[2]
504
- }
505
- | TIMES FARROW expression {
506
- result = Factory.ATTRIBUTES_OP(val[2]) ; loc result, val[0], val[2]
507
- }
508
-
509
- #---DEFINE
510
- #
511
- # Produces Model::Definition
512
- #
513
- definition_expression
514
- : DEFINE classname parameter_list LBRACE opt_statements RBRACE {
515
- definition = Factory.DEFINITION(classname(val[1][:value]), val[2], val[4])
516
- loc(definition, val[0], val[5])
517
- result = add_definition(definition)
518
- # New lexer does not keep track of this, this is done in validation
519
- if @lexer.respond_to?(:'indefine=')
520
- @lexer.indefine = false
521
- end
522
- }
523
-
524
- #---APPLICATION
525
- application_expression
526
- : APPLICATION classname parameter_list LBRACE opt_statements RBRACE {
527
- definition = Factory.APPLICATION(classname(val[1][:value]), val[2], val[4])
528
- loc(definition, val[0], val[5])
529
- result = add_definition(definition)
530
- }
531
-
532
- capability_mapping
533
- : classname capability_kw classname LBRACE attribute_operations endcomma RBRACE {
534
- result = Factory.CAPABILITY_MAPPING(val[1][:value],
535
- Factory.QNAME(classname(val[0][:value])),
536
- classname(val[2][:value]), val[4])
537
- loc result, val[0], val[6]
538
- add_mapping(result)
539
- }
540
- | bracketed_expression capability_kw classname LBRACE attribute_operations endcomma RBRACE {
541
- result = Factory.CAPABILITY_MAPPING(val[1][:value],
542
- val[0],
543
- classname(val[2][:value]), val[4])
544
- loc result, val[0], val[6]
545
- add_mapping(result)
546
- }
547
-
548
- capability_kw
549
- : PRODUCES
550
- | CONSUMES
551
-
552
- #--PLAN
553
- plan_expression
554
- : PLAN stacked_classname parameter_list LBRACE opt_statements RBRACE {
555
- # Remove this plan's name from the namestack as all nested plans have been parsed
556
- namepop
557
- definition = Factory.PLAN(classname(val[1][:value]), val[2], val[4])
558
- loc(definition, val[0], val[5])
559
- result = add_definition(definition)
560
- }
561
-
562
- #---HOSTCLASS
563
- #
564
- # Produces Model::HostClassDefinition
565
- #
566
- hostclass_expression
567
- : CLASS stacked_classname parameter_list classparent LBRACE opt_statements RBRACE {
568
- # Remove this class' name from the namestack as all nested classes have been parsed
569
- namepop
570
- definition = Factory.HOSTCLASS(classname(val[1][:value]), val[2], token_text(val[3]), val[5])
571
- loc(definition, val[0], val[6])
572
- result = add_definition(definition)
573
- }
574
-
575
- # Record the classname so nested classes gets a fully qualified name at parse-time
576
- # This is a separate rule since racc does not support intermediate actions.
577
- #
578
- stacked_classname
579
- : classname { namestack(val[0][:value]) ; result = val[0] }
580
-
581
- opt_statements
582
- : statements
583
- | nil
584
-
585
- # Produces String, name or nil result
586
- classparent
587
- : nil
588
- | INHERITS classnameordefault { result = val[1] }
589
-
590
- # Produces String (this construct allows a class to be named "default" and to be referenced as
591
- # the parent class.
592
- # TODO: Investigate the validity
593
- # Produces a String (classname), or a token (DEFAULT).
594
- #
595
- classnameordefault
596
- : classname
597
- | DEFAULT
598
-
599
- #---SITE
600
- #
601
- # Produces Model::SiteDefinition
602
- #
603
- site_definition_expression
604
- : SITE LBRACE statements RBRACE {
605
- definition = Factory.SITE(val[2])
606
- loc(definition, val[0], val[3])
607
- result = add_definition(definition)
608
- }
609
- | SITE LBRACE RBRACE {
610
- definition = Factory.SITE(nil)
611
- loc(definition, val[0], val[2])
612
- result = add_definition(definition)
613
- }
614
-
615
- #---NODE
616
- #
617
- # Produces Model::NodeDefinition
618
- #
619
- node_definition_expression
620
- : NODE hostnames endcomma nodeparent LBRACE statements RBRACE {
621
- definition = Factory.NODE(val[1], val[3], val[5])
622
- loc(definition, val[0], val[6])
623
- result = add_definition(definition)
624
- }
625
- | NODE hostnames endcomma nodeparent LBRACE RBRACE {
626
- definition = Factory.NODE(val[1], val[3], nil)
627
- loc(definition, val[0], val[5])
628
- result = add_definition(definition)
629
- }
630
-
631
- # Hostnames is not a list of names, it is a list of name matchers (including a Regexp).
632
- # (The old implementation had a special "Hostname" object with some minimal validation)
633
- #
634
- # Produces Array<Model::LiteralExpression>
635
- #
636
- hostnames
637
- : hostname { result = [result] }
638
- | hostnames COMMA hostname { result = val[0].push(val[2]) }
639
-
640
- # Produces a LiteralExpression (string, :default, or regexp)
641
- # String with interpolation is validated for better error message
642
- hostname
643
- : dotted_name
644
- | quotedtext
645
- | DEFAULT { result = Factory.literal(:default); loc result, val[0] }
646
- | regex
647
-
648
- dotted_name
649
- : name_or_number { result = Factory.literal(val[0][:value]); loc result, val[0] }
650
- | dotted_name DOT name_or_number { result = Factory.concat(val[0], '.', val[2][:value]); loc result, val[0], val[2] }
651
-
652
- name_or_number
653
- : NAME
654
- | NUMBER
655
-
656
- # Produces Expression, since hostname is an Expression
657
- nodeparent
658
- : nil
659
- | INHERITS hostname { result = val[1] }
660
-
661
- #---FUNCTION DEFINITION
662
- #
663
- function_definition
664
- : FUNCTION classname parameter_list opt_return_type LBRACE opt_statements RBRACE {
665
- definition = Factory.FUNCTION(val[1][:value], val[2], val[5], val[3])
666
- loc(definition, val[0], val[6])
667
- result = add_definition(definition)
668
- }
669
-
670
- opt_return_type
671
- : RSHIFT type { result = val[1] }
672
- | RSHIFT type LBRACK access_args RBRACK { result = val[1].access(val[3]) ; loc result, val[1], val[4] }
673
- | nil
674
-
675
- #---NAMES AND PARAMETERS COMMON TO SEVERAL RULES
676
- # Produces String
677
- # TODO: The error that "class" is not a valid classname is bad - classname rule is also used for other things
678
- classname
679
- : NAME
680
- | WORD
681
- | CLASSREF
682
- | PLAN_R
683
- | CLASS { error val[0], "'class' keyword not allowed at this location" }
684
- | STRING { error val[0], "A quoted string is not valid as a name here" }
685
-
686
- # Produces Array<Model::Parameter>
687
- parameter_list
688
- : nil { result = [] }
689
- | LPAREN RPAREN { result = [] }
690
- | WSLPAREN RPAREN { result = [] }
691
- | LPAREN parameters endcomma RPAREN { result = val[1] }
692
- | WSLPAREN parameters endcomma RPAREN { result = val[1] }
693
-
694
- # Produces Array<Model::Parameter>
695
- parameters
696
- : parameter { result = [val[0]] }
697
- | parameters COMMA parameter { result = val[0].push(val[2]) }
698
-
699
- # Produces Model::Parameter
700
- parameter
701
- : untyped_parameter
702
- | typed_parameter
703
-
704
- untyped_parameter
705
- : regular_parameter
706
- | splat_parameter
707
-
708
- regular_parameter
709
- : VARIABLE EQUALS expression { result = Factory.PARAM(val[0][:value], val[2]) ; loc result, val[0] }
710
- | VARIABLE { result = Factory.PARAM(val[0][:value]); loc result, val[0] }
711
-
712
- splat_parameter
713
- : TIMES regular_parameter { result = val[1]; val[1].captures_rest }
714
-
715
- typed_parameter
716
- : parameter_type untyped_parameter { val[1].type_expr(val[0]) ; result = val[1] }
717
-
718
- parameter_type
719
- : type { result = val[0] }
720
- | type LBRACK access_args RBRACK { result = val[0].access(val[2]) ; loc result, val[0], val[3] }
721
-
722
- #--TYPE ALIAS
723
- type_alias
724
- : type_alias_lhs EQUALS type hash {
725
- definition = Factory.TYPE_ASSIGNMENT(val[0], Factory.KEY_ENTRY(val[2], val[3]))
726
- loc(definition, val[0], val[3])
727
- result = add_definition(definition)
728
- }
729
- | type_alias_lhs EQUALS type LBRACK access_args endcomma RBRACK {
730
- definition = Factory.TYPE_ASSIGNMENT(val[0], val[2].access(val[4]))
731
- loc(definition, val[0], val[5])
732
- result = add_definition(definition)
733
- }
734
- | type_alias_lhs EQUALS type {
735
- definition = Factory.TYPE_ASSIGNMENT(val[0], val[2])
736
- loc(definition, val[0], val[2])
737
- result = add_definition(definition)
738
- }
739
- | type_alias_lhs EQUALS hash {
740
- definition = Factory.TYPE_ASSIGNMENT(val[0], val[2])
741
- loc(definition, val[0], val[2])
742
- result = add_definition(definition)
743
- }
744
- | type_alias_lhs EQUALS array {
745
- definition = Factory.TYPE_ASSIGNMENT(val[0], val[2])
746
- loc(definition, val[0], val[4])
747
- result = add_definition(definition)
748
- }
749
-
750
- type_alias_lhs
751
- : TYPE parameter_type { result = val[1] }
752
-
753
- #--TYPE definition
754
- # TODO: Uses the optional_statements rule temporarily since the actual body awaits final spec on methods and attributes.
755
- type_definition
756
- : TYPE CLASSREF LBRACE optional_statements RBRACE {
757
- definition = Factory.TYPE_DEFINITION(val[1][:value], nil, val[3])
758
- loc(definition, val[0], val[4])
759
- result = add_definition(definition)
760
- }
761
- | TYPE CLASSREF INHERITS CLASSREF LBRACE optional_statements RBRACE {
762
- definition = Factory.TYPE_DEFINITION(val[1][:value], val[3][:value], val[5])
763
- loc(definition, val[0], val[6])
764
- result = add_definition(definition)
765
- }
766
-
767
- #--VARIABLE
768
- #
769
- variable
770
- : VARIABLE {
771
- fqn = Factory.fqn(val[0][:value])
772
- loc(fqn, val[0])
773
- fqn['offset'] += 1
774
- fqn['length'] -= 1
775
- result = fqn.var
776
- loc(result, val[0])
777
- }
778
-
779
- #---RESERVED WORDS
780
- #
781
- reserved_word
782
- : PRIVATE { result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] }
783
- | ATTR { result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] }
784
- | PLAN_R { result = Factory.RESERVED(val[0][:value], true) ; loc result, val[0] }
785
-
786
-
787
- #---LITERALS (dynamic and static)
788
- #
789
-
790
- array
791
- : LISTSTART collection_entries endcomma RBRACK { result = Factory.LIST(val[1]); loc result, val[0], val[3] }
792
- | LISTSTART RBRACK { result = Factory.literal([]) ; loc result, val[0], val[1] }
793
- | LBRACK collection_entries endcomma RBRACK { result = Factory.LIST(val[1]); loc result, val[0], val[3] }
794
- | LBRACK RBRACK { result = Factory.literal([]) ; loc result, val[0], val[1] }
795
-
796
- hash
797
- : LBRACE hashpairs RBRACE { result = Factory.HASH(val[1]); loc result, val[0], val[2] }
798
- | LBRACE hashpairs COMMA RBRACE { result = Factory.HASH(val[1]); loc result, val[0], val[3] }
799
- | LBRACE RBRACE { result = Factory.literal({}) ; loc result, val[0], val[1] }
800
-
801
- hashpairs
802
- : hashpair { result = [val[0]] }
803
- | hashpairs COMMA hashpair { result = val[0].push val[2] }
804
-
805
- hashpair
806
- : hash_entry FARROW hash_entry { result = Factory.KEY_ENTRY(val[0], val[2]); loc result, val[1] }
807
-
808
- collection_entry:
809
- : argument
810
- | collection_entry_keyword { result = Factory.literal(val[0][:value]) ; loc result, val[0] }
811
-
812
- # Like collection_entry but will not allow nested hashpair
813
- hash_entry:
814
- : assignment
815
- | collection_entry_keyword { result = Factory.literal(val[0][:value]) ; loc result, val[0] }
816
-
817
- collection_entries
818
- : collection_entry { result = [val[0]] }
819
- | collection_entries COMMA collection_entry { result = Factory.ARGUMENTS(val[0], val[2]) }
820
-
821
- # Keywords valid as a collection value
822
- collection_entry_keyword
823
- : TYPE
824
- | FUNCTION
825
- | APPLICATION
826
- | CONSUMES
827
- | PRODUCES
828
- | SITE
829
-
830
- quotedtext
831
- : string
832
- | dq_string
833
- | heredoc
834
-
835
- string
836
- : STRING { result = Factory.literal(val[0][:value]) ; loc result, val[0] }
837
- | WORD { result = Factory.literal(val[0][:value]) ; loc result, val[0] }
838
-
839
- dq_string : dqpre dqrval { result = Factory.STRING(val[0], *val[1]) ; loc result, val[0], val[1][-1] }
840
- dqpre : DQPRE { result = Factory.literal(val[0][:value]); loc result, val[0] }
841
- dqpost : DQPOST { result = Factory.literal(val[0][:value]); loc result, val[0] }
842
- dqmid : DQMID { result = Factory.literal(val[0][:value]); loc result, val[0] }
843
- dqrval : text_expression dqtail { result = [val[0]] + val[1] }
844
- text_expression : assignment { result = Factory.TEXT(val[0]) }
845
-
846
- dqtail
847
- : dqpost { result = [val[0]] }
848
- | dqmid dqrval { result = [val[0]] + val[1] }
849
-
850
- heredoc
851
- : HEREDOC sublocated_text { result = Factory.HEREDOC(val[0][:value], val[1]); loc result, val[0] }
852
-
853
- sublocated_text
854
- : SUBLOCATE string { result = Factory.SUBLOCATE(val[0], val[1]); loc result, val[0] }
855
- | SUBLOCATE dq_string { result = Factory.SUBLOCATE(val[0], val[1]); loc result, val[0] }
856
-
857
- epp_expression
858
- : EPP_START epp_parameters_list optional_statements { result = Factory.EPP(val[1], val[2]); loc result, val[0] }
859
-
860
- optional_statements
861
- :
862
- | statements
863
-
864
- epp_parameters_list
865
- : =LOW{ result = nil }
866
- | PIPE PIPE { result = [] }
867
- | PIPE parameters endcomma PIPE { result = val[1] }
868
-
869
- epp_render_expression
870
- : RENDER_STRING { result = Factory.RENDER_STRING(val[0][:value]); loc result, val[0] }
871
- | RENDER_EXPR expression epp_end { result = Factory.RENDER_EXPR(val[1]); loc result, val[0], val[2] }
872
- | RENDER_EXPR LBRACE statements RBRACE epp_end { result = Factory.RENDER_EXPR(Factory.block_or_expression(val[2], val[1], val[3])); loc result, val[0], val[4] }
873
-
874
- epp_end
875
- : EPP_END
876
- | EPP_END_TRIM
877
-
878
- type : CLASSREF { result = Factory.QREF(val[0][:value]) ; loc result, val[0] }
879
-
880
- regex
881
- : REGEX { result = Factory.literal(val[0][:value]); loc result, val[0] }
882
-
883
- #---MARKERS, SPECIAL TOKENS, SYNTACTIC SUGAR, etc.
884
-
885
- endcomma
886
- : #
887
- | COMMA { result = nil }
888
-
889
- endsemi
890
- : #
891
- | SEMIC
892
-
893
- keyword
894
- : AND
895
- | CASE
896
- | CLASS
897
- | DEFAULT
898
- | DEFINE
899
- | ELSE
900
- | ELSIF
901
- | IF
902
- | IN
903
- | INHERITS
904
- | NODE
905
- | OR
906
- | UNDEF
907
- | UNLESS
908
- | TYPE
909
- | ATTR
910
- | FUNCTION
911
- | PRIVATE
912
- | APPLICATION
913
- | CONSUMES
914
- | PRODUCES
915
- | SITE
916
-
917
- nil
918
- : { result = nil}
919
-
920
- end
921
-
922
- ---- header ----
923
- require 'puppet'
924
- require 'puppet/pops'
925
-
926
- module Puppet
927
- class ParseError < Puppet::Error; end
928
- class ImportError < Racc::ParseError; end
929
- class AlreadyImportedError < ImportError; end
930
- end
931
-
932
- ---- inner ----
933
-
934
- # Make emacs happy
935
- # Local Variables:
936
- # mode: ruby
937
- # End: