⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cimmof.y

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 Y
📖 第 1 页 / 共 3 页
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions:// // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================%{  /* Flex grammar created from CIM Specification Version 2.2 Appendix A */  /*     Note the following implementation details:       1. The MOF specification has a production of type assocDeclaration,       but an association is just a type of classDeclaration with a few       special rules.  At least for the first pass, I'm treating an       associationDeclaration as a classDeclaration and applying its       syntactical rules outside of the grammar definition.       2. Same with the indicationDeclaration.  It appears to be a normal       classDeclaration with the INDICATION qualifier and no special       syntactical rules.       3. The Parser uses String objects throughout to represent       character data.  However, the tokenizer underneath is probably       working with 8-bit chars.  If we later use an extended character       compatible tokenizer, I anticipate NO CHANGE to this parser.       4. Besides the tokenizer, this parser uses 2 sets of outside       services:          1)Class valueFactory.  This has a couple of static methods	  that assist in creating CIMValue objects from Strings.	  2)Class cimmofParser.  This has a wide variety of methods	  that fall into these catagories:            a) Interfaces to the Repository.  You call cimmofParser::            methods to query and store compiled CIM elements.	    b) Error handling.            c) Data format conversions.            d) Tokenizer manipulation            e) Pragma handling            f) Alias Handling  */#define YYSTACKSIZE 2000#include <cstdlib>#if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && !defined(__OS400__) && !defined(PEGASUS_OS_VMS)#if defined(PEGASUS_OS_DARWIN)#include <sys/malloc.h>#else#include <malloc.h>#endif#endif#include <cstdio>#include <cstring>#include <Pegasus/Common/String.h>#include <Pegasus/Common/CIMName.h>#include "cimmofParser.h"#include "valueFactory.h"#include "memobjs.h"#include "qualifierList.h"#include "objname.h"//include any useful debugging stuff here/* Debugging the parser.  Debugging is provided through   1. debug functions in Bison that are controlled by a compile time      flag (YYDEBUG) and a runtime flag (yydebug) which is redefined      to cimmof_debug.   2. Debug functions defined through YACCTRACE, a macro defined      in cimmofparser.h and turned on and off manually.   All debugging must be turned on manually at this point by   setting the YYDEBUG compile flag and also setting YACCTRACE.   ATTN: TODO: automate the debug information flags.*/// Enable this define to compie Bison/Yacc tracing// ATTN: p3 03092003 ks Enabling this flag currently causes a compile error#define YYDEBUG 1//static int cimmof_debug;//extern cimmofParser g_cimmofParser;extern int   cimmof_lex(void);extern int   cimmof_error(...);extern char *cimmof_text;extern void  cimmof_yy_less(int n);extern int   cimmof_leng;/* ------------------------------------------------------------------- *//* These globals provide continuity between various pieces of a        *//* declaration.  They are usually interpreted as "these modifiers were *//* encountered and need to be applied to the finished object".  For    *//* example, qualifiers are accumulated in g_qualifierList[] as they    *//* encountered, then applied to the production they qualify when it    *//* is completed.                                                       *//* ------------------------------------------------------------------- */  CIMFlavor g_flavor = CIMFlavor (CIMFlavor::NONE);  CIMScope g_scope = CIMScope ();  //ATTN: BB 2001 BB P1 - Fixed size qualifier list max 20. Make larger or var  qualifierList g_qualifierList(20);  CIMMethod *g_currentMethod = 0;  CIMClass *g_currentClass = 0;  CIMInstance *g_currentInstance = 0;  String g_currentAliasRef; // Alias reference  String g_currentAliasDecl; // Alias declaration  CIMName g_referenceClassName = CIMName();  Array<CIMKeyBinding> g_KeyBindingArray; // it gets created empty  TYPED_INITIALIZER_VALUE g_typedInitializerValue; /* ------------------------------------------------------------------- *//* Pragmas, except for the Include pragma, are not handled yet    *//* I don't understand them, so it may be a while before they are       */ /* ------------------------------------------------------------------- */  struct pragma {    String name;    String value;  };/* ---------------------------------------------------------------- *//* Use our general wrap manager to handle end-of-file               *//* ---------------------------------------------------------------- */extern "C" {intcimmof_wrap() {  return cimmofParser::Instance()->wrapCurrentBuffer();}}/* ---------------------------------------------------------------- *//* Pass errors to our general log manager.                          *//* ---------------------------------------------------------------- */voidcimmof_error(const char *msg) {  cimmofParser::Instance()->log_parse_error(cimmof_text, msg);  // printf("Error: %s\n", msg);}static void MOF_error(const char * str, const char * S);static void MOF_trace(const char* str);static void MOF_trace2(const char * str, const char * S);%}%union {  //char                     *strval;  CIMClass                 *mofclass;  CIMFlavor                *flavor;  CIMInstance              *instance;  CIMKeyBinding            *keybinding;  CIMMethod                *method;  CIMName                  *cimnameval;  CIMObjectPath            *reference;  CIMProperty              *property;  CIMQualifier             *qualifier;  CIMQualifierDecl         *mofqualifier;  CIMScope                 *scope;  CIMType                   datatype;  CIMValue                 *value;  int                       ival;  modelPath                *modelpath;  String                   *strptr;  String                   *strval;  struct pragma            *pragma;  TYPED_INITIALIZER_VALUE  *typedinitializer;}%token TOK_ALIAS_IDENTIFIER%token TOK_ANY%token TOK_AS%token TOK_ASSOCIATION%token TOK_BINARY_VALUE%token TOK_CHAR_VALUE%token TOK_CLASS%token TOK_COLON%token TOK_COMMA%token TOK_DISABLEOVERRIDE%token TOK_DQUOTE%token TOK_DT_BOOL%token TOK_DT_CHAR16%token TOK_DT_CHAR8%token TOK_DT_DATETIME%token TOK_DT_REAL32%token TOK_DT_REAL64%token TOK_DT_SINT16%token TOK_DT_SINT32%token TOK_DT_SINT64%token TOK_DT_SINT8%token TOK_DT_STR%token TOK_DT_UINT16%token TOK_DT_UINT32%token TOK_DT_UINT64%token TOK_DT_UINT8%token TOK_ENABLEOVERRIDE%token TOK_END_OF_FILE%token TOK_EQUAL%token TOK_FALSE%token TOK_FLAVOR%token TOK_HEX_VALUE%token TOK_INCLUDE%token TOK_INDICATION%token TOK_INSTANCE%token TOK_LEFTCURLYBRACE%token TOK_LEFTPAREN%token TOK_LEFTSQUAREBRACKET%token TOK_METHOD%token TOK_NULL_VALUE%token TOK_OCTAL_VALUE%token TOK_OF%token TOK_PARAMETER%token TOK_PERIOD%token TOK_POSITIVE_DECIMAL_VALUE%token TOK_PRAGMA%token TOK_PROPERTY%token TOK_QUALIFIER%token TOK_REAL_VALUE%token TOK_REF%token TOK_REFERENCE%token TOK_RESTRICTED%token TOK_RIGHTCURLYBRACE%token TOK_RIGHTPAREN%token TOK_RIGHTSQUAREBRACKET%token TOK_SCHEMA%token TOK_SCOPE%token TOK_SEMICOLON%token TOK_SIGNED_DECIMAL_VALUE%token TOK_SIMPLE_IDENTIFIER%token TOK_STRING_VALUE%token TOK_TOSUBCLASS%token TOK_TRANSLATABLE%token TOK_TRUE%token TOK_UNEXPECTED_CHAR%type <cimnameval>       propertyName parameterName methodName className%type <cimnameval>       superClass%type <datatype>         dataType intDataType realDataType parameterType objectRef%type <flavor>           flavor defaultFlavor %type <instance>         instanceHead instanceDeclaration %type <ival>             array%type <ival>             booleanValue keyValuePairList%type <keybinding>       keyValuePair%type <method>           methodHead methodDeclaration%type <modelpath>        modelPath%type <mofclass>         classHead classDeclaration%type <mofqualifier>     qualifierDeclaration%type <pragma>           compilerDirectivePragma%type <property>         propertyBody propertyDeclaration referenceDeclaration%type <qualifier>        qualifier%type <scope>            scope metaElements metaElement%type <strval>           arrayInitializer constantValues %type <strval>           fileName referencedObject referenceName referencePath %type <strval>           integerValue TOK_REAL_VALUE TOK_CHAR_VALUE %type <strval>           namespaceHandle namespaceHandleRef%type <strval>           nonNullConstantValue%type <strval>           pragmaName pragmaVal keyValuePairName qualifierName%type <strval>           referenceInitializer objectHandle%type <strval>           aliasInitializer%type <strval>           aliasIdentifier%type <strval>           stringValue stringValues initializer constantValue%type <strval>           TOK_ALIAS_IDENTIFIER  alias %type <strval>           TOK_POSITIVE_DECIMAL_VALUE TOK_OCTAL_VALUE TOK_HEX_VALUE %type <strval>           TOK_SIGNED_DECIMAL_VALUE TOK_BINARY_VALUE%type <strval>           TOK_SIMPLE_IDENTIFIER TOK_STRING_VALUE%type <strval>           TOK_UNEXPECTED_CHAR%type <typedinitializer> typedInitializer typedDefaultValue %type <typedinitializer> typedQualifierParameter%type <value>            qualifierValue%%/***------------------------------------------------------------------------------****   Production rules section****------------------------------------------------------------------------------*/mofSpec: mofProductions ;mofProductions: mofProduction mofProductions              | /* empty */ ;// ATTN: P1 KS Apr 2002 Limit in (none) Directive handling. See FIXME below.mofProduction: compilerDirective { /* FIXME: Where do we put directives? */ }             | qualifierDeclaration                  { cimmofParser::Instance()->addQualifier($1); delete $1; }             | classDeclaration 	         { cimmofParser::Instance()->addClass($1); }             | instanceDeclaration                  { cimmofParser::Instance()->addInstance($1); } ;/***------------------------------------------------------------------------------****   class Declaration productions and processing****------------------------------------------------------------------------------*/classDeclaration: classHead  classBody{    YACCTRACE("classDeclaration");    if (g_currentAliasDecl != String::EMPTY)    cimmofParser::Instance()->addClassAlias(g_currentAliasDecl, $$, false);} ;classHead: qualifierList TOK_CLASS className alias superClass{    // create new instance of class with className and superclassName    // put returned class object on stack    YACCTRACE("classHead:");    $$ = cimmofParser::Instance()->newClassDecl(*$3, *$5);        // put list of qualifiers into class    applyQualifierList(&g_qualifierList, $$);        g_currentAliasRef = *$4;    if (g_currentClass)        delete g_currentClass;    g_currentClass = $$;    delete $3;    delete $4;    delete $5;} ;className: TOK_SIMPLE_IDENTIFIER {} ;superClass: TOK_COLON className { $$ = new CIMName(*$2); }          | /* empty */ { $$ = new CIMName(); } ;classBody: TOK_LEFTCURLYBRACE classFeatures TOK_RIGHTCURLYBRACE TOK_SEMICOLON         | TOK_LEFTCURLYBRACE TOK_RIGHTCURLYBRACE TOK_SEMICOLON ;classFeatures: classFeature             | classFeatures classFeature ;classFeature: propertyDeclaration  {  YACCTRACE("classFeature:applyProperty");  cimmofParser::Instance()->applyProperty(*g_currentClass, *$1); delete $1; }             | methodDeclaration {  YACCTRACE("classFeature:applyMethod");  cimmofParser::Instance()->applyMethod(*g_currentClass, *$1); }            | referenceDeclaration {  YACCTRACE("classFeature:applyProperty");  cimmofParser::Instance()->applyProperty(*g_currentClass, *$1); delete $1; }; /***------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -