📄 cimmof.y
字号:
$$ = $2; g_currentAliasDecl = *$2; MOF_trace2("aliasIdentifier $$ = ", $$->getCString()); MOF_trace2("aliasIdentifier g_currentAliasDecl = ", g_currentAliasDecl.getCString()); } | /* empty */ { $$ = new String(String::EMPTY); g_currentAliasDecl = String::EMPTY} ;aliasIdentifier: TOK_ALIAS_IDENTIFIER ;/***------------------------------------------------------------------------------**** Instance Declaration productions and processing****-----------------------------------------------------------------------------*/instanceDeclaration: instanceHead instanceBody{ $$ = g_currentInstance; if (g_currentAliasDecl != String::EMPTY) { MOF_trace2("instanceDeclaration g_currentAliasDecl = ", g_currentAliasDecl.getCString()); // MOF_trace2 ("instanceDeclaration instance = ", ((CIMObject *)$$)->toString().getCString()); if (cimmofParser::Instance()->addInstanceAlias(g_currentAliasDecl, $$, true) == 0) { // Error alias already exist MOF_error("ERROR: alias ALREADY EXISTS: aliasIdentifier = ", g_currentAliasDecl.getCString()); yyerror("instanceDeclaration - 'aliasIdentifier' ALREADY EXISTS"); YYABORT; } }};instanceHead: qualifierList TOK_INSTANCE TOK_OF className alias { if (g_currentInstance) delete g_currentInstance; g_currentAliasDecl = *$5; g_currentInstance = cimmofParser::Instance()->newInstance(*$4); // apply the qualifierlist to the current instance $$ = g_currentInstance; applyQualifierList(&g_qualifierList, $$); delete $4; delete $5; if (g_currentAliasDecl != String::EMPTY) MOF_trace2("instanceHead g_currentAliasDecl = ", g_currentAliasDecl.getCString());} ;instanceBody: TOK_LEFTCURLYBRACE valueInitializers TOK_RIGHTCURLYBRACE TOK_SEMICOLON ;valueInitializers: valueInitializer | valueInitializers valueInitializer ;// ATTN-DE-P1-20020427: Processing NULL Initializer values is incomplete.// Currently only the arrayInitializer element has been modified to // return CIMMOF_NULL_VALUEvalueInitializer: qualifierList TOK_SIMPLE_IDENTIFIER TOK_EQUAL typedInitializer TOK_SEMICOLON { cimmofParser *cp = cimmofParser::Instance(); // ATTN: P1 InstanceUpdate function 2001 BB Instance update needs work here and CIMOM // a property. It must be fixed in the Common code first. // What we have to do here is create a CIMProperty and initialize it with // the value provided. The name of the property is $2 and it belongs // to the class whose name is in g_currentInstance->getClassName(). // The steps are // 2. Get property declaration's value object CIMProperty *oldprop = cp->PropertyFromInstance(*g_currentInstance, *$2); CIMValue *oldv = cp->ValueFromProperty(*oldprop); // 3. create the new Value object of the same type // We want createValue to interpret a value as an array if is enclosed // in {}s (e.g., { 2 } or {2, 3, 5}) or it is NULL and the property is // defined as an array. createValue is responsible for the actual // validation. CIMValue *v = valueFactory::createValue(oldv->getType(), (($4->type == CIMMOF_ARRAY_VALUE) | (($4->type == CIMMOF_NULL_VALUE) & oldprop->isArray()))?0:-1, ($4->type == CIMMOF_NULL_VALUE), $4->value); // 4. create a clone property with the new value CIMProperty *newprop = cp->copyPropertyWithNewValue(*oldprop, *v); // 5. apply the qualifiers; applyQualifierList(&g_qualifierList, newprop); // 6. and apply the CIMProperty to g_currentInstance. cp->applyProperty(*g_currentInstance, *newprop); delete $2; delete $4->value; delete oldprop; delete oldv; delete v; delete newprop;};/***------------------------------------------------------------------------------**** Compiler directive productions and processing****------------------------------------------------------------------------------*/compilerDirective: compilerDirectiveInclude{ //printf("compilerDirectiveInclude "); } | compilerDirectivePragma{ //printf("compilerDirectivePragma ");} ;compilerDirectiveInclude: TOK_PRAGMA TOK_INCLUDE TOK_LEFTPAREN fileName TOK_RIGHTPAREN { cimmofParser::Instance()->enterInlineInclude(*$4); delete $4;};fileName: stringValue { $$ = $1; } ;compilerDirectivePragma: TOK_PRAGMA pragmaName TOK_LEFTPAREN pragmaVal TOK_RIGHTPAREN { cimmofParser::Instance()->processPragma(*$2, *$4); delete $2; delete $4; };/***------------------------------------------------------------------------------**** qualifier Declaration productions and processing****------------------------------------------------------------------------------*/qualifierDeclaration: TOK_QUALIFIER qualifierName qualifierValue scope defaultFlavor TOK_SEMICOLON {// CIMQualifierDecl *qd = new CIMQualifierDecl($2, $3, $4, $5); $$ = cimmofParser::Instance()->newQualifierDecl(*$2, $3, *$4, *$5); delete $2; delete $3; // CIMValue object created in qualifierValue production} ;qualifierValue: TOK_COLON dataType array typedDefaultValue{ $$ = valueFactory::createValue($2, $3, $4->type == CIMMOF_NULL_VALUE, $4->value); delete $4->value;} ;scope: scope_begin metaElements TOK_RIGHTPAREN { $$ = $2; } ;scope_begin: TOK_COMMA TOK_SCOPE TOK_LEFTPAREN { g_scope = CIMScope (CIMScope::NONE); } ;metaElements: metaElement { $$ = $1; } | metaElements TOK_COMMA metaElement { $$->addScope(*$3); } ;// ATTN: 2001 P3 defer There is not CIMScope::SCHEMA. Spec Limit KSmetaElement: TOK_CLASS { $$ = new CIMScope(CIMScope::CLASS); }// | TOK_SCHEMA { $$ = new CIMScope(CIMScope::SCHEMA); } | TOK_SCHEMA { $$ = new CIMScope(CIMScope::CLASS); } | TOK_ASSOCIATION { $$ = new CIMScope(CIMScope::ASSOCIATION); } | TOK_INDICATION { $$ = new CIMScope(CIMScope::INDICATION); }// | TOK_QUALIFIER { $$ = new CIMScope(CIMScope::QUALIFIER); } | TOK_PROPERTY { $$ = new CIMScope(CIMScope::PROPERTY); } | TOK_REFERENCE { $$ = new CIMScope(CIMScope::REFERENCE); } | TOK_METHOD { $$ = new CIMScope(CIMScope::METHOD); } | TOK_PARAMETER { $$ = new CIMScope(CIMScope::PARAMETER); } | TOK_ANY { $$ = new CIMScope(CIMScope::ANY); } ;// Correction KS 4 march 2002 - Set the default if emptydefaultFlavor: TOK_COMMA flavorHead explicitFlavors TOK_RIGHTPAREN { $$ = &g_flavor; } | /* empty */ { $$ = new CIMFlavor (CIMFlavor::NONE); } ;// Correction KS 4 March 2002 - set the defaults (was zero)// Set the flavors for the defaults required: via DEFAULTSflavorHead: TOK_FLAVOR TOK_LEFTPAREN {g_flavor = CIMFlavor (CIMFlavor::NONE);};explicitFlavors: explicitFlavor | explicitFlavors TOK_COMMA explicitFlavor ;// ATTN:KS-26/03/02 P2 This accumulates the flavor definitions. However, it allows multiple instances// of any keyword. Note also that each entity simply sets a bit so that you may// set disable and enable and we will not know which overrides the other.// We need to create the function to insure that you cannot enable then disable or// accept the latter and override the former.// The compiler simply provides the flavors defined in the MOF and does not make any// assumptions about defaults, etc. That is a problem for resolution of the flavors.explicitFlavor: TOK_ENABLEOVERRIDE { g_flavor.addFlavor (CIMFlavor::ENABLEOVERRIDE); } | TOK_DISABLEOVERRIDE { g_flavor.addFlavor (CIMFlavor::DISABLEOVERRIDE); } | TOK_RESTRICTED { g_flavor.addFlavor (CIMFlavor::RESTRICTED); } | TOK_TOSUBCLASS { g_flavor.addFlavor (CIMFlavor::TOSUBELEMENTS); } | TOK_TRANSLATABLE { g_flavor.addFlavor (CIMFlavor::TRANSLATABLE); };flavor: overrideFlavors { $$ = &g_flavor; } | /* empty */ { $$ = new CIMFlavor (CIMFlavor::NONE); };overrideFlavors: explicitFlavor | overrideFlavors explicitFlavor ;dataType: intDataType { $$ = $1; } | realDataType { $$ = $1; } | TOK_DT_STR { $$ = CIMTYPE_STRING; } | TOK_DT_BOOL { $$ = CIMTYPE_BOOLEAN; } | TOK_DT_DATETIME { $$ = CIMTYPE_DATETIME; } ;intDataType: TOK_DT_UINT8 { $$ = CIMTYPE_UINT8; } | TOK_DT_SINT8 { $$ = CIMTYPE_SINT8; } | TOK_DT_UINT16 { $$ = CIMTYPE_UINT16; } | TOK_DT_SINT16 { $$ = CIMTYPE_SINT16; } | TOK_DT_UINT32 { $$ = CIMTYPE_UINT32; } | TOK_DT_SINT32 { $$ = CIMTYPE_SINT32; } | TOK_DT_UINT64 { $$ = CIMTYPE_UINT64; } | TOK_DT_SINT64 { $$ = CIMTYPE_SINT64; } | TOK_DT_CHAR16 { $$ = CIMTYPE_CHAR16; } ;realDataType: TOK_DT_REAL32 { $$ =CIMTYPE_REAL32; } | TOK_DT_REAL64 { $$ =CIMTYPE_REAL64; };/***------------------------------------------------------------------------------**** Qualifier list and qualifier processing****------------------------------------------------------------------------------*/qualifierList: qualifierListBegin qualifiers TOK_RIGHTSQUAREBRACKET | /* empty */ { //yydebug = 1; stderr = stdout; };qualifierListBegin: TOK_LEFTSQUAREBRACKET { //yydebug = 1; stderr = stdout; YACCTRACE("qualifierListbegin"); g_qualifierList.init(); } ;qualifiers: qualifier { } | qualifiers TOK_COMMA qualifier { } ;qualifier: qualifierName typedQualifierParameter flavor{ cimmofParser *p = cimmofParser::Instance(); // The qualifier value can't be set until we know the contents of the // QualifierDeclaration. That's what QualifierValue() does. CIMValue *v = p->QualifierValue(*$1, ($2->type == CIMMOF_NULL_VALUE), *$2->value); $$ = p->newQualifier(*$1, *v, g_flavor); g_qualifierList.add($$); delete $1; delete $2->value; delete v; } ;qualifierName: TOK_SIMPLE_IDENTIFIER { g_flavor = CIMFlavor (CIMFlavor::NONE); } | metaElement { $$ = new String((*$1).toString ()); g_flavor = CIMFlavor (CIMFlavor::NONE); } ;typedQualifierParameter: TOK_LEFTPAREN nonNullConstantValue TOK_RIGHTPAREN { g_typedInitializerValue.type = CIMMOF_CONSTANT_VALUE; g_typedInitializerValue.value = $2; $$ = &g_typedInitializerValue; } | TOK_LEFTPAREN TOK_NULL_VALUE TOK_RIGHTPAREN { g_typedInitializerValue.type = CIMMOF_NULL_VALUE; g_typedInitializerValue.value = new String(String::EMPTY); $$ = &g_typedInitializerValue; } | arrayInitializer { g_typedInitializerValue.type = CIMMOF_ARRAY_VALUE; g_typedInitializerValue.value = $1; $$ = &g_typedInitializerValue; } | { /* empty */ g_typedInitializerValue.type = CIMMOF_NULL_VALUE; g_typedInitializerValue.value = new String(String::EMPTY); $$ = &g_typedInitializerValue; };pragmaName: TOK_SIMPLE_IDENTIFIER { $$ = $1; } ;pragmaVal: TOK_STRING_VALUE { $$ = $1; } ;%%/***==============================================================================**** MOF_error():****==============================================================================*/static void MOF_error(const char * str, const char * S){ printf("%s %s\n", str, S);}/***==============================================================================**** MOF_trace():****==============================================================================*/// #define DEBUG_cimmof 1static void MOF_trace(const char* str){#ifdef DEBUG_cimmof printf("MOF_trace(): %s \n", str);#endif // DEBUG_cimmof}static void MOF_trace2(const char * str, const char * S){#ifdef DEBUG_cimmof printf("MOF_trace2(): %s %s\n", str, S);#endif // DEBUG_cimmof}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -