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

  1 karl  1.33 //%2006////////////////////////////////////////////////////////////////////////
  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 karl  1.33 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike  1.11 //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15 kumpf 1.19 // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18 mike  1.11 // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20 karl  1.35 //
 21 kumpf 1.19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.11 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24 kumpf 1.19 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27 mike  1.11 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            //
 33            //%/////////////////////////////////////////////////////////////////////////////
 34            
 35            
 36            //
 37            //
 38 karl  1.35 // This header describes the cimmofParser class.
 39 mike  1.11 // It is a singleton, and can only be accessed via the pointer
 40            // returned by its static Intance() method.
 41            // //
 42            // The instance of this
 43            // class hold enough state information that there should be no need for
 44            // the underlying YACC parser to be written reentrant.
 45            //
 46            // The YACCer (and LExer) communicate with the instance of this class
 47            // via the ointer returned by the Instance() method.
 48            //
 49            // This specialization contains a reference to the containing program's
 50            // mofComplerCmdLine object, which holds the command line arguments
 51            // including the list of directories to search to find included mof files
 52            //
 53            
 54            #ifndef _CIMMOFPARSER_H_
 55            #define _CIMMOFPARSER_H_
 56            
 57            
 58 kumpf 1.29 #include <Pegasus/Common/Config.h>
 59            #include <Pegasus/Common/InternalException.h>
 60            #include <Pegasus/Compiler/compilerCommonDefs.h>
 61            #include <Pegasus/Compiler/Linkage.h>
 62 mike  1.11 #include "parser.h"
 63            #include "mofCompilerOptions.h"
 64 bob   1.15 #include "cimmofRepositoryInterface.h"
 65 gerarda 1.26 #include "cimmofMessages.h"
 66 mike    1.11 #include "memobjs.h"
 67              
 68 karl    1.27 // Diagnostics that can be used to display flow.
 69              // This is manually turned on be selecting the proper define
 70 karl    1.35 // below.
 71 karl    1.27 #define YACCTRACE(X)
 72              //#define YACCTRACE(X) {if (yydebug) cerr << X << endl;}
 73              // The following is used for the moment to set the trace because
 74              // there is a bug when YYDEBUG set and yydebug needs to be connected
 75              // to the commof compile flags.
 76              //#define YACCTRACE(X) {cerr << X << endl;}
 77              
 78              
 79 mike    1.11 extern int cimmof_parse(); // the yacc parser entry point
 80              
 81 bob     1.15 //class cimmofRepository;
 82 mike    1.11 
 83              // This class extends class parser (see parser.h)
 84 karl    1.35 class PEGASUS_COMPILER_LINKAGE cimmofParser : public parser
 85              {
 86                  private:
 87                      // This is meant to be a singleton, so we hide the constructor
 88                      // and the destructor
 89 kumpf   1.38         friend class DeletePtr<cimmofParser>;
 90 kumpf   1.39         static cimmofParser* _instance;
 91 karl    1.35 
 92                      cimmofParser();
 93              
 94                      ~cimmofParser();
 95              
 96                      void trace(const String &head, const String &tail) const;
 97              
 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              
102                      //Processing to determine if class should be updated
103                      Boolean updateClass(
104                              const CIMClass& classdecl,
105                              cimmofMessages::MsgCode& updateMessage,
106                              Boolean& classExist);
107              
108                      Boolean parseVersion(
109                              const String& version,
110                              int& iM,
111                              int& iN,
112 karl    1.35                 int& iU);
113              
114                      // Here are the members added by this specialization
115                      const mofCompilerOptions *_cmdline;
116              
117                      String _includefile;  // temp storage for included file to be entered
118              
119                      cimmofRepositoryInterface _repository; // repository interface object
120              
121                      String _defaultNamespacePath;  // The path we'll use if none is given
122              
123                      String _currentNamespacePath;  // a namespace set from a #pragma
124              
125                      compilerCommonDefs::operationType _ot;
126                  public:
127                      // Provide a way for the singleton to be constructed, or a
128                      // pointer to be returned:
129                      static cimmofParser *Instance();
130              
131 kumpf   1.39         /// Destructs the singleton object created by the Instance() method.
132                      static void destroy();
133              
134 karl    1.35         void elog(const String &msg) const; // handle logging of errors
135              
136                      void wlog(const String &msg) const; // handle logging of warnings
137              
138                      //------------------------------------------------------------------
139                      // Methods for manipulating the members added in this specialization
140                      //------------------------------------------------------------------
141                      // compiler options.  This may be set from command line data,
142                      // or by an embedding application
143                      void setCompilerOptions(const mofCompilerOptions *co);
144                      const mofCompilerOptions *getCompilerOptions() const;
145                      // for all, or nearly all, operations, a repository object is needed
146                      Boolean setRepository(void);
147                      const cimmofRepositoryInterface *getRepository() const;
148                      // Whether you need a repository or not depends on the operationsType
149                      void setOperationType(compilerCommonDefs::operationType);
150                      compilerCommonDefs::operationType getOperationType() const;
151                      // Set a default root namespace path to pass to  the repository
152                      void setDefaultNamespacePath(const String &path); // default value
153                      void setCurrentNamespacePath(const String &path); // current override
154                      const String &getDefaultNamespacePath() const;
155 karl    1.35         const String &getCurrentNamespacePath() const;
156                      // Get the effective namespace path -- the override, if there is one.
157                      const String &getNamespacePath() const;
158              
159                      //------------------------------------------------------------------
160                      // Methods that implement or override base class methods
161                      //------------------------------------------------------------------
162                      // establish an input buffer given an input file stream
163                      int setInputBuffer(const FILE *f, Boolean closeCurrent);
164                      // establish an input buffer given an existing context (YY_BUFFERSTATE)
165                      int setInputBuffer(void *buffstate, Boolean closeCurrent);
166                      // Dig into an include file given its name
167                      int enterInlineInclude(const String &filename);
168                      // Dig into an include file given an input file stream
169                      int enterInlineInclude(const FILE *f);
170                      // Handle end-of-file
171                      int wrapCurrentBuffer();
172                      // Parse an input file
173                      int parse();
174                      // Log a parser error
175                      void log_parse_error(char *token, const char *errmsg) const;
176 karl    1.35 
177                      //------------------------------------------------------------------
178                      // Handle the processing of CIM-specific constructs
179                      //------------------------------------------------------------------
180                      // This is called after a completed #pragma production is formed
181                      void processPragma(const String &pragmaName,
182                          const String &pragmaString);
183              
184                      // addClass called when completed class declaration production is formed
185                      int addClass(CIMClass *classdecl);
186              
187                      // This is called when a new class declaration heading is discovered
188                      CIMClass *newClassDecl(const CIMName &name, const CIMName &superclass);
189              
190                      // Called when a completed instanace declaration production is formed
191                      int addInstance(CIMInstance *instance);
192              
193                      // Called when a new qualifier declaration heading is discovered
194                      CIMQualifierDecl *newQualifierDecl(const String &name,
195                          const CIMValue *value,
196                          const CIMScope & scope, const CIMFlavor & flavor);
197 karl    1.35 
198                      // Called when a completed qualifier declaration production is formed
199                      int addQualifier(CIMQualifierDecl *qualifier);
200              
201                      // Called when a new qualifier declaration heading is discovered
202                      CIMQualifier *newQualifier(const String &name, const CIMValue &val,
203                              const CIMFlavor & flav);
204              
205                      // Called when a new instance declaration heading is discovered
206                      CIMInstance *newInstance(const CIMName &name);
207              
208                      // Called when a new property is discovered
209                      CIMProperty *newProperty(const CIMName &name, const CIMValue &val,
210                              const Boolean isArray,
211                              const Uint32 arraySize,
212                              const CIMName &referencedObj = CIMName()) const;
213              
214                      // Called when a property production inside a class is complete
215                      int applyProperty(CIMClass &c, CIMProperty &p);
216              
217                      // Called when a property production inside an instance is complete
218 karl    1.35         int applyProperty(CIMInstance &instance, CIMProperty &p);
219              
220                      // Called when a new method is discovered
221                      CIMMethod   *newMethod(const CIMName &name, const CIMType type);
222              
223                      // Called when a method production inside a class is complete
224                      int applyMethod(CIMClass &c, CIMMethod &m);
225              
226                      // Called when a method parameter is discovered
227                      CIMParameter *newParameter(const CIMName &name, const CIMType type,
228                              Boolean isArray=false, Uint32 array=0,
229                              const CIMName &objName=CIMName());
230              
231                      // Called when a method parameter production is complete
232                      int applyParameter(CIMMethod &method, CIMParameter &parm);
233              
234                      // Called when a qualifier value production is complete
235                      CIMValue *QualifierValue(const CIMName &qualifierName,
236                              Boolean isNull, const String &valstr);
237              
238                      // Called to retrieve the value object for an existing parameter
239 karl    1.35         CIMProperty *PropertyFromInstance(CIMInstance &instance,
240                              const CIMName &propertyName) const;
241              
242                      CIMValue *ValueFromProperty(const CIMProperty &prop) const;
243              
244                      CIMValue *PropertyValueFromInstance(CIMInstance &instance,
245                              const CIMName &propertyName) const;
246              
247                      // Called when a class alias is found
248                      void addClassAlias(const String &alias, const CIMClass *cd,
249                              Boolean isInstance);
250              
251                      // Called when an instance alias is found
252                      Uint32 addInstanceAlias(const String &alias, const CIMInstance *cd,
253                              Boolean isInstance);
254              
255                      // Called when an instance alias reference is found
256                      Uint32 getInstanceAlias(const String &alias, CIMObjectPath &ObjPath);
257              
258                      // Make a clone of a property object, inserting a new value object
259                      CIMProperty *copyPropertyWithNewValue(const CIMProperty &p,
260 karl    1.35                 const CIMValue &v) const;
261 mike    1.11 };
262              
263              // Exceptions
264              
265              class PEGASUS_COMPILER_LINKAGE LexerError : public Exception {
266               public:
267                static const char MSG[];
268                LexerError(const String &lexerr) : Exception(MSG + lexerr) {}
269              };
270              
271              #endif
272 karl    1.35 
273 mike    1.11 
274              

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2