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

  1 mike  1.11 //%/////////////////////////////////////////////////////////////////////////////
  2            //
  3 kumpf 1.19 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4            // The Open Group, Tivoli Systems
  5 mike  1.11 //
  6            // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 kumpf 1.19 // of this software and associated documentation files (the "Software"), to
  8            // deal in the Software without restriction, including without limitation the
  9            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10 mike  1.11 // sell copies of the Software, and to permit persons to whom the Software is
 11            // furnished to do so, subject to the following conditions:
 12            // 
 13 kumpf 1.19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 mike  1.11 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16 kumpf 1.19 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19 mike  1.11 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21            //
 22            //==============================================================================
 23            //
 24            // Author: Bob Blair (bblair@bmc.com)
 25            //
 26            // Modified By:
 27            //
 28            //%/////////////////////////////////////////////////////////////////////////////
 29            
 30            
 31            //
 32            //
 33            // This header describes the cimmofParser class.  
 34            // It is a singleton, and can only be accessed via the pointer
 35            // returned by its static Intance() method.
 36            // //
 37            // The instance of this
 38            // class hold enough state information that there should be no need for
 39            // the underlying YACC parser to be written reentrant.
 40 mike  1.11 //
 41            // The YACCer (and LExer) communicate with the instance of this class
 42            // via the ointer returned by the Instance() method.
 43            //
 44            // This specialization contains a reference to the containing program's
 45            // mofComplerCmdLine object, which holds the command line arguments
 46            // including the list of directories to search to find included mof files
 47            //
 48            
 49            #ifndef _CIMMOFPARSER_H_
 50            #define _CIMMOFPARSER_H_
 51            
 52            
 53            #include "parser.h"
 54            #include "mofCompilerOptions.h"
 55 bob   1.15 #include "cimmofRepositoryInterface.h"
 56 mike  1.11 #include <Pegasus/Common/Config.h>
 57            #include <Pegasus/Common/Exception.h>
 58 bob   1.12 #include <Pegasus/Compiler/compilerCommonDefs.h>
 59 mike  1.11 #include "memobjs.h"
 60            #include "objname.h"
 61            
 62            extern int cimmof_parse(); // the yacc parser entry point
 63            
 64 bob   1.15 //class cimmofRepository;
 65 mike  1.11 
 66            // This class extends class parser (see parser.h)
 67            class PEGASUS_COMPILER_LINKAGE cimmofParser : public parser {
 68             private:
 69              // This is meant to be a singleton, so we hide the constructor
 70              // and the destructor
 71              static cimmofParser *_instance;
 72              cimmofParser();
 73              ~cimmofParser();
 74              void trace(const String &head, const String &tail) const;
 75              //either throw us out or retry depending on user preference
 76              void maybeThrowParseError(const String &msg) const;
 77              void maybeThrowLexerError(const String &msg) const;
 78            
 79              // Here are the members added by this specialization
 80              const mofCompilerOptions *_cmdline;
 81              String _includefile;  // temp storage for included file to be entered
 82 bob   1.15   cimmofRepositoryInterface _repository; // the repository interface object
 83 mike  1.11   String _defaultNamespacePath;  // The path we'll use if none is given
 84              String _currentNamespacePath;  // a namespace set from a #pragma
 85 bob   1.12   compilerCommonDefs::operationType _ot;
 86 mike  1.11  public:
 87              // Provide a way for the singleton to be constructed, or a
 88              // pointer to be returned:
 89              static cimmofParser *Instance();
 90 bob   1.15   void elog(const String &msg) const; // handle logging of errors
 91              void wlog(const String &msg) const; // handle logging of warnings
 92 mike  1.11 
 93              //------------------------------------------------------------------
 94              // Methods for manipulating the members added in this specialization
 95              //------------------------------------------------------------------
 96              // compiler options.  This may be set from command line data,
 97              // or by an embedding application
 98              void setCompilerOptions(const mofCompilerOptions *co);
 99              const mofCompilerOptions *getCompilerOptions() const;
100              // for all, or nearly all, operations, a repository object is needed
101              Boolean setRepository(void);
102 bob   1.15   const cimmofRepositoryInterface *getRepository() const;
103 bob   1.12   // Whether you need a repository or not depends on the operationsType
104              void setOperationType(compilerCommonDefs::operationType);
105              compilerCommonDefs::operationType getOperationType() const;
106 mike  1.11   // Set a default root namespace path to pass to  the repository
107              void setDefaultNamespacePath(const String &path); // default value
108              void setCurrentNamespacePath(const String &path); // current override
109              const String &getDefaultNamespacePath() const;
110              const String &getCurrentNamespacePath() const;
111              // Get the effective namespace path -- the override, if there is one.
112              const String &getNamespacePath() const;
113              //------------------------------------------------------------------
114              // Methods that implement or override base class methods
115              //------------------------------------------------------------------
116              // establish an input buffer given an input file stream
117              int setInputBuffer(const FILE *f);
118              // establish an input buffer given an existing context (YY_BUFFERSTATE)
119              int setInputBuffer(void *buffstate);
120              // Dig into an include file given its name
121              int enterInlineInclude(const String &filename);
122              // Dig into an include file given an input file stream
123              int enterInlineInclude(const FILE *f);
124              // Handle end-of-file 
125              int wrapCurrentBuffer();
126              // Parse an input file
127 mike  1.11   int parse();
128              // Log a parser error
129 kumpf 1.17   void log_parse_error(char *token, const char *errmsg) const;
130 mike  1.11 
131              //------------------------------------------------------------------
132              // Do various representation transformations.
133              // These are in this class simply because there wasn't another
134              // conventient place for them.  They could just as well be static
135              // methods of some convenience class.
136              //------------------------------------------------------------------
137              //    Octal character input to decimal character output
138              char *oct_to_dec(const String &octrep) const;
139              //    Hex character input to decimal character output
140              char *hex_to_dec(const String &hexrep) const;
141              //    Binary character input to decimal character output
142              char *binary_to_dec(const String &binrep) const;
143            
144              //------------------------------------------------------------------
145              // Handle the processing of CIM-specific constructs
146              //------------------------------------------------------------------
147              // This is called after a completed #pragma production is formed
148              void processPragma(const String &pragmaName, const String &pragmaString);
149              // This is called when a completed class declaration production is formed
150              int addClass(CIMClass *classdecl);
151 mike  1.11   // This is called when a new class declaration heading is discovered
152              CIMClass *newClassDecl(const String &name, const String &superclass);
153              // Called when a completed instanace declaration production is formed
154              int addInstance(CIMInstance *instance);
155              // Called when a new qualifier declaration heading is discovered
156              CIMQualifierDecl *newQualifierDecl(const String &name, const CIMValue *value,
157            				  Uint32 scope, Uint32 flavor);
158              // Called when a completed qualifier declaration production is formed
159              int addQualifier(CIMQualifierDecl *qualifier);
160              // Called when a new qualifier declaration heading is discovered
161              CIMQualifier *newQualifier(const String &name, const CIMValue &val,
162            			     Uint32 flav);
163              // Called when a new instance declaration heading is discovered
164              CIMInstance *newInstance(const String &name);
165              // Called when a new property is discovered
166              CIMProperty *newProperty(const String &name, const CIMValue &val,
167 karl  1.14                            const Boolean isArray,
168                                       const Uint32 arraySize,
169 mike  1.11 			   const String &referencedObj = String::EMPTY) const;
170              // Called when a property production inside a class is complete
171              int applyProperty(CIMClass &c, CIMProperty &p);
172              // Called when a property production inside an instance is complete
173              int applyProperty(CIMInstance &instance, CIMProperty &p);
174              // Called when a new method is discovered
175              CIMMethod   *newMethod(const String &name, const CIMType type);
176              // Called when a method production inside a class is complete
177              int applyMethod(CIMClass &c, CIMMethod &m);
178              // Called when a method parameter is discovered
179              CIMParameter *newParameter(const String &name, const CIMType type,
180            			     Boolean isArray=false, Uint32 array=0, 
181            			     const String &objName=String::EMPTY);
182              // Called when a method parameter production is complete
183              int applyParameter(CIMMethod &method, CIMParameter &parm);
184              // Called when a qualifier value production is complete
185 kumpf 1.17   CIMValue *QualifierValue(const String &qualifierName, 
186                                       Boolean isNull, const String &valstr);
187 mike  1.11   // Called to retrieve the value object for an existing parameter
188              CIMProperty *PropertyFromInstance(CIMInstance &instance,
189            				    const String &propertyName) const;
190              CIMValue *ValueFromProperty(const CIMProperty &prop) const;
191              CIMValue *PropertyValueFromInstance(CIMInstance &instance, 
192            				      const String &propertyName) const; 
193              // Called when a class alias is found
194              void addClassAlias(const String &alias, const CIMClass *cd, 
195            		Boolean isInstance);
196              // Called when an instance alias is found
197              void addInstanceAlias(const String &alias, const CIMInstance *cd, 
198            		Boolean isInstance);
199              // Called when a reference declaration is found
200 kumpf 1.18   CIMObjectPath *newReference(const objectName &oname);
201 mike  1.11   // Make a clone of a property object, inserting a new value object
202              CIMProperty *copyPropertyWithNewValue(const CIMProperty &p,
203            					const CIMValue &v) const;
204            };
205            
206            // Exceptions
207            
208            class PEGASUS_COMPILER_LINKAGE LexerError : public Exception {
209             public:
210              static const char MSG[];
211              LexerError(const String &lexerr) : Exception(MSG + lexerr) {}
212            };
213            
214            #endif
215              
216            
217            

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2