(file) Return to cimmofParser.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Compiler

  1 karl  1.31 //%2005////////////////////////////////////////////////////////////////////////
  2 mike  1.11 //
  3 karl  1.30 // 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 karl  1.28 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.30 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.31 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 mike  1.11 //
 12            // Permission is hereby granted, free of charge, to any person obtaining a copy
 13 kumpf 1.19 // 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 mike  1.11 // sell copies of the Software, and to permit persons to whom the Software is
 17            // furnished to do so, subject to the following conditions:
 18            // 
 19 kumpf 1.19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20 mike  1.11 // 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 kumpf 1.19 // 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 mike  1.11 // 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.
 27            //
 28            //==============================================================================
 29            //
 30            // Author: Bob Blair (bblair@bmc.com)
 31            //
 32 kumpf 1.22 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 33            //                (carolann_graves@hp.com)
 34 gerarda 1.26 //              Gerarda Marquez (gmarquez@us.ibm.com)
 35              //              -- PEP 43 changes
 36 kumpf   1.29 //              Terry Martin, Hewlett-Packard Company (terry.martin@hp.com)
 37 mike    1.11 //
 38              //%/////////////////////////////////////////////////////////////////////////////
 39              
 40              
 41              //
 42              //
 43              // This header describes the cimmofParser class.  
 44              // It is a singleton, and can only be accessed via the pointer
 45              // returned by its static Intance() method.
 46              // //
 47              // The instance of this
 48              // class hold enough state information that there should be no need for
 49              // the underlying YACC parser to be written reentrant.
 50              //
 51              // The YACCer (and LExer) communicate with the instance of this class
 52              // via the ointer returned by the Instance() method.
 53              //
 54              // This specialization contains a reference to the containing program's
 55              // mofComplerCmdLine object, which holds the command line arguments
 56              // including the list of directories to search to find included mof files
 57              //
 58 mike    1.11 
 59              #ifndef _CIMMOFPARSER_H_
 60              #define _CIMMOFPARSER_H_
 61              
 62              
 63 kumpf   1.29 #include <Pegasus/Common/Config.h>
 64              #include <Pegasus/Common/InternalException.h>
 65              #include <Pegasus/Compiler/compilerCommonDefs.h>
 66              #include <Pegasus/Compiler/Linkage.h>
 67 mike    1.11 #include "parser.h"
 68              #include "mofCompilerOptions.h"
 69 bob     1.15 #include "cimmofRepositoryInterface.h"
 70 gerarda 1.26 #include "cimmofMessages.h"
 71 mike    1.11 #include "memobjs.h"
 72              #include "objname.h"
 73              
 74 karl    1.27 // Diagnostics that can be used to display flow.
 75              // This is manually turned on be selecting the proper define
 76              // below.  
 77              #define YACCTRACE(X)
 78              //#define YACCTRACE(X) {if (yydebug) cerr << X << endl;}
 79              // The following is used for the moment to set the trace because
 80              // there is a bug when YYDEBUG set and yydebug needs to be connected
 81              // to the commof compile flags.
 82              //#define YACCTRACE(X) {cerr << X << endl;}
 83              
 84              
 85 mike    1.11 extern int cimmof_parse(); // the yacc parser entry point
 86              
 87 bob     1.15 //class cimmofRepository;
 88 mike    1.11 
 89              // This class extends class parser (see parser.h)
 90              class PEGASUS_COMPILER_LINKAGE cimmofParser : public parser {
 91               private:
 92                // This is meant to be a singleton, so we hide the constructor
 93                // and the destructor
 94                static cimmofParser *_instance;
 95                cimmofParser();
 96                ~cimmofParser();
 97                void trace(const String &head, const String &tail) const;
 98                //either throw us out or retry depending on user preference
 99                void maybeThrowParseError(const String &msg) const;
100                void maybeThrowLexerError(const String &msg) const;
101 gerarda 1.26 
102                //Processing to determine if class should be updated
103                Boolean updateClass(const CIMClass &classdecl, cimmofMessages::MsgCode &updateMessage, Boolean &classExist);
104                Boolean verifyVersion(const String &version, int &iM, int &iN, int &iU);
105 mike    1.11 
106                // Here are the members added by this specialization
107                const mofCompilerOptions *_cmdline;
108                String _includefile;  // temp storage for included file to be entered
109 bob     1.15   cimmofRepositoryInterface _repository; // the repository interface object
110 mike    1.11   String _defaultNamespacePath;  // The path we'll use if none is given
111                String _currentNamespacePath;  // a namespace set from a #pragma
112 bob     1.12   compilerCommonDefs::operationType _ot;
113 mike    1.11  public:
114                // Provide a way for the singleton to be constructed, or a
115                // pointer to be returned:
116                static cimmofParser *Instance();
117 bob     1.15   void elog(const String &msg) const; // handle logging of errors
118                void wlog(const String &msg) const; // handle logging of warnings
119 mike    1.11 
120                //------------------------------------------------------------------
121                // Methods for manipulating the members added in this specialization
122                //------------------------------------------------------------------
123                // compiler options.  This may be set from command line data,
124                // or by an embedding application
125                void setCompilerOptions(const mofCompilerOptions *co);
126                const mofCompilerOptions *getCompilerOptions() const;
127                // for all, or nearly all, operations, a repository object is needed
128                Boolean setRepository(void);
129 bob     1.15   const cimmofRepositoryInterface *getRepository() const;
130 bob     1.12   // Whether you need a repository or not depends on the operationsType
131                void setOperationType(compilerCommonDefs::operationType);
132                compilerCommonDefs::operationType getOperationType() const;
133 mike    1.11   // Set a default root namespace path to pass to  the repository
134                void setDefaultNamespacePath(const String &path); // default value
135                void setCurrentNamespacePath(const String &path); // current override
136                const String &getDefaultNamespacePath() const;
137                const String &getCurrentNamespacePath() const;
138                // Get the effective namespace path -- the override, if there is one.
139                const String &getNamespacePath() const;
140                //------------------------------------------------------------------
141                // Methods that implement or override base class methods
142                //------------------------------------------------------------------
143                // establish an input buffer given an input file stream
144 kumpf   1.25   int setInputBuffer(const FILE *f, Boolean closeCurrent);
145 mike    1.11   // establish an input buffer given an existing context (YY_BUFFERSTATE)
146 kumpf   1.25   int setInputBuffer(void *buffstate, Boolean closeCurrent);
147 mike    1.11   // Dig into an include file given its name
148                int enterInlineInclude(const String &filename);
149                // Dig into an include file given an input file stream
150                int enterInlineInclude(const FILE *f);
151                // Handle end-of-file 
152                int wrapCurrentBuffer();
153                // Parse an input file
154                int parse();
155                // Log a parser error
156 kumpf   1.17   void log_parse_error(char *token, const char *errmsg) const;
157 mike    1.11 
158                //------------------------------------------------------------------
159                // Do various representation transformations.
160                // These are in this class simply because there wasn't another
161                // conventient place for them.  They could just as well be static
162                // methods of some convenience class.
163                //------------------------------------------------------------------
164                //    Octal character input to decimal character output
165                char *oct_to_dec(const String &octrep) const;
166                //    Hex character input to decimal character output
167                char *hex_to_dec(const String &hexrep) const;
168                //    Binary character input to decimal character output
169                char *binary_to_dec(const String &binrep) const;
170              
171                //------------------------------------------------------------------
172                // Handle the processing of CIM-specific constructs
173                //------------------------------------------------------------------
174                // This is called after a completed #pragma production is formed
175                void processPragma(const String &pragmaName, const String &pragmaString);
176                // This is called when a completed class declaration production is formed
177                int addClass(CIMClass *classdecl);
178 mike    1.11   // This is called when a new class declaration heading is discovered
179 kumpf   1.21   CIMClass *newClassDecl(const CIMName &name, const CIMName &superclass);
180 mike    1.11   // Called when a completed instanace declaration production is formed
181                int addInstance(CIMInstance *instance);
182                // Called when a new qualifier declaration heading is discovered
183                CIMQualifierDecl *newQualifierDecl(const String &name, const CIMValue *value,
184 kumpf   1.22       const CIMScope & scope, const CIMFlavor & flavor);
185 mike    1.11   // Called when a completed qualifier declaration production is formed
186                int addQualifier(CIMQualifierDecl *qualifier);
187                // Called when a new qualifier declaration heading is discovered
188                CIMQualifier *newQualifier(const String &name, const CIMValue &val,
189 kumpf   1.22 			     const CIMFlavor & flav);
190 mike    1.11   // Called when a new instance declaration heading is discovered
191 kumpf   1.24   CIMInstance *newInstance(const CIMName &name);
192 mike    1.11   // Called when a new property is discovered
193 kumpf   1.21   CIMProperty *newProperty(const CIMName &name, const CIMValue &val,
194 karl    1.14                            const Boolean isArray,
195                                         const Uint32 arraySize,
196 kumpf   1.21 			   const CIMName &referencedObj = CIMName()) const;
197 mike    1.11   // Called when a property production inside a class is complete
198                int applyProperty(CIMClass &c, CIMProperty &p);
199                // Called when a property production inside an instance is complete
200                int applyProperty(CIMInstance &instance, CIMProperty &p);
201                // Called when a new method is discovered
202 kumpf   1.21   CIMMethod   *newMethod(const CIMName &name, const CIMType type);
203 mike    1.11   // Called when a method production inside a class is complete
204                int applyMethod(CIMClass &c, CIMMethod &m);
205                // Called when a method parameter is discovered
206 kumpf   1.21   CIMParameter *newParameter(const CIMName &name, const CIMType type,
207 mike    1.11 			     Boolean isArray=false, Uint32 array=0, 
208 kumpf   1.21 			     const CIMName &objName=CIMName());
209 mike    1.11   // Called when a method parameter production is complete
210                int applyParameter(CIMMethod &method, CIMParameter &parm);
211                // Called when a qualifier value production is complete
212 kumpf   1.24   CIMValue *QualifierValue(const CIMName &qualifierName, 
213 kumpf   1.17                            Boolean isNull, const String &valstr);
214 mike    1.11   // Called to retrieve the value object for an existing parameter
215                CIMProperty *PropertyFromInstance(CIMInstance &instance,
216 kumpf   1.24 				    const CIMName &propertyName) const;
217 mike    1.11   CIMValue *ValueFromProperty(const CIMProperty &prop) const;
218                CIMValue *PropertyValueFromInstance(CIMInstance &instance, 
219 kumpf   1.24 				      const CIMName &propertyName) const; 
220 mike    1.11   // Called when a class alias is found
221                void addClassAlias(const String &alias, const CIMClass *cd, 
222              		Boolean isInstance);
223                // Called when an instance alias is found
224 jim.wunderlich 1.32   Uint32 addInstanceAlias(const String &alias, const CIMInstance *cd, 
225 mike           1.11 		Boolean isInstance);
226 jim.wunderlich 1.32   // Called when an instance alias reference is found
227                       Uint32 getInstanceAlias(const String &alias, CIMObjectPath &ObjPath);
228 mike           1.11   // Called when a reference declaration is found
229 kumpf          1.18   CIMObjectPath *newReference(const objectName &oname);
230 mike           1.11   // Make a clone of a property object, inserting a new value object
231                       CIMProperty *copyPropertyWithNewValue(const CIMProperty &p,
232                     					const CIMValue &v) const;
233                     };
234                     
235                     // Exceptions
236                     
237                     class PEGASUS_COMPILER_LINKAGE LexerError : public Exception {
238                      public:
239                       static const char MSG[];
240                       LexerError(const String &lexerr) : Exception(MSG + lexerr) {}
241                     };
242                     
243                     #endif
244                       
245                     
246                     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2