1 //%2005////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //==============================================================================
30 /* Flex grammar created from CIM Specification Version 2.2 Appendix A */
33 Note the following implementation details:
35 1. The MOF specification has a production of type assocDeclaration,
36 but an association is just a type of classDeclaration with a few
37 special rules. At least for the first pass, I'm treating an
38 associationDeclaration as a classDeclaration and applying its
39 syntactical rules outside of the grammar definition.
41 2. Same with the indicationDeclaration. It appears to be a normal
42 classDeclaration with the INDICATION qualifier and no special
45 3. The Parser uses String objects throughout to represent
46 character data. However, the tokenizer underneath is probably
47 working with 8-bit chars. If we later use an extended character
48 compatible tokenizer, I anticipate NO CHANGE to this parser.
50 4. Besides the tokenizer, this parser uses 2 sets of outside
52 1)Class valueFactory. This has a couple of static methods
53 that assist in creating CIMValue objects from Strings.
54 2)Class cimmofParser. This has a wide variety of methods
55 that fall into these catagories:
56 a) Interfaces to the Repository. You call cimmofParser::
57 methods to query and store compiled CIM elements.
59 c) Data format conversions.
60 d) Tokenizer manipulation
66 #define YYSTACKSIZE 2000
69 #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && !defined(__OS400__) && !defined(PEGASUS_OS_VMS)
70 #if defined(PEGASUS_PLATFORM_DARWIN_PPC_GNU)
71 #include <sys/malloc.h>
78 #include <Pegasus/Common/String.h>
79 #include <Pegasus/Common/CIMName.h>
80 #include "cimmofParser.h"
81 #include "valueFactory.h"
83 #include "qualifierList.h"
86 //include any useful debugging stuff here
88 /* Debugging the parser. Debugging is provided through
89 1. debug functions in Bison that are controlled by a compile time
90 flag (YYDEBUG) and a runtime flag (yydebug) which is redefined
92 2. Debug functions defined through YACCTRACE, a macro defined
93 in cimmofparser.h and turned on and off manually.
94 All debugging must be turned on manually at this point by
95 setting the YYDEBUG compile flag and also setting YACCTRACE.
96 ATTN: TODO: automate the debug information flags.
98 // Enable this define to compie Bison/Yacc tracing
99 // ATTN: p3 03092003 ks Enabling this flag currently causes a compile error
102 //static int cimmof_debug;
104 //extern cimmofParser g_cimmofParser;
106 extern int cimmof_lex(void);
107 extern int cimmof_error(...);
108 extern char *cimmof_text;
109 extern void cimmof_yy_less(int n);
110 extern int cimmof_leng;
113 /* ------------------------------------------------------------------- */
114 /* These globals provide continuity between various pieces of a */
115 /* declaration. They are usually interpreted as "these modifiers were */
116 /* encountered and need to be applied to the finished object". For */
117 /* example, qualifiers are accumulated in g_qualifierList[] as they */
118 /* encountered, then applied to the production they qualify when it */
120 /* ------------------------------------------------------------------- */
121 CIMFlavor g_flavor = CIMFlavor (CIMFlavor::NONE);
122 CIMScope g_scope = CIMScope ();
123 //ATTN: BB 2001 BB P1 - Fixed size qualifier list max 20. Make larger or var
124 qualifierList g_qualifierList(20);
125 CIMMethod *g_currentMethod = 0;
126 CIMClass *g_currentClass = 0;
127 CIMInstance *g_currentInstance = 0;
128 String g_currentAliasRef; // Alias reference
129 String g_currentAliasDecl; // Alias declaration
130 CIMName g_referenceClassName = CIMName();
131 Array<CIMKeyBinding> g_KeyBindingArray; // it gets created empty
132 TYPED_INITIALIZER_VALUE g_typedInitializerValue;
134 /* ------------------------------------------------------------------- */
135 /* Pragmas, except for the Include pragma, are not handled yet */
136 /* I don't understand them, so it may be a while before they are */
137 /* ------------------------------------------------------------------- */
143 /* ---------------------------------------------------------------- */
144 /* Use our general wrap manager to handle end-of-file */
145 /* ---------------------------------------------------------------- */
149 return cimmofParser::Instance()->wrapCurrentBuffer();
153 /* ---------------------------------------------------------------- */
154 /* Pass errors to our general log manager. */
155 /* ---------------------------------------------------------------- */
157 cimmof_error(const char *msg) {
158 cimmofParser::Instance()->log_parse_error(cimmof_text, msg);
159 // printf("Error: %s\n", msg);
162 static void MOF_error(const char * str, const char * S);
163 static void MOF_trace(const char* str);
164 static void MOF_trace2(const char * str, const char * S);
172 CIMInstance *instance;
173 CIMKeyBinding *keybinding;
176 CIMObjectPath *reference;
177 CIMProperty *property;
178 CIMQualifier *qualifier;
179 CIMQualifierDecl *mofqualifier;
184 modelPath *modelpath;
187 struct pragma *pragma;
188 TYPED_INITIALIZER_VALUE *typedinitializer;
193 %token TOK_ALIAS_IDENTIFIER
196 %token TOK_ASSOCIATION
197 %token TOK_BINARY_VALUE
198 %token TOK_CHAR_VALUE
202 %token TOK_DISABLEOVERRIDE
207 %token TOK_DT_DATETIME
219 %token TOK_ENABLEOVERRIDE
220 %token TOK_END_OF_FILE
226 %token TOK_INDICATION
228 %token TOK_LEFTCURLYBRACE
230 %token TOK_LEFTSQUAREBRACKET
232 %token TOK_NULL_VALUE
233 %token TOK_OCTAL_VALUE
237 %token TOK_POSITIVE_DECIMAL_VALUE
241 %token TOK_REAL_VALUE
244 %token TOK_RESTRICTED
245 %token TOK_RIGHTCURLYBRACE
246 %token TOK_RIGHTPAREN
247 %token TOK_RIGHTSQUAREBRACKET
251 %token TOK_SIGNED_DECIMAL_VALUE
252 %token TOK_SIMPLE_IDENTIFIER
253 %token TOK_STRING_VALUE
254 %token TOK_TOSUBCLASS
255 %token TOK_TRANSLATABLE
257 %token TOK_UNEXPECTED_CHAR
260 %type <cimnameval> propertyName parameterName methodName className
261 %type <cimnameval> superClass
262 %type <datatype> dataType intDataType realDataType parameterType objectRef
263 %type <flavor> flavor defaultFlavor
264 %type <instance> instanceHead instanceDeclaration
266 %type <ival> booleanValue keyValuePairList
267 %type <keybinding> keyValuePair
268 %type <method> methodHead methodDeclaration
269 %type <modelpath> modelPath
270 %type <mofclass> classHead classDeclaration
271 %type <mofqualifier> qualifierDeclaration
272 %type <pragma> compilerDirectivePragma
273 %type <property> propertyBody propertyDeclaration referenceDeclaration
274 %type <qualifier> qualifier
275 %type <scope> scope metaElements metaElement
276 %type <strval> arrayInitializer constantValues
277 %type <strval> fileName referencedObject referenceName referencePath
278 %type <strval> integerValue TOK_REAL_VALUE TOK_CHAR_VALUE
279 %type <strval> namespaceHandle namespaceHandleRef
280 %type <strval> nonNullConstantValue
281 %type <strval> pragmaName pragmaVal keyValuePairName qualifierName
282 %type <strval> referenceInitializer objectHandle
283 %type <strval> aliasInitializer
284 %type <strval> aliasIdentifier
285 %type <strval> stringValue stringValues initializer constantValue
286 %type <strval> TOK_ALIAS_IDENTIFIER alias
287 %type <strval> TOK_POSITIVE_DECIMAL_VALUE TOK_OCTAL_VALUE TOK_HEX_VALUE
288 %type <strval> TOK_SIGNED_DECIMAL_VALUE TOK_BINARY_VALUE
289 %type <strval> TOK_SIMPLE_IDENTIFIER TOK_STRING_VALUE
290 %type <strval> TOK_UNEXPECTED_CHAR
291 %type <typedinitializer> typedInitializer typedDefaultValue
292 %type <typedinitializer> typedQualifierParameter
293 %type <value> qualifierValue
305 **------------------------------------------------------------------------------
307 ** Production rules section
309 **------------------------------------------------------------------------------
311 mofSpec: mofProductions ;
314 mofProductions: mofProduction mofProductions
318 // ATTN: P1 KS Apr 2002 Limit in (none) Directive handling. See FIXME below.
319 mofProduction: compilerDirective { /* FIXME: Where do we put directives? */ }
320 | qualifierDeclaration
321 { cimmofParser::Instance()->addQualifier($1); delete $1; }
323 { cimmofParser::Instance()->addClass($1); }
324 | instanceDeclaration
325 { cimmofParser::Instance()->addInstance($1); } ;
331 **------------------------------------------------------------------------------
333 ** class Declaration productions and processing
335 **------------------------------------------------------------------------------
337 classDeclaration: classHead classBody
339 YACCTRACE("classDeclaration");
340 if (g_currentAliasDecl != String::EMPTY)
341 cimmofParser::Instance()->addClassAlias(g_currentAliasDecl, $$, false);
345 classHead: qualifierList TOK_CLASS className alias superClass
347 // create new instance of class with className and superclassName
348 // put returned class object on stack
349 YACCTRACE("classHead:");
350 $$ = cimmofParser::Instance()->newClassDecl(*$3, *$5);
352 // put list of qualifiers into class
353 applyQualifierList(&g_qualifierList, $$);
355 g_currentAliasRef = *$4;
357 delete g_currentClass;
365 className: TOK_SIMPLE_IDENTIFIER {} ;
368 superClass: TOK_COLON className { $$ = new CIMName(*$2); }
369 | /* empty */ { $$ = new CIMName(); } ;
372 classBody: TOK_LEFTCURLYBRACE classFeatures TOK_RIGHTCURLYBRACE TOK_SEMICOLON
373 | TOK_LEFTCURLYBRACE TOK_RIGHTCURLYBRACE TOK_SEMICOLON ;
376 classFeatures: classFeature
377 | classFeatures classFeature ;
380 classFeature: propertyDeclaration {
381 YACCTRACE("classFeature:applyProperty");
382 cimmofParser::Instance()->applyProperty(*g_currentClass, *$1); delete $1; }
383 | methodDeclaration {
384 YACCTRACE("classFeature:applyMethod");
385 cimmofParser::Instance()->applyMethod(*g_currentClass, *$1); }
386 | referenceDeclaration {
387 YACCTRACE("classFeature:applyProperty");
388 cimmofParser::Instance()->applyProperty(*g_currentClass, *$1); delete $1; };
396 **------------------------------------------------------------------------------
398 ** method Declaration productions and processing.
400 **------------------------------------------------------------------------------
403 methodDeclaration: qualifierList methodHead methodBody methodEnd
405 YACCTRACE("methodDeclaration");
411 // methodHead processes the datatype and methodName and puts qualifierList.
412 // BUG 366. qualifier list was originally placed on in methoddeclaration
413 // which meant it might be overwritten by parameter qualifier lists.
414 methodHead: dataType methodName
416 YACCTRACE("methodHead");
418 delete g_currentMethod;
420 // create new method instance with pointer to method name and datatype
421 g_currentMethod = cimmofParser::Instance()->newMethod(*$2, $1) ;
423 // put new method on stack
424 $$ = g_currentMethod;
426 // apply the method qualifier list.
427 applyQualifierList(&g_qualifierList, $$);
433 methodBody: TOK_LEFTPAREN parameters TOK_RIGHTPAREN ;
436 methodEnd: TOK_SEMICOLON ;
439 methodName: TOK_SIMPLE_IDENTIFIER { $$ = new CIMName(*$1); } ;
443 // Productions for method parameters
445 parameters : parameter
446 | parameters TOK_COMMA parameter
450 parameter: qualifierList parameterType parameterName array
452 // ATTN: P2 2002 Question Need to create default value including type?
454 YACCTRACE("parameter:");
456 cimmofParser *cp = cimmofParser::Instance();
458 // Create new parameter with name, type, isArray, array, referenceClassName
460 p = cp->newParameter(*$3, $2, false, 0, g_referenceClassName);
462 p = cp->newParameter(*$3, $2, true, $4, g_referenceClassName);
465 g_referenceClassName = CIMName();
467 YACCTRACE("parameter:applyQualifierList");
468 applyQualifierList(&g_qualifierList, p);
470 cp->applyParameter(*g_currentMethod, *p);
476 parameterType: dataType { $$ = $1; }
477 | objectRef { $$ = CIMTYPE_REFERENCE; } ;
485 **------------------------------------------------------------------------------
487 ** property Declaration productions and processing
489 **------------------------------------------------------------------------------
492 propertyDeclaration: qualifierList propertyBody propertyEnd
494 // set body to stack and apply qualifier list
495 // ATTN: the apply qualifer only works here because
496 // there are not lower level qualifiers. We do productions
497 // that might have lower level qualifiers differently by
498 // setting up a xxxHead production where qualifiers are
500 YACCTRACE("propertyDeclaration:");
502 applyQualifierList(&g_qualifierList, $$);
506 propertyBody: dataType propertyName array typedDefaultValue
508 CIMValue *v = valueFactory::createValue($1, $3,
509 ($4->type == CIMMOF_NULL_VALUE), $4->value);
511 $$ = cimmofParser::Instance()->newProperty(*$2, *v, false, 0);
513 $$ = cimmofParser::Instance()->newProperty(*$2, *v, true, $3);
522 propertyEnd: TOK_SEMICOLON ;
530 **------------------------------------------------------------------------------
532 ** reference Declaration productions and processing
534 **------------------------------------------------------------------------------
537 referenceDeclaration: qualifierList referencedObject TOK_REF referenceName
538 referencePath TOK_SEMICOLON
541 if (!String::equal(*$5, String::EMPTY))
543 CIMValue *v = valueFactory::createValue(CIMTYPE_REFERENCE, -1, true, &s);
544 //KS add the isArray and arraysize parameters. 8 mar 2002
545 $$ = cimmofParser::Instance()->newProperty(*$4, *v, false,0, *$2);
546 applyQualifierList(&g_qualifierList, $$);
554 referencedObject: TOK_SIMPLE_IDENTIFIER { $$ = $1; } ;
557 referenceName: TOK_SIMPLE_IDENTIFIER { $$ = $1; };
560 referencePath: TOK_EQUAL stringValue { $$ = $2; }
561 | /* empty */ { $$ = new String(String::EMPTY); } ;
564 objectRef: className TOK_REF {
565 g_referenceClassName = *$1; } ;
568 parameterName: TOK_SIMPLE_IDENTIFIER { $$ = new CIMName(*$1); } ;
571 propertyName: TOK_SIMPLE_IDENTIFIER { $$ = new CIMName(*$1); } ;
574 array: TOK_LEFTSQUAREBRACKET TOK_POSITIVE_DECIMAL_VALUE
575 TOK_RIGHTSQUAREBRACKET
576 { $$ = valueFactory::Stoi(*$2);
579 | TOK_LEFTSQUAREBRACKET TOK_RIGHTSQUAREBRACKET { $$ = 0; }
580 | /* empty */ { $$ = -1; } ;
583 typedDefaultValue: TOK_EQUAL typedInitializer { $$ = $2; }
585 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
586 g_typedInitializerValue.value = new String(String::EMPTY);
587 $$ = &g_typedInitializerValue;
591 initializer: constantValue { $$ = $1; }
592 | arrayInitializer { $$ = $1; }
593 | referenceInitializer { $$ = $1; } ;
596 // The typedInitializer element is syntactially identical to
597 // the initializer element. However, the typedInitializer element
598 // returns, in addition to the value, the type of the value.
599 typedInitializer: nonNullConstantValue
601 g_typedInitializerValue.type = CIMMOF_CONSTANT_VALUE;
602 g_typedInitializerValue.value = $1;
603 $$ = &g_typedInitializerValue;
607 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
608 g_typedInitializerValue.value = new String(String::EMPTY);
609 $$ = &g_typedInitializerValue;
613 g_typedInitializerValue.type = CIMMOF_ARRAY_VALUE;
614 g_typedInitializerValue.value = $1;
615 $$ = &g_typedInitializerValue;
617 | referenceInitializer
619 g_typedInitializerValue.type = CIMMOF_REFERENCE_VALUE;
620 g_typedInitializerValue.value = $1;
621 $$ = &g_typedInitializerValue;
625 // BUG 497 - Commmas embedded in strings in arrays change the
626 // strings. Aded function stringWComma to escape commas.
627 constantValues: constantValue {
628 *$$ = valueFactory::stringWComma(String(*$1)); }
629 | constantValues TOK_COMMA constantValue
631 YACCTRACE("constantValues:1, Value= " << *$3);
634 (*$$).append(valueFactory::stringWComma(String(*$3)));
639 // The nonNullConstantValue has been added to allow NULL
640 // to be distinguished from the EMPTY STRING.
642 constantValue: nonNullConstantValue {$$ = $1;}
643 | TOK_NULL_VALUE { $$ = new String(String::EMPTY); } ;
646 nonNullConstantValue: integerValue { $$ = $1; }
647 | TOK_REAL_VALUE { $$ = $1; }
648 | TOK_CHAR_VALUE { $$ = $1; }
650 | booleanValue { $$ = new String($1 ? "T" : "F"); };
653 integerValue: TOK_POSITIVE_DECIMAL_VALUE
654 | TOK_SIGNED_DECIMAL_VALUE
656 $$ = new String(cimmofParser::Instance()->oct_to_dec(*$1));
659 $$ = new String(cimmofParser::Instance()->hex_to_dec(*$1));
662 $$ = new String(cimmofParser::Instance()->binary_to_dec(*$1));
666 booleanValue: TOK_FALSE { $$ = 0; }
667 | TOK_TRUE { $$ = 1; } ;
670 stringValues: stringValue { $$ = $1; }
671 | stringValues stringValue
673 (*$$).append(*$2); delete $2;
677 stringValue: TOK_STRING_VALUE
679 //String oldrep = *$1;
680 //String s(oldrep), s1(String::EMPTY);
681 // Handle quoted quote
682 //int len = s.size();
683 //if (s[len] == '\n') {
684 //error: new line inside a string constant unless it is quoted
685 //if (s[len - 2] == '\\') {
687 //s1 = s.subString(1, len-3);
689 //cimmof_error("New line in string constant");
691 //cimmofParser::Instance()->increment_lineno();
692 //} else { // Can only be a quotation mark
693 //if (s[len - 2] == '\\') { // if it is quoted
694 //if (len > 3) s1 = s.subString(1, len-3);
696 //cimmof_yy_less(len-1);
697 //} else { // This is the normal case: real quotes on both end
698 //s1 = s.subString(1, len - 2) ;
702 $$ = //new String(s1);
709 TOK_LEFTCURLYBRACE constantValues TOK_RIGHTCURLYBRACE
711 | TOK_LEFTCURLYBRACE TOK_RIGHTCURLYBRACE
712 { $$ = new String(String::EMPTY); };
715 referenceInitializer: objectHandle {}
716 | aliasInitializer { } ;
719 objectHandle: TOK_DQUOTE namespaceHandleRef modelPath TOK_DQUOTE
721 // The objectName string is decomposed for syntactical purposes
722 // and reassembled here for later parsing in creation of an objname instance
723 String *s = new String(*$2);
724 if (!String::equal(*s, String::EMPTY) && $3)
727 (*s).append($3->Stringrep());
732 MOF_trace2 ("objectHandle done $$ = ", $$->getCString());
736 aliasInitializer : aliasIdentifier {
740 MOF_trace2("aliasInitializer $$ = ", $$->getCString());
741 MOF_trace2("aliasInitializer $1 = ", $1->getCString());
743 g_currentAliasRef = *$$;
745 MOF_trace2("aliasInitializer g_currentAliasRef = ", g_currentAliasRef.getCString());
746 if (cimmofParser::Instance()->getInstanceAlias(g_currentAliasRef, AOP) == 0)
748 yyerror("aliasInitializer - 'aliasIdentifier' NOT FOUND");
752 String *s = new String(AOP.toString());
758 MOF_trace2 ("aliasInitializer done $$ = ", $$->getCString());
763 namespaceHandleRef: namespaceHandle TOK_COLON
765 | /* empty */ { $$ = new String(String::EMPTY); };
768 namespaceHandle: stringValue {};
771 modelPath: className TOK_PERIOD keyValuePairList {
772 modelPath *m = new modelPath((*$1).getString(), g_KeyBindingArray);
773 g_KeyBindingArray.clear();
777 keyValuePairList: keyValuePair { $$ = 0; }
778 | keyValuePairList TOK_COMMA keyValuePair { $$ = 0; } ;
781 keyValuePair: keyValuePairName TOK_EQUAL initializer
783 CIMKeyBinding *kb = new CIMKeyBinding(*$1, *$3,
784 modelPath::KeyBindingTypeOf(*$3));
785 g_KeyBindingArray.append(*kb);
791 keyValuePairName: TOK_SIMPLE_IDENTIFIER ;
794 alias: TOK_AS aliasIdentifier {
796 g_currentAliasDecl = *$2;
797 MOF_trace2("aliasIdentifier $$ = ", $$->getCString());
798 MOF_trace2("aliasIdentifier g_currentAliasDecl = ", g_currentAliasDecl.getCString());
802 $$ = new String(String::EMPTY);
803 g_currentAliasDecl = String::EMPTY}
807 aliasIdentifier: TOK_ALIAS_IDENTIFIER ;
811 **------------------------------------------------------------------------------
813 ** Instance Declaration productions and processing
815 **-----------------------------------------------------------------------------
818 instanceDeclaration: instanceHead instanceBody
820 $$ = g_currentInstance;
821 if (g_currentAliasDecl != String::EMPTY)
823 MOF_trace2("instanceDeclaration g_currentAliasDecl = ", g_currentAliasDecl.getCString());
824 // MOF_trace2 ("instanceDeclaration instance = ", ((CIMObject *)$$)->toString().getCString());
825 if (cimmofParser::Instance()->addInstanceAlias(g_currentAliasDecl, $$, true) == 0)
827 // Error alias already exist
828 MOF_error("ERROR: alias ALREADY EXISTS: aliasIdentifier = ",
829 g_currentAliasDecl.getCString());
830 yyerror("instanceDeclaration - 'aliasIdentifier' ALREADY EXISTS");
838 instanceHead: qualifierList TOK_INSTANCE TOK_OF className alias
840 if (g_currentInstance)
841 delete g_currentInstance;
842 g_currentAliasDecl = *$5;
843 g_currentInstance = cimmofParser::Instance()->newInstance(*$4);
844 // apply the qualifierlist to the current instance
845 $$ = g_currentInstance;
846 applyQualifierList(&g_qualifierList, $$);
849 if (g_currentAliasDecl != String::EMPTY)
850 MOF_trace2("instanceHead g_currentAliasDecl = ", g_currentAliasDecl.getCString());
855 instanceBody: TOK_LEFTCURLYBRACE valueInitializers TOK_RIGHTCURLYBRACE
860 valueInitializers: valueInitializer
861 | valueInitializers valueInitializer ;
865 // ATTN-DE-P1-20020427: Processing NULL Initializer values is incomplete.
866 // Currently only the arrayInitializer element has been modified to
867 // return CIMMOF_NULL_VALUE
868 valueInitializer: qualifierList TOK_SIMPLE_IDENTIFIER TOK_EQUAL
869 typedInitializer TOK_SEMICOLON
871 cimmofParser *cp = cimmofParser::Instance();
872 // ATTN: P1 InstanceUpdate function 2001 BB Instance update needs work here and CIMOM
873 // a property. It must be fixed in the Common code first.
874 // What we have to do here is create a CIMProperty and initialize it with
875 // the value provided. The name of the property is $2 and it belongs
876 // to the class whose name is in g_currentInstance->getClassName().
878 // 2. Get property declaration's value object
879 CIMProperty *oldprop = cp->PropertyFromInstance(*g_currentInstance,
881 CIMValue *oldv = cp->ValueFromProperty(*oldprop);
883 // 3. create the new Value object of the same type
885 // We want createValue to interpret a value as an array if is enclosed
886 // in {}s (e.g., { 2 } or {2, 3, 5}) or it is NULL and the property is
887 // defined as an array. createValue is responsible for the actual
890 CIMValue *v = valueFactory::createValue(oldv->getType(),
891 (($4->type == CIMMOF_ARRAY_VALUE) |
892 (($4->type == CIMMOF_NULL_VALUE) & oldprop->isArray()))?0:-1,
893 ($4->type == CIMMOF_NULL_VALUE),
897 // 4. create a clone property with the new value
898 CIMProperty *newprop = cp->copyPropertyWithNewValue(*oldprop, *v);
900 // 5. apply the qualifiers;
901 applyQualifierList(&g_qualifierList, newprop);
903 // 6. and apply the CIMProperty to g_currentInstance.
904 cp->applyProperty(*g_currentInstance, *newprop);
918 **------------------------------------------------------------------------------
920 ** Compiler directive productions and processing
922 **------------------------------------------------------------------------------
925 compilerDirective: compilerDirectiveInclude
927 //printf("compilerDirectiveInclude ");
929 | compilerDirectivePragma
931 //printf("compilerDirectivePragma ");
935 compilerDirectiveInclude: TOK_PRAGMA TOK_INCLUDE TOK_LEFTPAREN fileName
938 cimmofParser::Instance()->enterInlineInclude(*$4); delete $4;
942 fileName: stringValue { $$ = $1; } ;
945 compilerDirectivePragma: TOK_PRAGMA pragmaName
946 TOK_LEFTPAREN pragmaVal TOK_RIGHTPAREN
947 { cimmofParser::Instance()->processPragma(*$2, *$4);
956 **------------------------------------------------------------------------------
958 ** qualifier Declaration productions and processing
960 **------------------------------------------------------------------------------
963 qualifierDeclaration: TOK_QUALIFIER qualifierName qualifierValue scope
964 defaultFlavor TOK_SEMICOLON
966 // CIMQualifierDecl *qd = new CIMQualifierDecl($2, $3, $4, $5);
967 $$ = cimmofParser::Instance()->newQualifierDecl(*$2, $3, *$4, *$5);
969 delete $3; // CIMValue object created in qualifierValue production
973 qualifierValue: TOK_COLON dataType array typedDefaultValue
975 $$ = valueFactory::createValue($2, $3,
976 $4->type == CIMMOF_NULL_VALUE, $4->value);
981 scope: scope_begin metaElements TOK_RIGHTPAREN { $$ = $2; } ;
984 scope_begin: TOK_COMMA TOK_SCOPE TOK_LEFTPAREN {
985 g_scope = CIMScope (CIMScope::NONE); } ;
988 metaElements: metaElement { $$ = $1; }
989 | metaElements TOK_COMMA metaElement
990 { $$->addScope(*$3); } ;
991 // ATTN: 2001 P3 defer There is not CIMScope::SCHEMA. Spec Limit KS
994 metaElement: TOK_CLASS { $$ = new CIMScope(CIMScope::CLASS); }
995 // | TOK_SCHEMA { $$ = new CIMScope(CIMScope::SCHEMA); }
996 | TOK_SCHEMA { $$ = new CIMScope(CIMScope::CLASS); }
997 | TOK_ASSOCIATION { $$ = new CIMScope(CIMScope::ASSOCIATION); }
998 | TOK_INDICATION { $$ = new CIMScope(CIMScope::INDICATION); }
999 // | TOK_QUALIFIER { $$ = new CIMScope(CIMScope::QUALIFIER); }
1000 | TOK_PROPERTY { $$ = new CIMScope(CIMScope::PROPERTY); }
1001 | TOK_REFERENCE { $$ = new CIMScope(CIMScope::REFERENCE); }
1002 | TOK_METHOD { $$ = new CIMScope(CIMScope::METHOD); }
1003 | TOK_PARAMETER { $$ = new CIMScope(CIMScope::PARAMETER); }
1004 | TOK_ANY { $$ = new CIMScope(CIMScope::ANY); } ;
1007 // Correction KS 4 march 2002 - Set the default if empty
1008 defaultFlavor: TOK_COMMA flavorHead explicitFlavors TOK_RIGHTPAREN
1010 | /* empty */ { $$ = new CIMFlavor (CIMFlavor::NONE); } ;
1013 // Correction KS 4 March 2002 - set the defaults (was zero)
1014 // Set the flavors for the defaults required: via DEFAULTS
1016 flavorHead: TOK_FLAVOR TOK_LEFTPAREN {g_flavor = CIMFlavor (CIMFlavor::NONE);};
1019 explicitFlavors: explicitFlavor
1020 | explicitFlavors TOK_COMMA explicitFlavor ;
1023 // ATTN:KS-26/03/02 P2 This accumulates the flavor definitions. However, it allows multiple instances
1024 // of any keyword. Note also that each entity simply sets a bit so that you may
1025 // set disable and enable and we will not know which overrides the other.
1026 // We need to create the function to insure that you cannot enable then disable or
1027 // accept the latter and override the former.
1029 // The compiler simply provides the flavors defined in the MOF and does not make any
1030 // assumptions about defaults, etc. That is a problem for resolution of the flavors.
1032 explicitFlavor: TOK_ENABLEOVERRIDE
1033 { g_flavor.addFlavor (CIMFlavor::ENABLEOVERRIDE); }
1034 | TOK_DISABLEOVERRIDE { g_flavor.addFlavor (CIMFlavor::DISABLEOVERRIDE); }
1035 | TOK_RESTRICTED { g_flavor.addFlavor (CIMFlavor::RESTRICTED); }
1036 | TOK_TOSUBCLASS { g_flavor.addFlavor (CIMFlavor::TOSUBELEMENTS); }
1037 | TOK_TRANSLATABLE { g_flavor.addFlavor (CIMFlavor::TRANSLATABLE); };
1040 flavor: overrideFlavors { $$ = &g_flavor; }
1041 | /* empty */ { $$ = new CIMFlavor (CIMFlavor::NONE); };
1044 overrideFlavors: explicitFlavor
1045 | overrideFlavors explicitFlavor ;
1049 dataType: intDataType { $$ = $1; }
1050 | realDataType { $$ = $1; }
1051 | TOK_DT_STR { $$ = CIMTYPE_STRING; }
1052 | TOK_DT_BOOL { $$ = CIMTYPE_BOOLEAN; }
1053 | TOK_DT_DATETIME { $$ = CIMTYPE_DATETIME; } ;
1056 intDataType: TOK_DT_UINT8 { $$ = CIMTYPE_UINT8; }
1057 | TOK_DT_SINT8 { $$ = CIMTYPE_SINT8; }
1058 | TOK_DT_UINT16 { $$ = CIMTYPE_UINT16; }
1059 | TOK_DT_SINT16 { $$ = CIMTYPE_SINT16; }
1060 | TOK_DT_UINT32 { $$ = CIMTYPE_UINT32; }
1061 | TOK_DT_SINT32 { $$ = CIMTYPE_SINT32; }
1062 | TOK_DT_UINT64 { $$ = CIMTYPE_UINT64; }
1063 | TOK_DT_SINT64 { $$ = CIMTYPE_SINT64; }
1064 | TOK_DT_CHAR16 { $$ = CIMTYPE_CHAR16; } ;
1067 realDataType: TOK_DT_REAL32 { $$ =CIMTYPE_REAL32; }
1068 | TOK_DT_REAL64 { $$ =CIMTYPE_REAL64; };
1074 **------------------------------------------------------------------------------
1076 ** Qualifier list and qualifier processing
1078 **------------------------------------------------------------------------------
1080 qualifierList: qualifierListBegin qualifiers TOK_RIGHTSQUAREBRACKET
1082 //yydebug = 1; stderr = stdout;
1087 qualifierListBegin: TOK_LEFTSQUAREBRACKET {
1089 //yydebug = 1; stderr = stdout;
1090 YACCTRACE("qualifierListbegin");
1091 g_qualifierList.init(); } ;
1095 qualifiers: qualifier { }
1096 | qualifiers TOK_COMMA qualifier { } ;
1100 qualifier: qualifierName typedQualifierParameter flavor
1102 cimmofParser *p = cimmofParser::Instance();
1103 // The qualifier value can't be set until we know the contents of the
1104 // QualifierDeclaration. That's what QualifierValue() does.
1105 CIMValue *v = p->QualifierValue(*$1,
1106 ($2->type == CIMMOF_NULL_VALUE), *$2->value);
1107 $$ = p->newQualifier(*$1, *v, g_flavor);
1108 g_qualifierList.add($$);
1116 qualifierName: TOK_SIMPLE_IDENTIFIER {
1117 g_flavor = CIMFlavor (CIMFlavor::NONE); }
1119 $$ = new String((*$1).toString ());
1120 g_flavor = CIMFlavor (CIMFlavor::NONE); } ;
1124 typedQualifierParameter: TOK_LEFTPAREN nonNullConstantValue TOK_RIGHTPAREN
1126 g_typedInitializerValue.type = CIMMOF_CONSTANT_VALUE;
1127 g_typedInitializerValue.value = $2;
1128 $$ = &g_typedInitializerValue;
1130 | TOK_LEFTPAREN TOK_NULL_VALUE TOK_RIGHTPAREN
1132 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
1133 g_typedInitializerValue.value = new String(String::EMPTY);
1134 $$ = &g_typedInitializerValue;
1138 g_typedInitializerValue.type = CIMMOF_ARRAY_VALUE;
1139 g_typedInitializerValue.value = $1;
1140 $$ = &g_typedInitializerValue;
1143 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
1144 g_typedInitializerValue.value = new String(String::EMPTY);
1145 $$ = &g_typedInitializerValue;
1149 pragmaName: TOK_SIMPLE_IDENTIFIER { $$ = $1; } ;
1152 pragmaVal: TOK_STRING_VALUE { $$ = $1; } ;
1157 **==============================================================================
1161 **==============================================================================
1163 static void MOF_error(const char * str, const char * S)
1165 printf("%s %s\n", str, S);
1169 **==============================================================================
1173 **==============================================================================
1175 // #define DEBUG_cimmof 1
1177 static void MOF_trace(const char* str)
1180 printf("MOF_trace(): %s \n", str);
1181 #endif // DEBUG_cimmof
1184 static void MOF_trace2(const char * str, const char * S)
1187 printf("MOF_trace2(): %s %s\n", str, S);
1188 #endif // DEBUG_cimmof