racc 1.4.14-java → 1.4.15-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Manifest.txt +50 -0
- data/ext/racc/com/headius/racc/Cparse.java +66 -23
- data/ext/racc/cparse.c +1 -1
- data/ext/racc/depend +1 -1
- data/lib/racc/cparse-jruby.jar +0 -0
- data/lib/racc/info.rb +2 -2
- data/test/assets/bibtex.y +141 -0
- data/test/assets/cadenza.y +170 -0
- data/test/assets/cast.y +926 -0
- data/test/assets/csspool.y +729 -0
- data/test/assets/edtf.y +583 -0
- data/test/assets/huia.y +318 -0
- data/test/assets/journey.y +47 -0
- data/test/assets/liquor.y +313 -0
- data/test/assets/machete.y +423 -0
- data/test/assets/macruby.y +2197 -0
- data/test/assets/mediacloth.y +599 -0
- data/test/assets/mof.y +649 -0
- data/test/assets/namae.y +302 -0
- data/test/assets/nasl.y +626 -0
- data/test/assets/nokogiri-css.y +255 -0
- data/test/assets/opal.y +1807 -0
- data/test/assets/php_serialization.y +98 -0
- data/test/assets/rdblockparser.y +576 -0
- data/test/assets/rdinlineparser.y +561 -0
- data/test/assets/riml.y +665 -0
- data/test/assets/ruby18.y +1943 -0
- data/test/assets/ruby19.y +2174 -0
- data/test/assets/ruby20.y +2350 -0
- data/test/assets/ruby21.y +2359 -0
- data/test/assets/ruby22.y +2381 -0
- data/test/assets/tp_plus.y +622 -0
- data/test/assets/twowaysql.y +278 -0
- data/test/helper.rb +50 -34
- data/test/regress/bibtex +474 -0
- data/test/regress/cadenza +796 -0
- data/test/regress/cast +3425 -0
- data/test/regress/csspool +2318 -0
- data/test/regress/edtf +1794 -0
- data/test/regress/huia +1392 -0
- data/test/regress/journey +222 -0
- data/test/regress/liquor +885 -0
- data/test/regress/machete +833 -0
- data/test/regress/mediacloth +1463 -0
- data/test/regress/mof +1368 -0
- data/test/regress/namae +634 -0
- data/test/regress/nasl +2058 -0
- data/test/regress/nokogiri-css +836 -0
- data/test/regress/opal +6429 -0
- data/test/regress/php_serialization +336 -0
- data/test/regress/rdblockparser +1061 -0
- data/test/regress/rdinlineparser +1243 -0
- data/test/regress/riml +3297 -0
- data/test/regress/ruby18 +6351 -0
- data/test/regress/ruby22 +7456 -0
- data/test/regress/tp_plus +1933 -0
- data/test/regress/twowaysql +556 -0
- data/test/test_racc_command.rb +177 -0
- metadata +80 -25
- data/.gemtest +0 -0
data/test/assets/mof.y
ADDED
@@ -0,0 +1,649 @@
|
|
1
|
+
# Distributed under the Ruby license
|
2
|
+
# See http://www.ruby-lang.org/en/LICENSE.txt for the full license text
|
3
|
+
# Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
|
4
|
+
|
5
|
+
/*
|
6
|
+
* According to appendix A of
|
7
|
+
* http://www.dmtf.org/standards/cim/cim_spec_v22
|
8
|
+
*/
|
9
|
+
|
10
|
+
class MOF::Parser
|
11
|
+
prechigh
|
12
|
+
/* nonassoc UMINUS */
|
13
|
+
left '*' '/'
|
14
|
+
left '+' '-'
|
15
|
+
preclow
|
16
|
+
|
17
|
+
token PRAGMA INCLUDE IDENTIFIER CLASS ASSOCIATION INDICATION
|
18
|
+
AMENDED ENABLEOVERRIDE DISABLEOVERRIDE RESTRICTED TOSUBCLASS TOINSTANCE
|
19
|
+
TRANSLATABLE QUALIFIER SCOPE SCHEMA PROPERTY REFERENCE
|
20
|
+
METHOD PARAMETER FLAVOR INSTANCE
|
21
|
+
AS REF ANY OF
|
22
|
+
DT_VOID
|
23
|
+
DT_UINT8 DT_SINT8 DT_UINT16 DT_SINT16 DT_UINT32 DT_SINT32
|
24
|
+
DT_UINT64 DT_SINT64 DT_REAL32 DT_REAL64 DT_CHAR16 DT_STR
|
25
|
+
DT_BOOLEAN DT_DATETIME
|
26
|
+
positiveDecimalValue
|
27
|
+
stringValue
|
28
|
+
realValue
|
29
|
+
charValue
|
30
|
+
booleanValue
|
31
|
+
nullValue
|
32
|
+
binaryValue
|
33
|
+
octalValue
|
34
|
+
decimalValue
|
35
|
+
hexValue
|
36
|
+
|
37
|
+
rule
|
38
|
+
|
39
|
+
/* Returns a Hash of filename and MofResult */
|
40
|
+
mofSpecification
|
41
|
+
: /* empty */
|
42
|
+
{ result = Hash.new }
|
43
|
+
| mofProduction
|
44
|
+
{ result = { @name => @result } }
|
45
|
+
| mofSpecification mofProduction
|
46
|
+
{ result = val[0]
|
47
|
+
result[@name] = @result
|
48
|
+
}
|
49
|
+
;
|
50
|
+
|
51
|
+
mofProduction
|
52
|
+
: compilerDirective
|
53
|
+
| classDeclaration
|
54
|
+
{ #puts "Class '#{val[0].name}'"
|
55
|
+
@result.classes << val[0]
|
56
|
+
}
|
57
|
+
| qualifierDeclaration
|
58
|
+
{ @result.qualifiers << val[0]
|
59
|
+
@qualifiers[val[0].name.downcase] = val[0]
|
60
|
+
}
|
61
|
+
| instanceDeclaration
|
62
|
+
{ @result.instances << val[0] }
|
63
|
+
;
|
64
|
+
|
65
|
+
/***
|
66
|
+
* compilerDirective
|
67
|
+
*
|
68
|
+
*/
|
69
|
+
|
70
|
+
compilerDirective
|
71
|
+
: "#" PRAGMA INCLUDE pragmaParameters_opt
|
72
|
+
{ raise MOF::Helper::Error.new(@name,@lineno,@line,"Missing filename after '#pragma include'") unless val[3]
|
73
|
+
open val[3], :pragma
|
74
|
+
}
|
75
|
+
| "#" PRAGMA pragmaName pragmaParameters_opt
|
76
|
+
| "#" INCLUDE pragmaParameters_opt
|
77
|
+
{ raise StyleError.new(@name,@lineno,@line,"Use '#pragma include' instead of '#include'") unless @style == :wmi
|
78
|
+
raise MOF::Helper::Error.new(@name,@lineno,@line,"Missing filename after '#include'") unless val[2]
|
79
|
+
open val[2], :pragma
|
80
|
+
}
|
81
|
+
;
|
82
|
+
|
83
|
+
pragmaName
|
84
|
+
: IDENTIFIER
|
85
|
+
;
|
86
|
+
|
87
|
+
pragmaParameters_opt
|
88
|
+
: /* empty */
|
89
|
+
{ raise StyleError.new(@name,@lineno,@line,"#pragma parameter missing") unless @style == :wmi }
|
90
|
+
| "(" pragmaParameterValues ")"
|
91
|
+
{ result = val[1] }
|
92
|
+
;
|
93
|
+
|
94
|
+
pragmaParameterValues
|
95
|
+
: pragmaParameterValue
|
96
|
+
| pragmaParameterValues "," pragmaParameterValue
|
97
|
+
;
|
98
|
+
|
99
|
+
pragmaParameterValue
|
100
|
+
: string
|
101
|
+
| integerValue
|
102
|
+
{ raise StyleError.new(@name,@lineno,@line,"#pragma parameter missing") unless @style == :wmi }
|
103
|
+
| IDENTIFIER
|
104
|
+
;
|
105
|
+
|
106
|
+
/***
|
107
|
+
* classDeclaration
|
108
|
+
*
|
109
|
+
*/
|
110
|
+
|
111
|
+
classDeclaration
|
112
|
+
: qualifierList_opt CLASS className alias_opt superClass_opt "{" classFeatures "}" ";"
|
113
|
+
{ qualifiers = val[0]
|
114
|
+
features = val[6]
|
115
|
+
# FIXME: features must not include references
|
116
|
+
result = CIM::Class.new(val[2],qualifiers,val[3],val[4],features)
|
117
|
+
}
|
118
|
+
;
|
119
|
+
|
120
|
+
classFeatures
|
121
|
+
: /* empty */
|
122
|
+
{ result = [] }
|
123
|
+
| classFeatures classFeature
|
124
|
+
{ result = val[0] << val[1] }
|
125
|
+
;
|
126
|
+
|
127
|
+
classFeature
|
128
|
+
: propertyDeclaration
|
129
|
+
| methodDeclaration
|
130
|
+
| referenceDeclaration /* must have association qualifier */
|
131
|
+
;
|
132
|
+
|
133
|
+
|
134
|
+
qualifierList_opt
|
135
|
+
: /* empty */
|
136
|
+
| qualifierList
|
137
|
+
{ result = CIM::QualifierSet.new val[0] }
|
138
|
+
;
|
139
|
+
|
140
|
+
qualifierList
|
141
|
+
: "[" qualifier qualifiers "]"
|
142
|
+
{ result = val[2]
|
143
|
+
result.unshift val[1] if val[1] }
|
144
|
+
;
|
145
|
+
|
146
|
+
qualifiers
|
147
|
+
: /* empty */
|
148
|
+
{ result = [] }
|
149
|
+
| qualifiers "," qualifier
|
150
|
+
{ result = val[0]
|
151
|
+
result << val[2] if val[2]
|
152
|
+
}
|
153
|
+
;
|
154
|
+
|
155
|
+
qualifier
|
156
|
+
: qualifierName qualifierParameter_opt flavor_opt
|
157
|
+
{ # Get qualifier decl
|
158
|
+
qualifier = case val[0]
|
159
|
+
when CIM::Qualifier then val[0].definition
|
160
|
+
when CIM::QualifierDeclaration then val[0]
|
161
|
+
when String then @qualifiers[val[0].downcase]
|
162
|
+
else
|
163
|
+
nil
|
164
|
+
end
|
165
|
+
raise MOF::Helper::Error.new(@name,@lineno,@line,"'#{val[0]}' is not a valid qualifier") unless qualifier
|
166
|
+
value = val[1]
|
167
|
+
raise MOF::Helper::Error.new(@name,@lineno,@line,"#{value.inspect} does not match qualifier type '#{qualifier.type}'") unless qualifier.type.matches?(value)||@style == :wmi
|
168
|
+
# Don't propagate a boolean 'false'
|
169
|
+
if qualifier.type == :boolean && value == false
|
170
|
+
result = nil
|
171
|
+
else
|
172
|
+
result = CIM::Qualifier.new(qualifier,value,val[2])
|
173
|
+
end
|
174
|
+
}
|
175
|
+
;
|
176
|
+
|
177
|
+
flavor_opt
|
178
|
+
: /* empty */
|
179
|
+
| ":" flavor
|
180
|
+
{ result = CIM::QualifierFlavors.new val[1] }
|
181
|
+
;
|
182
|
+
|
183
|
+
qualifierParameter_opt
|
184
|
+
: /* empty */
|
185
|
+
| qualifierParameter
|
186
|
+
;
|
187
|
+
|
188
|
+
qualifierParameter
|
189
|
+
: "(" constantValue ")"
|
190
|
+
{ result = val[1] }
|
191
|
+
| arrayInitializer
|
192
|
+
;
|
193
|
+
|
194
|
+
/* CIM::Flavors */
|
195
|
+
flavor
|
196
|
+
: AMENDED | ENABLEOVERRIDE | DISABLEOVERRIDE | RESTRICTED | TOSUBCLASS | TRANSLATABLE | TOINSTANCE
|
197
|
+
{ case val[0].to_sym
|
198
|
+
when :amended, :toinstance
|
199
|
+
raise StyleError.new(@name,@lineno,@line,"'#{val[0]}' is not a valid flavor") unless @style == :wmi
|
200
|
+
end
|
201
|
+
}
|
202
|
+
;
|
203
|
+
|
204
|
+
alias_opt
|
205
|
+
: /* empty */
|
206
|
+
| alias
|
207
|
+
;
|
208
|
+
|
209
|
+
superClass_opt
|
210
|
+
: /* empty */
|
211
|
+
| superClass
|
212
|
+
;
|
213
|
+
|
214
|
+
className
|
215
|
+
: IDENTIFIER /* must be <schema>_<classname> in CIM v2.x */
|
216
|
+
{ raise ParseError.new("Class name must be prefixed by '<schema>_'") unless val[0].include?("_") || @style == :wmi }
|
217
|
+
;
|
218
|
+
|
219
|
+
alias
|
220
|
+
: AS aliasIdentifier
|
221
|
+
{ result = val[1] }
|
222
|
+
;
|
223
|
+
|
224
|
+
aliasIdentifier
|
225
|
+
: "$" IDENTIFIER /* NO whitespace ! */
|
226
|
+
{ result = val[1] }
|
227
|
+
;
|
228
|
+
|
229
|
+
superClass
|
230
|
+
: ":" className
|
231
|
+
{ result = val[1] }
|
232
|
+
;
|
233
|
+
|
234
|
+
|
235
|
+
propertyDeclaration
|
236
|
+
: qualifierList_opt dataType propertyName array_opt defaultValue_opt ";"
|
237
|
+
{ if val[3]
|
238
|
+
type = CIM::Array.new val[3],val[1]
|
239
|
+
else
|
240
|
+
type = val[1]
|
241
|
+
end
|
242
|
+
result = CIM::Property.new(type,val[2],val[0],val[4])
|
243
|
+
}
|
244
|
+
;
|
245
|
+
|
246
|
+
referenceDeclaration
|
247
|
+
: qualifierList_opt objectRef referenceName array_opt defaultValue_opt ";"
|
248
|
+
{ if val[4]
|
249
|
+
raise StyleError.new(@name,@lineno,@line,"Array not allowed in reference declaration") unless @style == :wmi
|
250
|
+
end
|
251
|
+
result = CIM::Reference.new(val[1],val[2],val[0],val[4]) }
|
252
|
+
;
|
253
|
+
|
254
|
+
methodDeclaration
|
255
|
+
: qualifierList_opt dataType methodName "(" parameterList_opt ")" ";"
|
256
|
+
{ result = CIM::Method.new(val[1],val[2],val[0],val[4]) }
|
257
|
+
;
|
258
|
+
|
259
|
+
propertyName
|
260
|
+
: IDENTIFIER
|
261
|
+
| PROPERTY
|
262
|
+
{ # tmplprov.mof has 'string Property;'
|
263
|
+
raise StyleError.new(@name,@lineno,@line,"Invalid keyword '#{val[0]}' used for property name") unless @style == :wmi
|
264
|
+
}
|
265
|
+
;
|
266
|
+
|
267
|
+
referenceName
|
268
|
+
: IDENTIFIER
|
269
|
+
| INDICATION
|
270
|
+
{ result = "Indication" }
|
271
|
+
;
|
272
|
+
|
273
|
+
methodName
|
274
|
+
: IDENTIFIER
|
275
|
+
;
|
276
|
+
|
277
|
+
dataType
|
278
|
+
: DT_UINT8
|
279
|
+
| DT_SINT8
|
280
|
+
| DT_UINT16
|
281
|
+
| DT_SINT16
|
282
|
+
| DT_UINT32
|
283
|
+
| DT_SINT32
|
284
|
+
| DT_UINT64
|
285
|
+
| DT_SINT64
|
286
|
+
| DT_REAL32
|
287
|
+
| DT_REAL64
|
288
|
+
| DT_CHAR16
|
289
|
+
| DT_STR
|
290
|
+
| DT_BOOLEAN
|
291
|
+
| DT_DATETIME
|
292
|
+
| DT_VOID
|
293
|
+
{ raise StyleError.new(@name,@lineno,@line,"'void' is not a valid datatype") unless @style == :wmi }
|
294
|
+
;
|
295
|
+
|
296
|
+
objectRef
|
297
|
+
: className
|
298
|
+
{ # WMI uses class names as data types (without REF ?!)
|
299
|
+
raise StyleError.new(@name,@lineno,@line,"Expected 'ref' keyword after classname '#{val[0]}'") unless @style == :wmi
|
300
|
+
result = CIM::ReferenceType.new val[0]
|
301
|
+
}
|
302
|
+
|
303
|
+
| className REF
|
304
|
+
{ result = CIM::ReferenceType.new val[0] }
|
305
|
+
;
|
306
|
+
|
307
|
+
parameterList_opt
|
308
|
+
: /* empty */
|
309
|
+
| parameterList
|
310
|
+
;
|
311
|
+
|
312
|
+
parameterList
|
313
|
+
: parameter parameters
|
314
|
+
{ result = val[1].unshift val[0] }
|
315
|
+
;
|
316
|
+
|
317
|
+
parameters
|
318
|
+
: /* empty */
|
319
|
+
{ result = [] }
|
320
|
+
| parameters "," parameter
|
321
|
+
{ result = val[0] << val[2] }
|
322
|
+
;
|
323
|
+
|
324
|
+
parameter
|
325
|
+
: qualifierList_opt typespec parameterName array_opt parameterValue_opt
|
326
|
+
{ if val[3]
|
327
|
+
type = CIM::Array.new val[3], val[1]
|
328
|
+
else
|
329
|
+
type = val[1]
|
330
|
+
end
|
331
|
+
result = CIM::Property.new(type,val[2],val[0])
|
332
|
+
}
|
333
|
+
;
|
334
|
+
|
335
|
+
typespec
|
336
|
+
: dataType
|
337
|
+
| objectRef
|
338
|
+
;
|
339
|
+
|
340
|
+
parameterName
|
341
|
+
: IDENTIFIER
|
342
|
+
;
|
343
|
+
|
344
|
+
array_opt
|
345
|
+
: /* empty */
|
346
|
+
| array
|
347
|
+
;
|
348
|
+
|
349
|
+
parameterValue_opt
|
350
|
+
: /* empty */
|
351
|
+
| defaultValue
|
352
|
+
{ raise "Default parameter value not allowed in syntax style '{@style}'" unless @style == :wmi }
|
353
|
+
;
|
354
|
+
|
355
|
+
array
|
356
|
+
: "[" positiveDecimalValue_opt "]"
|
357
|
+
{ result = val[1] }
|
358
|
+
;
|
359
|
+
|
360
|
+
positiveDecimalValue_opt
|
361
|
+
: /* empty */
|
362
|
+
{ result = -1 }
|
363
|
+
| positiveDecimalValue
|
364
|
+
;
|
365
|
+
|
366
|
+
defaultValue_opt
|
367
|
+
: /* empty */
|
368
|
+
| defaultValue
|
369
|
+
;
|
370
|
+
|
371
|
+
defaultValue
|
372
|
+
: "=" initializer
|
373
|
+
{ result = val[1] }
|
374
|
+
;
|
375
|
+
|
376
|
+
initializer
|
377
|
+
: constantValue
|
378
|
+
| arrayInitializer
|
379
|
+
| referenceInitializer
|
380
|
+
;
|
381
|
+
|
382
|
+
arrayInitializer
|
383
|
+
: "{" constantValues "}"
|
384
|
+
{ result = val[1] }
|
385
|
+
;
|
386
|
+
|
387
|
+
constantValues
|
388
|
+
: /* empty */
|
389
|
+
| constantValue
|
390
|
+
{ result = [ val[0] ] }
|
391
|
+
| constantValues "," constantValue
|
392
|
+
{ result = val[0] << val[2] }
|
393
|
+
;
|
394
|
+
|
395
|
+
constantValue
|
396
|
+
: integerValue
|
397
|
+
| realValue
|
398
|
+
| charValue
|
399
|
+
| string
|
400
|
+
| booleanValue
|
401
|
+
| nullValue
|
402
|
+
| instance
|
403
|
+
{ raise "Instance as property value not allowed in syntax style '{@style}'" unless @style == :wmi }
|
404
|
+
;
|
405
|
+
|
406
|
+
integerValue
|
407
|
+
: binaryValue
|
408
|
+
| octalValue
|
409
|
+
| decimalValue
|
410
|
+
| positiveDecimalValue
|
411
|
+
| hexValue
|
412
|
+
;
|
413
|
+
|
414
|
+
string
|
415
|
+
: stringValue
|
416
|
+
| string stringValue
|
417
|
+
{ result = val[0] + val[1] }
|
418
|
+
;
|
419
|
+
|
420
|
+
referenceInitializer
|
421
|
+
: objectHandle
|
422
|
+
| aliasIdentifier
|
423
|
+
;
|
424
|
+
|
425
|
+
objectHandle
|
426
|
+
: namespace_opt modelPath
|
427
|
+
;
|
428
|
+
|
429
|
+
namespace_opt
|
430
|
+
: /* empty */
|
431
|
+
| namespaceHandle ":"
|
432
|
+
;
|
433
|
+
|
434
|
+
namespaceHandle
|
435
|
+
: IDENTIFIER
|
436
|
+
;
|
437
|
+
|
438
|
+
/*
|
439
|
+
* Note
|
440
|
+
: structure depends on type of namespace
|
441
|
+
*/
|
442
|
+
|
443
|
+
modelPath
|
444
|
+
: className "." keyValuePairList
|
445
|
+
;
|
446
|
+
|
447
|
+
keyValuePairList
|
448
|
+
: keyValuePair keyValuePairs
|
449
|
+
;
|
450
|
+
|
451
|
+
keyValuePairs
|
452
|
+
: /* empty */
|
453
|
+
| keyValuePairs "," keyValuePair
|
454
|
+
;
|
455
|
+
|
456
|
+
keyValuePair
|
457
|
+
: keyname "=" initializer
|
458
|
+
;
|
459
|
+
|
460
|
+
keyname
|
461
|
+
: propertyName | referenceName
|
462
|
+
;
|
463
|
+
|
464
|
+
/***
|
465
|
+
* qualifierDeclaration
|
466
|
+
*
|
467
|
+
*/
|
468
|
+
|
469
|
+
qualifierDeclaration
|
470
|
+
/* 0 1 2 3 4 */
|
471
|
+
: QUALIFIER qualifierName qualifierType scope defaultFlavor_opt ";"
|
472
|
+
{ result = CIM::QualifierDeclaration.new( val[1], val[2][0], val[2][1], val[3], val[4]) }
|
473
|
+
;
|
474
|
+
|
475
|
+
defaultFlavor_opt
|
476
|
+
: /* empty */
|
477
|
+
| defaultFlavor
|
478
|
+
;
|
479
|
+
|
480
|
+
qualifierName
|
481
|
+
: IDENTIFIER
|
482
|
+
| ASSOCIATION /* meta qualifier */
|
483
|
+
| INDICATION /* meta qualifier */
|
484
|
+
| REFERENCE /* Added in DSP0004 2.7.0 */
|
485
|
+
| SCHEMA
|
486
|
+
;
|
487
|
+
|
488
|
+
/* [type, value] */
|
489
|
+
qualifierType
|
490
|
+
: ":" dataType array_opt defaultValue_opt
|
491
|
+
{ type = val[2].nil? ? val[1] : CIM::Array.new(val[2],val[1])
|
492
|
+
result = [ type, val[3] ]
|
493
|
+
}
|
494
|
+
;
|
495
|
+
|
496
|
+
scope
|
497
|
+
: "," SCOPE "(" metaElements ")"
|
498
|
+
{ result = CIM::QualifierScopes.new(val[3]) }
|
499
|
+
;
|
500
|
+
|
501
|
+
metaElements
|
502
|
+
: metaElement
|
503
|
+
{ result = [ val[0] ] }
|
504
|
+
| metaElements "," metaElement
|
505
|
+
{ result = val[0] << val[2] }
|
506
|
+
;
|
507
|
+
|
508
|
+
metaElement
|
509
|
+
: SCHEMA
|
510
|
+
| CLASS
|
511
|
+
| ASSOCIATION
|
512
|
+
| INDICATION
|
513
|
+
| QUALIFIER
|
514
|
+
| PROPERTY
|
515
|
+
| REFERENCE
|
516
|
+
| METHOD
|
517
|
+
| PARAMETER
|
518
|
+
| ANY
|
519
|
+
;
|
520
|
+
|
521
|
+
defaultFlavor
|
522
|
+
: "," FLAVOR "(" flavors ")"
|
523
|
+
{ result = CIM::QualifierFlavors.new val[3] }
|
524
|
+
;
|
525
|
+
|
526
|
+
flavors
|
527
|
+
: flavor
|
528
|
+
{ result = [ val[0] ] }
|
529
|
+
| flavors "," flavor
|
530
|
+
{ result = val[0] << val[2] }
|
531
|
+
;
|
532
|
+
|
533
|
+
/***
|
534
|
+
* instanceDeclaration
|
535
|
+
*
|
536
|
+
*/
|
537
|
+
|
538
|
+
instanceDeclaration
|
539
|
+
: instance ";"
|
540
|
+
;
|
541
|
+
|
542
|
+
instance
|
543
|
+
: qualifierList_opt INSTANCE OF className alias_opt "{" valueInitializers "}"
|
544
|
+
;
|
545
|
+
|
546
|
+
valueInitializers
|
547
|
+
: valueInitializer
|
548
|
+
| valueInitializers valueInitializer
|
549
|
+
;
|
550
|
+
|
551
|
+
valueInitializer
|
552
|
+
: qualifierList_opt keyname "=" initializer ";"
|
553
|
+
| qualifierList_opt keyname ";"
|
554
|
+
{ raise "Instance property '#{val[1]} must have a value" unless @style == :wmi }
|
555
|
+
;
|
556
|
+
|
557
|
+
end # class Parser
|
558
|
+
|
559
|
+
---- header ----
|
560
|
+
|
561
|
+
# parser.rb - generated by racc
|
562
|
+
|
563
|
+
require 'strscan'
|
564
|
+
require 'rubygems'
|
565
|
+
require 'cim'
|
566
|
+
require File.join(File.dirname(__FILE__), 'result')
|
567
|
+
require File.join(File.dirname(__FILE__), 'scanner')
|
568
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
569
|
+
|
570
|
+
---- inner ----
|
571
|
+
|
572
|
+
#
|
573
|
+
# Initialize MOF::Parser
|
574
|
+
# MOF::Parser.new options = {}
|
575
|
+
#
|
576
|
+
# options -> Hash of options
|
577
|
+
# :debug -> boolean
|
578
|
+
# :includes -> array of include dirs
|
579
|
+
# :style -> :cim or :wmi
|
580
|
+
#
|
581
|
+
def initialize options = {}
|
582
|
+
@yydebug = options[:debug]
|
583
|
+
@includes = options[:includes] || []
|
584
|
+
@quiet = options[:quiet]
|
585
|
+
@style = options[:style] || :cim # default to style CIM v2.2 syntax
|
586
|
+
|
587
|
+
@lineno = 1
|
588
|
+
@file = nil
|
589
|
+
@iconv = nil
|
590
|
+
@eol = "\n"
|
591
|
+
@fname = nil
|
592
|
+
@fstack = []
|
593
|
+
@in_comment = false
|
594
|
+
@seen_files = []
|
595
|
+
@qualifiers = {}
|
596
|
+
end
|
597
|
+
|
598
|
+
#
|
599
|
+
# Make options hash from argv
|
600
|
+
#
|
601
|
+
# returns [ files, options ]
|
602
|
+
#
|
603
|
+
|
604
|
+
def self.argv_handler name, argv
|
605
|
+
files = []
|
606
|
+
options = { :namespace => "" }
|
607
|
+
while argv.size > 0
|
608
|
+
case opt = argv.shift
|
609
|
+
when "-h"
|
610
|
+
$stderr.puts "Ruby MOF compiler"
|
611
|
+
$stderr.puts "#{name} [-h] [-d] [-I <dir>] [<moffiles>]"
|
612
|
+
$stderr.puts "Compiles <moffile>"
|
613
|
+
$stderr.puts "\t-d debug"
|
614
|
+
$stderr.puts "\t-h this help"
|
615
|
+
$stderr.puts "\t-I <dir> include dir"
|
616
|
+
$stderr.puts "\t-f force"
|
617
|
+
$stderr.puts "\t-n <namespace>"
|
618
|
+
$stderr.puts "\t-o <output>"
|
619
|
+
$stderr.puts "\t-s <style> syntax style (wmi,cim)"
|
620
|
+
$stderr.puts "\t-q quiet"
|
621
|
+
$stderr.puts "\t<moffiles> file(s) to read (else use $stdin)"
|
622
|
+
exit 0
|
623
|
+
when "-f" then options[:force] = true
|
624
|
+
when "-s" then options[:style] = argv.shift.to_sym
|
625
|
+
when "-d" then options[:debug] = true
|
626
|
+
when "-q" then options[:quiet] = true
|
627
|
+
when "-I"
|
628
|
+
options[:includes] ||= []
|
629
|
+
dirname = argv.shift
|
630
|
+
unless File.directory?(dirname)
|
631
|
+
files << dirname
|
632
|
+
dirname = File.dirname(dirname)
|
633
|
+
end
|
634
|
+
options[:includes] << Pathname.new(dirname)
|
635
|
+
when "-n" then options[:namespace] = argv.shift
|
636
|
+
when "-o" then options[:output] = argv.shift
|
637
|
+
when /^-.+/
|
638
|
+
$stderr.puts "Undefined option #{opt}"
|
639
|
+
else
|
640
|
+
files << opt
|
641
|
+
end
|
642
|
+
end
|
643
|
+
[ files, options ]
|
644
|
+
end
|
645
|
+
|
646
|
+
include Helper
|
647
|
+
include Scanner
|
648
|
+
|
649
|
+
---- footer ----
|