1 bob 1.1 %{
2 /* Flex grammar created from CIM Specification Version 2.2 Appendix A */
3
4 /*
5 Note the following implementation details:
6
7 1. The MOF specification has a production of type assocDeclaration,
8 but an association is just a type of classDeclaration with a few
9 special rules. At least for the first pass, I'm treating an
10 associationDeclaration as a classDeclaration and applying its
11 syntactical rules outside of the grammar definition.
12
13 2. Same with the indicationDeclaration. It appears to be a normal
14 classDeclaration with the INDICATION qualifier and no special
15 syntactical rules.
16
17 3. The Parser uses String objects throughout to represent
18 character data. However, the tokenizer underneath is probably
19 working with 8-bit chars. If we later use an extended character
20 compatible tokenizer, I anticipate NO CHANGE to this parser.
21
22 bob 1.1 4. Besides the tokenizer, this parser uses 2 sets of outside
23 services:
24 1)Class valueFactory. This has a couple of static methods
25 that assist in creating CIMValue objects from Strings.
26 2)Class cimmofParser. This has a wide variety of methods
27 that fall into these catagories:
28 a) Interfaces to the Repository. You call cimmofParser::
29 methods to query and store compiled CIM elements.
30 b) Error handling.
31 c) Data format conversions.
32 d) Tokenizer manipulation
33 e) Pragma handling
34 f) Alias Handling
35 */
36
|
37 mike 1.7 #define YYSTACKSIZE 2000
38
|
39 bob 1.1 #include <cstdlib>
|
40 chuck 1.27 #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && !defined(__OS400__)
|
41 bob 1.1 #include <malloc.h>
|
42 sage 1.14 #endif
|
43 bob 1.1 #include <cstdio>
44 #include <cstring>
|
45 mike 1.5 #include <Pegasus/Common/String.h>
|
46 kumpf 1.23 #include <Pegasus/Common/CIMName.h>
|
47 bob 1.1 #include "cimmofParser.h"
48 #include "valueFactory.h"
49 #include "memobjs.h"
50 #include "qualifierList.h"
|
51 bob 1.3 #include "objname.h"
|
52 bob 1.1
53 //extern cimmofParser g_cimmofParser;
54
55 extern int cimmof_lex(void);
56 extern int cimmof_error(...);
57 extern char *cimmof_text;
58 extern void cimmof_yy_less(int n);
59
60 /* ------------------------------------------------------------------- */
61 /* These globals provide continuity between various pieces of a */
62 /* declaration. They are usually interpreted as "these modifiers were */
63 /* encountered and need to be applied to the finished object". For */
64 /* example, qualifiers are accumulated in g_qualifierList[] as they */
65 /* encountered, then applied to the production they qualify when it */
66 /* is completed. */
67 /* ------------------------------------------------------------------- */
|
68 kumpf 1.25 CIMFlavor g_flavor = CIMFlavor (CIMFlavor::NONE);
69 CIMScope g_scope = CIMScope ();
|
70 karl 1.16 //ATTN: BB 2001 BB P1 - Fixed size qualifier list max 10. Make larger or var
71 qualifierList g_qualifierList(10);
|
72 bob 1.3 CIMMethod *g_currentMethod = 0;
73 CIMClass *g_currentClass = 0;
74 CIMInstance *g_currentInstance = 0;
75 String g_currentAlias = String::EMPTY;
|
76 kumpf 1.23 CIMName g_referenceClassName = CIMName();
|
77 kumpf 1.29 Array<CIMKeyBinding> g_KeyBindingArray; // it gets created empty
|
78 kumpf 1.17 TYPED_INITIALIZER_VALUE g_typedInitializerValue;
|
79 bob 1.1
80 /* ------------------------------------------------------------------- */
|
81 bob 1.3 /* Pragmas, except for the Include pragma, are not handled yet */
|
82 bob 1.1 /* I don't understand them, so it may be a while before they are */
83 /* ------------------------------------------------------------------- */
84 struct pragma {
85 String name;
86 String value;
87 };
88
89 /* ---------------------------------------------------------------- */
90 /* Use our general wrap manager to handle end-of-file */
91 /* ---------------------------------------------------------------- */
92 extern "C" {
93 int
94 cimmof_wrap() {
95 return cimmofParser::Instance()->wrapCurrentBuffer();
96 }
97 }
98
99 /* ---------------------------------------------------------------- */
100 /* Pass errors to our general log manager. */
101 /* ---------------------------------------------------------------- */
102 void
|
103 kumpf 1.20 cimmof_error(const char *msg) {
|
104 bob 1.1 cimmofParser::Instance()->log_parse_error(cimmof_text, msg);
105 // printf("Error: %s\n", msg);
106 }
107
108 %}
109
110 %union {
111 struct pragma *pragma;
112 int ival;
113 // char *strval;
114 String * strval;
|
115 kumpf 1.23 CIMName * cimnameval;
|
116 kumpf 1.22 CIMType datatype;
|
117 bob 1.1 CIMValue * value;
|
118 mike 1.5 String * strptr;
|
119 bob 1.1 CIMQualifier * qualifier;
|
120 kumpf 1.25 CIMScope * scope;
121 CIMFlavor * flavor;
|
122 bob 1.1 CIMProperty * property;
123 CIMMethod * method;
124 CIMClass * mofclass;
125 CIMQualifierDecl * mofqualifier;
126 CIMInstance * instance;
|
127 kumpf 1.21 CIMObjectPath * reference;
|
128 bob 1.3 modelPath * modelpath;
|
129 kumpf 1.29 CIMKeyBinding * keybinding;
|
130 kumpf 1.17 TYPED_INITIALIZER_VALUE * typedinitializer;
|
131 bob 1.1 }
132
133 %token TOK_LEFTCURLYBRACE
134 %token TOK_RIGHTCURLYBRACE
135 %token TOK_RIGHTSQUAREBRACKET
136 %token TOK_LEFTSQUAREBRACKET
137 %token TOK_LEFTPAREN
138 %token TOK_RIGHTPAREN
139 %token TOK_COLON
140 %token TOK_SEMICOLON
141 %token TOK_POSITIVE_DECIMAL_VALUE
142 %token TOK_SIGNED_DECIMAL_VALUE
143 %token TOK_EQUAL
144 %token TOK_COMMA
145 %token TOK_CLASS
146 %token TOK_REAL_VALUE
147 %token TOK_CHAR_VALUE
|
148 mike 1.2 %token TOK_STRING_VALUE
|
149 bob 1.1 %token TOK_NULL_VALUE
150 %token TOK_OCTAL_VALUE
151 %token TOK_HEX_VALUE
152 %token TOK_BINARY_VALUE
153 %token TOK_TRUE
154 %token TOK_FALSE
155 %token TOK_DQUOTE
156 %token TOK_PERIOD
|
157 mike 1.2 %token TOK_SIMPLE_IDENTIFIER
|
158 bob 1.1 %token TOK_ALIAS_IDENTIFIER
159 %token TOK_PRAGMA
160 %token TOK_INCLUDE
161 %token TOK_AS
162 %token TOK_INSTANCE
163 %token TOK_OF
164 %token TOK_QUALIFIER
165 %token TOK_SCOPE
166 %token TOK_SCHEMA
167 %token TOK_ASSOCIATION
168 %token TOK_INDICATION
169 %token TOK_PROPERTY
170 %token TOK_REFERENCE
171 %token TOK_METHOD
172 %token TOK_PARAMETER
173 %token TOK_ANY
174 %token TOK_REF
175 %token TOK_FLAVOR
176 %token TOK_ENABLEOVERRIDE
177 %token TOK_DISABLEOVERRIDE
178 %token TOK_RESTRICTED
179 bob 1.1 %token TOK_TOSUBCLASS
180 %token TOK_TRANSLATABLE
181 %token TOK_DT_STR
182 %token TOK_DT_BOOL
183 %token TOK_DT_DATETIME
184 %token TOK_DT_UINT8
185 %token TOK_DT_SINT8
186 %token TOK_DT_UINT16
187 %token TOK_DT_SINT16
188 %token TOK_DT_UINT32
189 %token TOK_DT_SINT32
190 %token TOK_DT_UINT64
191 %token TOK_DT_SINT64
192 %token TOK_DT_CHAR8
193 %token TOK_DT_CHAR16
194 %token TOK_DT_REAL32
195 %token TOK_DT_REAL64
|
196 bob 1.9 %token TOK_UNEXPECTED_CHAR
|
197 bob 1.1 %token TOK_END_OF_FILE
198
|
199 kumpf 1.23 %type <strval> pragmaName pragmaVal keyValuePairName qualifierName
|
200 bob 1.1 %type <strval> fileName referencedObject referenceName referencePath
201 %type <strval> TOK_POSITIVE_DECIMAL_VALUE TOK_OCTAL_VALUE TOK_HEX_VALUE
202 %type <strval> TOK_SIGNED_DECIMAL_VALUE TOK_BINARY_VALUE
203 %type <strval> TOK_SIMPLE_IDENTIFIER TOK_STRING_VALUE
|
204 kumpf 1.18 %type <strval> stringValue stringValues initializer constantValue
|
205 kumpf 1.17 %type <strval> nonNullConstantValue
|
206 bob 1.3 %type <strval> arrayInitializer constantValues
|
207 kumpf 1.23 %type <strval> TOK_ALIAS_IDENTIFIER alias aliasIdentifier
|
208 kumpf 1.20 %type <strval> integerValue TOK_REAL_VALUE TOK_CHAR_VALUE
|
209 bob 1.3 %type <strval> namespaceHandle namespaceHandleRef
210 %type <strval> referenceInitializer aliasInitializer objectHandle
|
211 bob 1.9 %type <strval> TOK_UNEXPECTED_CHAR
|
212 bob 1.1
|
213 kumpf 1.23 %type <cimnameval> propertyName parameterName methodName className
214 %type <cimnameval> superClass
215
|
216 kumpf 1.20 %type <typedinitializer> typedInitializer typedDefaultValue
217 %type <typedinitializer> typedQualifierParameter
|
218 kumpf 1.17
|
219 bob 1.3 %type <modelpath> modelPath
220 %type <keybinding> keyValuePair
|
221 kumpf 1.26 %type <scope> scope metaElements metaElement
|
222 kumpf 1.25 %type <flavor> flavor defaultFlavor
|
223 kumpf 1.26 %type <ival> array
|
224 bob 1.3 %type <ival> booleanValue keyValuePairList
|
225 bob 1.1 %type <pragma> compilerDirectivePragma
226 %type <datatype> dataType intDataType realDataType parameterType objectRef
227 %type <value> qualifierValue
228 %type <qualifier> qualifier
|
229 bob 1.3 %type <property> propertyBody propertyDeclaration referenceDeclaration
|
230 bob 1.1 %type <method> methodStart methodDeclaration
231 %type <mofclass> classHead classDeclaration
232 %type <mofqualifier> qualifierDeclaration
|
233 bob 1.3 %type <instance> instanceHead instanceDeclaration
|
234 bob 1.1
235 %%
|
236 kumpf 1.17 mofSpec: mofProductions ;
|
237 bob 1.1
238 mofProductions: mofProduction mofProductions
239 | /* empty */ ;
|
240 karl 1.16 // ATTN: P1 KS Apr 2002 Limit in (none) Directive handling. See FIXME below.
|
241 bob 1.1 mofProduction: compilerDirective { /* FIXME: Where do we put directives? */ }
242 | qualifierDeclaration
243 { cimmofParser::Instance()->addQualifier($1); delete $1; }
244 | classDeclaration
245 { cimmofParser::Instance()->addClass($1); }
246 | instanceDeclaration
|
247 bob 1.4 { cimmofParser::Instance()->addInstance($1); } ;
|
248 bob 1.1
249 classDeclaration: classHead classBody
250 {
251 if (g_currentAlias != String::EMPTY)
252 cimmofParser::Instance()->addClassAlias(g_currentAlias, $$, false);
253 } ;
254
255 classHead: qualifierList TOK_CLASS className alias superClass
256 {
257 $$ = cimmofParser::Instance()->newClassDecl(*$3, *$5);
|
258 mike 1.8 apply(&g_qualifierList, $$);
|
259 bob 1.1 g_currentAlias = *$4;
260 if (g_currentClass)
261 delete g_currentClass;
262 g_currentClass = $$;
263 delete $3;
264 delete $4;
265 delete $5;
|
266 kumpf 1.17 } ;
|
267 bob 1.1
|
268 kumpf 1.17 className: TOK_SIMPLE_IDENTIFIER { } ;
|
269 bob 1.1
|
270 kumpf 1.23 superClass: TOK_COLON className { $$ = new CIMName(*$2); }
271 | /* empty */ { $$ = new CIMName(); } ;
|
272 bob 1.1
273 classBody: TOK_LEFTCURLYBRACE classFeatures TOK_RIGHTCURLYBRACE TOK_SEMICOLON
274 | TOK_LEFTCURLYBRACE TOK_RIGHTCURLYBRACE TOK_SEMICOLON ;
275
276 classFeatures: classFeature
277 | classFeatures classFeature ;
278
279 classFeature: propertyDeclaration {
|
280 bob 1.3 cimmofParser::Instance()->applyProperty(*g_currentClass, *$1); delete $1; }
|
281 bob 1.1 | methodDeclaration {
282 cimmofParser::Instance()->applyMethod(*g_currentClass, *$1); }
283 | referenceDeclaration {
|
284 bob 1.3 cimmofParser::Instance()->applyProperty(*g_currentClass, *$1); delete $1; };
|
285 bob 1.1
286 methodDeclaration: qualifierList methodStart methodBody methodEnd
287 {
288 $$ = $2;
|
289 mike 1.8 apply(&g_qualifierList, $$);
|
290 bob 1.1 } ;
291
292 methodStart: dataType methodName
293 {
294 if (g_currentMethod)
295 delete g_currentMethod;
296 g_currentMethod =
297 cimmofParser::Instance()->newMethod(*$2, $1) ;
298 $$ = g_currentMethod;
299 delete $2;
300 } ;
301
302 methodBody: TOK_LEFTPAREN parameters TOK_RIGHTPAREN ;
303
304 methodEnd: TOK_SEMICOLON ;
305
306 propertyDeclaration: qualifierList propertyBody propertyEnd
307 {
308 $$ = $2;
|
309 mike 1.8 apply(&g_qualifierList, $$);
|
310 bob 1.1 } ;
311
|
312 karl 1.13 // KS 8 March 2002 - Extended to pass isArray and arraySize
|
313 kumpf 1.18 propertyBody: dataType propertyName array typedDefaultValue
|
314 bob 1.1 {
|
315 kumpf 1.18 CIMValue *v = valueFactory::createValue($1, $3,
316 ($4->type == CIMMOF_NULL_VALUE), $4->value);
|
317 karl 1.13 if ($3 == -1) {
318 $$ = cimmofParser::Instance()->newProperty(*$2, *v, false, 0);
319 } else {
320 $$ = cimmofParser::Instance()->newProperty(*$2, *v, true, $3);
321 }
322
|
323 bob 1.1 delete $2;
|
324 kumpf 1.19 delete $4->value;
|
325 bob 1.1 delete v;
326 } ;
327
328 propertyEnd: TOK_SEMICOLON ;
329
330 referenceDeclaration: qualifierList referencedObject TOK_REF referenceName
331 referencePath TOK_SEMICOLON
332 {
|
333 bob 1.3 String s(*$2);
334 if (!String::equal(*$5, String::EMPTY))
|
335 kumpf 1.28 s.append("." + *$5);
|
336 kumpf 1.22 CIMValue *v = valueFactory::createValue(CIMTYPE_REFERENCE, -1, true, &s);
|
337 karl 1.13 //KS add the isArray and arraysize parameters. 8 mar 2002
338 $$ = cimmofParser::Instance()->newProperty(*$4, *v, false,0, *$2);
|
339 mike 1.8 apply(&g_qualifierList, $$);
|
340 bob 1.1 delete $2;
341 delete $4;
342 delete $5;
|
343 bob 1.3 delete v;
|
344 bob 1.1 } ;
345
346 referencedObject: TOK_SIMPLE_IDENTIFIER { $$ = $1; } ;
347
348 referenceName: TOK_SIMPLE_IDENTIFIER { $$ = $1; };
349
350 referencePath: TOK_EQUAL stringValue { $$ = $2; }
351 | /* empty */ { $$ = new String(String::EMPTY); } ;
352
|
353 kumpf 1.23 methodName: TOK_SIMPLE_IDENTIFIER { $$ = new CIMName(*$1); } ;
|
354 bob 1.1
355 parameters : parameter
356 | parameters TOK_COMMA parameter
357 | /* empty */ ;
358
359 parameter: qualifierList parameterType parameterName array
|
360 karl 1.16 { // ATTN: P2 2002 Question Need to create default value including type?
|
361 bob 1.3 CIMParameter *p = 0;
362 cimmofParser *cp = cimmofParser::Instance();
363 if ($4 == -1) {
364 p = cp->newParameter(*$3, $2, false, 0, g_referenceClassName);
365 } else {
366 p = cp->newParameter(*$3, $2, true, $4, g_referenceClassName);
367 }
|
368 kumpf 1.23 g_referenceClassName = CIMName();
|
369 mike 1.8 apply(&g_qualifierList, p);
|
370 bob 1.3 cp->applyParameter(*g_currentMethod, *p);
|
371 bob 1.1 delete p;
372 delete $3;
373 } ;
374
375 parameterType: dataType { $$ = $1; }
|
376 kumpf 1.22 | objectRef { $$ = CIMTYPE_REFERENCE; } ;
|
377 bob 1.1
|
378 bob 1.3 objectRef: className TOK_REF {
379 g_referenceClassName = *$1; } ;
|
380 bob 1.1
|
381 kumpf 1.23 parameterName: TOK_SIMPLE_IDENTIFIER { $$ = new CIMName(*$1); } ;
|
382 bob 1.1
|
383 kumpf 1.23 propertyName: TOK_SIMPLE_IDENTIFIER { $$ = new CIMName(*$1); } ;
|
384 bob 1.1
385 array: TOK_LEFTSQUAREBRACKET TOK_POSITIVE_DECIMAL_VALUE
386 TOK_RIGHTSQUAREBRACKET
387 { $$ = valueFactory::Stoi(*$2);
388 delete $2;
389 }
390 | TOK_LEFTSQUAREBRACKET TOK_RIGHTSQUAREBRACKET { $$ = 0; }
|
391 kumpf 1.17 | /* empty */ { $$ = -1; } ;
|
392 bob 1.1
|
393 kumpf 1.18 typedDefaultValue: TOK_EQUAL typedInitializer { $$ = $2; }
394 | { /* empty */
395 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
396 g_typedInitializerValue.value = new String(String::EMPTY);
397 $$ = &g_typedInitializerValue;
398 };
|
399 bob 1.1
400 initializer: constantValue { $$ = $1; }
401 | arrayInitializer { $$ = $1; }
|
402 bob 1.3 | referenceInitializer { $$ = $1; } ;
|
403 bob 1.1
|
404 kumpf 1.17 // The typedInitializer element is syntactially identical to
405 // the initializer element. However, the typedInitializer element
406 // returns, in addition to the value, the type of the value.
407 typedInitializer: nonNullConstantValue
408 {
409 g_typedInitializerValue.type = CIMMOF_CONSTANT_VALUE;
410 g_typedInitializerValue.value = $1;
411 $$ = &g_typedInitializerValue;
412 }
413 | TOK_NULL_VALUE
414 {
415 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
416 g_typedInitializerValue.value = new String(String::EMPTY);
417 $$ = &g_typedInitializerValue;
418 }
419 | arrayInitializer
420 {
421 g_typedInitializerValue.type = CIMMOF_ARRAY_VALUE;
422 g_typedInitializerValue.value = $1;
423 $$ = &g_typedInitializerValue;
424 }
425 kumpf 1.17 | referenceInitializer
426 {
427 g_typedInitializerValue.type = CIMMOF_REFERENCE_VALUE;
428 g_typedInitializerValue.value = $1;
429 $$ = &g_typedInitializerValue;
430 };
431
|
432 bob 1.1 constantValues: constantValue { $$ = $1; }
433 | constantValues TOK_COMMA constantValue
434 {
|
435 kumpf 1.28 (*$$).append(",");
436 (*$$).append(*$3);
|
437 bob 1.1 delete $3;
438 } ;
439
|
440 kumpf 1.17 // The nonNullConstantValue has been added to allow NULL
441 // to be distinguished from the EMPTY STRING.
442
443 constantValue: nonNullConstantValue {$$ = $1;}
444 | TOK_NULL_VALUE { $$ = new String(String::EMPTY); } ;
445
446 nonNullConstantValue: integerValue { $$ = $1; }
|
447 bob 1.1 | TOK_REAL_VALUE { $$ = $1; }
448 | TOK_CHAR_VALUE { $$ = $1; }
449 | stringValues { }
|
450 kumpf 1.17 | booleanValue { $$ = new String($1 ? "T" : "F"); };
|
451 bob 1.1
452 integerValue: TOK_POSITIVE_DECIMAL_VALUE
453 | TOK_SIGNED_DECIMAL_VALUE
454 | TOK_OCTAL_VALUE {
455 $$ = new String(cimmofParser::Instance()->oct_to_dec(*$1));
456 delete $1; }
457 | TOK_HEX_VALUE {
458 $$ = new String(cimmofParser::Instance()->hex_to_dec(*$1));
459 delete $1; }
460 | TOK_BINARY_VALUE {
461 $$ = new String(cimmofParser::Instance()->binary_to_dec(*$1));
462 delete $1; };
463
464 booleanValue: TOK_FALSE { $$ = 0; }
465 | TOK_TRUE { $$ = 1; } ;
466
467 stringValues: stringValue { $$ = $1; }
468 | stringValues stringValue
469 {
|
470 kumpf 1.28 (*$$).append(*$2); delete $2;
|
471 bob 1.1 } ;
472
473 stringValue: TOK_STRING_VALUE
474 {
475 String oldrep = *$1;
476 String s(oldrep), s1(String::EMPTY);
477 // Handle quoted quote
|
478 karl 1.6 int len = s.size();
|
479 bob 1.1 if (s[len] == '\n') {
480 // error: new line inside a string constant unless it is quoted
481 if (s[len - 2] == '\\') {
482 if (len > 3)
483 s1 = s.subString(1, len-3);
484 } else {
485 cimmof_error("New line in string constant");
486 }
487 cimmofParser::Instance()->increment_lineno();
488 } else { // Can only be a quotation mark
489 if (s[len - 2] == '\\') { // if it is quoted
490 if (len > 3)
491 s1 = s.subString(1, len-3);
|
492 kumpf 1.28 s1.append('\"');
|
493 bob 1.1 cimmof_yy_less(len-1);
494 } else { // This is the normal case: real quotes on both end
495 s1 = s.subString(1, len - 2) ;
496 }
497 }
498 delete $1; $$ = new String(s1);
|
499 kumpf 1.17 } ;
|
500 bob 1.1
|
501 kumpf 1.17 arrayInitializer:
502 TOK_LEFTCURLYBRACE constantValues TOK_RIGHTCURLYBRACE
503 { $$ = $2; }
504 | TOK_LEFTCURLYBRACE TOK_RIGHTCURLYBRACE
505 { $$ = new String(String::EMPTY); };
|
506 bob 1.1
507 referenceInitializer: objectHandle {}
|
508 bob 1.3 | aliasInitializer { } ;
|
509 bob 1.1
510 objectHandle: TOK_DQUOTE namespaceHandleRef modelPath TOK_DQUOTE
511 {
|
512 bob 1.3 // The objectName string is decomposed for syntactical purposes
513 // and reassembled here for later parsing in creation of an objname instance
514 String *s = new String(*$2);
515 if (!String::equal(*s, String::EMPTY) && $3)
|
516 kumpf 1.28 (*s).append(":");
|
517 bob 1.3 if ($3) {
|
518 kumpf 1.28 (*s).append($3->Stringrep());
|
519 bob 1.3 }
520 $$ = s;
|
521 bob 1.1 delete $2;
522 delete $3;
|
523 kumpf 1.17 } ;
|
524 bob 1.1
|
525 bob 1.3 aliasInitializer : aliasIdentifier {
526 // convert somehow from alias to a CIM object name
527 delete $1;
|
528 kumpf 1.17 } ;
|
529 bob 1.3
|
530 bob 1.1 namespaceHandleRef: namespaceHandle TOK_COLON
531 { }
532 | /* empty */ { $$ = new String(String::EMPTY); };
533
534 namespaceHandle: stringValue {};
535
|
536 bob 1.3 modelPath: className TOK_PERIOD keyValuePairList {
|
537 kumpf 1.30 modelPath *m = new modelPath((*$1).getString(), g_KeyBindingArray);
|
538 bob 1.3 g_KeyBindingArray.clear();
|
539 bob 1.1 delete $1;} ;
540
|
541 bob 1.3 keyValuePairList: keyValuePair { $$ = 0; }
542 | keyValuePairList TOK_COMMA keyValuePair { $$ = 0; } ;
|
543 bob 1.1
544 keyValuePair: keyValuePairName TOK_EQUAL initializer
|
545 bob 1.3 {
|
546 kumpf 1.29 CIMKeyBinding *kb = new CIMKeyBinding(*$1, *$3,
|
547 bob 1.3 modelPath::KeyBindingTypeOf(*$3));
548 g_KeyBindingArray.append(*kb);
549 delete kb;
|
550 bob 1.1 delete $1;
551 delete $3; } ;
552
553 keyValuePairName: TOK_SIMPLE_IDENTIFIER ;
554
555 alias: TOK_AS aliasIdentifier { $$ = $2; }
556 | /* empty */ { $$ = new String(String::EMPTY); } ;
557
558 aliasIdentifier: TOK_ALIAS_IDENTIFIER ;
559
560 instanceDeclaration: instanceHead instanceBody
561 {
|
562 bob 1.4 $$ = g_currentInstance;
|
563 bob 1.1 if (g_currentAlias != String::EMPTY)
564 cimmofParser::Instance()->addInstanceAlias(g_currentAlias, $1, true);
565 };
566
567 instanceHead: qualifierList TOK_INSTANCE TOK_OF className alias
568 {
569 if (g_currentInstance)
570 delete g_currentInstance;
571 g_currentAlias = *$5;
|
572 bob 1.4 g_currentInstance = cimmofParser::Instance()->newInstance(*$4);
|
573 bob 1.1 $$ = g_currentInstance;
|
574 mike 1.8 apply(&g_qualifierList, $$);
|
575 bob 1.4 delete $4;
|
576 bob 1.1 delete $5;
577 } ;
578
579 instanceBody: TOK_LEFTCURLYBRACE valueInitializers TOK_RIGHTCURLYBRACE
580 TOK_SEMICOLON ;
581
582 valueInitializers: valueInitializer
583 | valueInitializers valueInitializer ;
584
|
585 kumpf 1.17 // ATTN-DE-P1-20020427: Processing NULL Initializer values is incomplete.
586 // Currently only the arrayInitializer element has been modified to
587 // return CIMMOF_NULL_VALUE
588 valueInitializer: qualifierList TOK_SIMPLE_IDENTIFIER TOK_EQUAL
589 typedInitializer TOK_SEMICOLON
|
590 bob 1.1 {
|
591 bob 1.3 cimmofParser *cp = cimmofParser::Instance();
|
592 kumpf 1.17 // ATTN: P1 InstanceUpdate function 2001 BB Instance update needs work here and CIMOM
|
593 bob 1.3 // a property. It must be fixed in the Common code first.
|
594 bob 1.1 // What we have to do here is create a CIMProperty and initialize it with
595 // the value provided. The name of the property is $2 and it belongs
596 // to the class whose name is in g_currentInstance->getClassName().
|
597 bob 1.3 // The steps are
598 // 2. Get property declaration's value object
|
599 mike 1.8 CIMProperty *oldprop = cp->PropertyFromInstance(*g_currentInstance,
|
600 bob 1.3 *$2);
|
601 mike 1.8 CIMValue *oldv = cp->ValueFromProperty(*oldprop);
|
602 kumpf 1.17
|
603 bob 1.3 // 3. create the new Value object of the same type
|
604 kumpf 1.17
605 // We want createValue to interpret a value as an array if is enclosed
606 // in {}s (e.g., { 2 } or {2, 3, 5}) or it is NULL and the property is
607 // defined as an array. createValue is responsible for the actual
608 // validation.
609
610 CIMValue *v = valueFactory::createValue(oldv->getType(),
611 (($4->type == CIMMOF_ARRAY_VALUE) |
612 (($4->type == CIMMOF_NULL_VALUE) & oldprop->isArray()))?0:-1,
613 ($4->type == CIMMOF_NULL_VALUE),
614 $4->value);
615
|
616 bob 1.3 // 4. create a clone property with the new value
617 CIMProperty *newprop = cp->copyPropertyWithNewValue(*oldprop, *v);
|
618 bob 1.1 // 5. apply the qualifiers;
|
619 mike 1.8 apply(&g_qualifierList, newprop);
|
620 bob 1.1 // 6. and apply the CIMProperty to g_currentInstance.
|
621 bob 1.3 cp->applyProperty(*g_currentInstance, *newprop);
|
622 bob 1.1 delete $2;
|
623 kumpf 1.17 delete $4->value;
|
624 bob 1.3 delete oldprop;
625 delete oldv;
626 delete v;
627 delete newprop;
|
628 bob 1.1 } ;
629
630 compilerDirective: compilerDirectiveInclude
631 {
632 //printf("compilerDirectiveInclude ");
633 }
634 | compilerDirectivePragma
635 {
636 //printf("compilerDirectivePragma ");
637 } ;
638
639 compilerDirectiveInclude: TOK_PRAGMA TOK_INCLUDE TOK_LEFTPAREN fileName
640 TOK_RIGHTPAREN
641 {
642 cimmofParser::Instance()->enterInlineInclude(*$4); delete $4;
643 }
644 ;
645
646 fileName: stringValue { $$ = $1; } ;
647
648 compilerDirectivePragma: TOK_PRAGMA pragmaName
649 bob 1.1 TOK_LEFTPAREN pragmaVal TOK_RIGHTPAREN
650 { cimmofParser::Instance()->processPragma(*$2, *$4);
651 delete $2;
652 delete $4;
653 };
654
655 qualifierDeclaration: TOK_QUALIFIER qualifierName qualifierValue scope
656 defaultFlavor TOK_SEMICOLON
657 {
658 // CIMQualifierDecl *qd = new CIMQualifierDecl($2, $3, $4, $5);
|
659 kumpf 1.25 $$ = cimmofParser::Instance()->newQualifierDecl(*$2, $3, *$4, *$5);
|
660 bob 1.1 delete $2;
661 delete $3; // CIMValue object created in qualifierValue production
662 } ;
663
664
|
665 kumpf 1.18 qualifierValue: TOK_COLON dataType array typedDefaultValue
|
666 bob 1.1 {
|
667 kumpf 1.18 $$ = valueFactory::createValue($2, $3,
668 $4->type == CIMMOF_NULL_VALUE, $4->value);
669 delete $4->value;
|
670 kumpf 1.17 } ;
|
671 bob 1.1
|
672 kumpf 1.26 scope: scope_begin metaElements TOK_RIGHTPAREN { $$ = $2; } ;
|
673 bob 1.1
|
674 kumpf 1.25 scope_begin: TOK_COMMA TOK_SCOPE TOK_LEFTPAREN {
675 g_scope = CIMScope (CIMScope::NONE); } ;
|
676 bob 1.1
677 metaElements: metaElement { $$ = $1; }
678 | metaElements TOK_COMMA metaElement
|
679 kumpf 1.26 { $$->addScope(*$3); } ;
|
680 karl 1.16 // ATTN: 2001 P3 defer There is not CIMScope::SCHEMA. Spec Limit KS
|
681 bob 1.1
|
682 kumpf 1.26 metaElement: TOK_CLASS { $$ = new CIMScope(CIMScope::CLASS); }
683 // | TOK_SCHEMA { $$ = new CIMScope(CIMScope::SCHEMA); }
684 | TOK_SCHEMA { $$ = new CIMScope(CIMScope::CLASS); }
685 | TOK_ASSOCIATION { $$ = new CIMScope(CIMScope::ASSOCIATION); }
686 | TOK_INDICATION { $$ = new CIMScope(CIMScope::INDICATION); }
687 // | TOK_QUALIFIER { $$ = new CIMScope(CIMScope::QUALIFIER); }
688 | TOK_PROPERTY { $$ = new CIMScope(CIMScope::PROPERTY); }
689 | TOK_REFERENCE { $$ = new CIMScope(CIMScope::REFERENCE); }
690 | TOK_METHOD { $$ = new CIMScope(CIMScope::METHOD); }
691 | TOK_PARAMETER { $$ = new CIMScope(CIMScope::PARAMETER); }
692 | TOK_ANY { $$ = new CIMScope(CIMScope::ANY); } ;
|
693 bob 1.1
|
694 karl 1.11 // Correction KS 4 march 2002 - Set the default if empty
|
695 bob 1.1 defaultFlavor: TOK_COMMA flavorHead explicitFlavors TOK_RIGHTPAREN
|
696 kumpf 1.25 { $$ = &g_flavor; }
697 | /* empty */ { $$ = new CIMFlavor (CIMFlavor::NONE); } ;
|
698 bob 1.1
|
699 karl 1.11 // Correction KS 4 March 2002 - set the defaults (was zero)
700 // Set the flavors for the defaults required: via DEFAULTS
701
|
702 kumpf 1.25 flavorHead: TOK_FLAVOR TOK_LEFTPAREN {g_flavor = CIMFlavor (CIMFlavor::NONE);};
|
703 bob 1.1
704 explicitFlavors: explicitFlavor
705
706 | explicitFlavors TOK_COMMA explicitFlavor ;
707
|
708 mike 1.10
|
709 karl 1.15 // ATTN:KS-26/03/02 P2 This accumulates the flavor defintions. However, it allows multiple instances
710 // of any keyword. Note also that each entity simply sets a bit so that you may
711 // set disable and enable and we will not know which overrides the other.
712 // We need to create the function to insure that you cannot enable then disable or
713 // accept the latter and override the former.
714
715 // The compiler simply provides the flavors defined in the MOF and does not make any
716 // assumptions about defaults, etc. That is a problem for resolution of the flavors.
|
717 kumpf 1.25 explicitFlavor: TOK_ENABLEOVERRIDE
718 { g_flavor.addFlavor (CIMFlavor::ENABLEOVERRIDE); }
719 | TOK_DISABLEOVERRIDE { g_flavor.addFlavor (CIMFlavor::DISABLEOVERRIDE); }
720 | TOK_RESTRICTED { g_flavor.addFlavor (CIMFlavor::RESTRICTED); }
721 | TOK_TOSUBCLASS { g_flavor.addFlavor (CIMFlavor::TOSUBELEMENTS); }
722 | TOK_TRANSLATABLE { g_flavor.addFlavor (CIMFlavor::TRANSLATABLE); };
|
723 bob 1.1
|
724 kumpf 1.25 flavor: overrideFlavors { $$ = &g_flavor; }
725 | /* empty */ { $$ = new CIMFlavor (CIMFlavor::NONE); };
|
726 bob 1.1
727 overrideFlavors: explicitFlavor
728 | overrideFlavors explicitFlavor ;
729
730
731 dataType: intDataType { $$ = $1; }
732 | realDataType { $$ = $1; }
|
733 kumpf 1.22 | TOK_DT_STR { $$ = CIMTYPE_STRING; }
734 | TOK_DT_BOOL { $$ = CIMTYPE_BOOLEAN; }
735 | TOK_DT_DATETIME { $$ = CIMTYPE_DATETIME; } ;
736
737 intDataType: TOK_DT_UINT8 { $$ = CIMTYPE_UINT8; }
738 | TOK_DT_SINT8 { $$ = CIMTYPE_SINT8; }
739 | TOK_DT_UINT16 { $$ = CIMTYPE_UINT16; }
740 | TOK_DT_SINT16 { $$ = CIMTYPE_SINT16; }
741 | TOK_DT_UINT32 { $$ = CIMTYPE_UINT32; }
742 | TOK_DT_SINT32 { $$ = CIMTYPE_SINT32; }
743 | TOK_DT_UINT64 { $$ = CIMTYPE_UINT64; }
744 | TOK_DT_SINT64 { $$ = CIMTYPE_SINT64; }
745 | TOK_DT_CHAR16 { $$ = CIMTYPE_CHAR16; } ;
|
746 bob 1.1
|
747 kumpf 1.22 realDataType: TOK_DT_REAL32 { $$ =CIMTYPE_REAL32; }
748 | TOK_DT_REAL64 { $$ =CIMTYPE_REAL64; };
|
749 bob 1.1
750 qualifierList: qualifierListBegin qualifiers TOK_RIGHTSQUAREBRACKET
751 | /* empty */ { };
752
753 qualifierListBegin: TOK_LEFTSQUAREBRACKET { g_qualifierList.init(); } ;
754
755 qualifiers: qualifier { }
756 | qualifiers TOK_COMMA qualifier { } ;
757
|
758 kumpf 1.20 qualifier: qualifierName typedQualifierParameter flavor
|
759 bob 1.1 {
760 cimmofParser *p = cimmofParser::Instance();
761 // The qualifier value can't be set until we know the contents of the
762 // QualifierDeclaration. That's what QualifierValue() does.
|
763 kumpf 1.20 CIMValue *v = p->QualifierValue(*$1,
764 ($2->type == CIMMOF_NULL_VALUE), *$2->value);
|
765 bob 1.1 $$ = p->newQualifier(*$1, *v, g_flavor);
766 g_qualifierList.add($$);
767 delete $1;
|
768 kumpf 1.20 delete $2->value;
|
769 bob 1.1 delete v;
770 } ;
771
|
772 karl 1.11 // KS 4 march change g_flavor to set defaults
|
773 kumpf 1.25 qualifierName: TOK_SIMPLE_IDENTIFIER {
774 g_flavor = CIMFlavor (CIMFlavor::NONE); }
|
775 bob 1.1 | metaElement {
|
776 kumpf 1.26 $$ = new String((*$1).toString ());
|
777 kumpf 1.25 g_flavor = CIMFlavor (CIMFlavor::NONE); } ;
|
778 bob 1.1
|
779 kumpf 1.20 typedQualifierParameter: TOK_LEFTPAREN nonNullConstantValue TOK_RIGHTPAREN
780 {
781 g_typedInitializerValue.type = CIMMOF_CONSTANT_VALUE;
782 g_typedInitializerValue.value = $2;
783 $$ = &g_typedInitializerValue;
784 }
785 | TOK_LEFTPAREN TOK_NULL_VALUE TOK_RIGHTPAREN
786 {
787 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
788 g_typedInitializerValue.value = new String(String::EMPTY);
789 $$ = &g_typedInitializerValue;
790 }
791 | arrayInitializer
792 {
793 g_typedInitializerValue.type = CIMMOF_ARRAY_VALUE;
794 g_typedInitializerValue.value = $1;
795 $$ = &g_typedInitializerValue;
796 }
797 | { /* empty */
798 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
799 g_typedInitializerValue.value = new String(String::EMPTY);
800 kumpf 1.20 $$ = &g_typedInitializerValue;
801 };
|
802 bob 1.1
803 pragmaName: TOK_SIMPLE_IDENTIFIER { $$ = $1; } ;
804
805 pragmaVal: TOK_STRING_VALUE { $$ = $1; } ;
806
807 %%
|