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 #include "objname.h"
68
|
69 karl 1.27 // Diagnostics that can be used to display flow.
70 // This is manually turned on be selecting the proper define
|
71 karl 1.35 // below.
|
72 karl 1.27 #define YACCTRACE(X)
73 //#define YACCTRACE(X) {if (yydebug) cerr << X << endl;}
74 // The following is used for the moment to set the trace because
75 // there is a bug when YYDEBUG set and yydebug needs to be connected
76 // to the commof compile flags.
77 //#define YACCTRACE(X) {cerr << X << endl;}
78
79
|
80 mike 1.11 extern int cimmof_parse(); // the yacc parser entry point
81
|
82 bob 1.15 //class cimmofRepository;
|
83 mike 1.11
84 // This class extends class parser (see parser.h)
|
85 karl 1.35 class PEGASUS_COMPILER_LINKAGE cimmofParser : public parser
86 {
87 private:
88 // This is meant to be a singleton, so we hide the constructor
89 // and the destructor
90 static cimmofParser *_instance;
91
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 karl 1.35 Boolean& classExist);
107
108 Boolean parseVersion(
109 const String& version,
110 int& iM,
111 int& iN,
112 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 karl 1.35 // Provide a way for the singleton to be constructed, or a
128 // pointer to be returned:
129 static cimmofParser *Instance();
130
131 void elog(const String &msg) const; // handle logging of errors
132
133 void wlog(const String &msg) const; // handle logging of warnings
134
135 //------------------------------------------------------------------
136 // Methods for manipulating the members added in this specialization
137 //------------------------------------------------------------------
138 // compiler options. This may be set from command line data,
139 // or by an embedding application
140 void setCompilerOptions(const mofCompilerOptions *co);
141 const mofCompilerOptions *getCompilerOptions() const;
142 // for all, or nearly all, operations, a repository object is needed
143 Boolean setRepository(void);
144 const cimmofRepositoryInterface *getRepository() const;
145 // Whether you need a repository or not depends on the operationsType
146 void setOperationType(compilerCommonDefs::operationType);
147 compilerCommonDefs::operationType getOperationType() const;
148 karl 1.35 // Set a default root namespace path to pass to the repository
149 void setDefaultNamespacePath(const String &path); // default value
150 void setCurrentNamespacePath(const String &path); // current override
151 const String &getDefaultNamespacePath() const;
152 const String &getCurrentNamespacePath() const;
153 // Get the effective namespace path -- the override, if there is one.
154 const String &getNamespacePath() const;
155
156 //------------------------------------------------------------------
157 // Methods that implement or override base class methods
158 //------------------------------------------------------------------
159 // establish an input buffer given an input file stream
160 int setInputBuffer(const FILE *f, Boolean closeCurrent);
161 // establish an input buffer given an existing context (YY_BUFFERSTATE)
162 int setInputBuffer(void *buffstate, Boolean closeCurrent);
163 // Dig into an include file given its name
164 int enterInlineInclude(const String &filename);
165 // Dig into an include file given an input file stream
166 int enterInlineInclude(const FILE *f);
167 // Handle end-of-file
168 int wrapCurrentBuffer();
169 karl 1.35 // Parse an input file
170 int parse();
171 // Log a parser error
172 void log_parse_error(char *token, const char *errmsg) const;
173
174 //------------------------------------------------------------------
175 // Do various representation transformations.
176 // These are in this class simply because there wasn't another
177 // conventient place for them. They could just as well be static
178 // methods of some convenience class.
179 //------------------------------------------------------------------
180 // Octal character input to decimal character output
181 char *oct_to_dec(const String &octrep) const;
182 // Hex character input to decimal character output
183 char *hex_to_dec(const String &hexrep) const;
184 // Binary character input to decimal character output
185 char *binary_to_dec(const String &binrep) const;
186
187 //------------------------------------------------------------------
188 // Handle the processing of CIM-specific constructs
189 //------------------------------------------------------------------
190 karl 1.35 // This is called after a completed #pragma production is formed
191 void processPragma(const String &pragmaName,
192 const String &pragmaString);
193
194 // addClass called when completed class declaration production is formed
195 int addClass(CIMClass *classdecl);
196
197 // This is called when a new class declaration heading is discovered
198 CIMClass *newClassDecl(const CIMName &name, const CIMName &superclass);
199
200 // Called when a completed instanace declaration production is formed
201 int addInstance(CIMInstance *instance);
202
203 // Called when a new qualifier declaration heading is discovered
204 CIMQualifierDecl *newQualifierDecl(const String &name,
205 const CIMValue *value,
206 const CIMScope & scope, const CIMFlavor & flavor);
207
208 // Called when a completed qualifier declaration production is formed
209 int addQualifier(CIMQualifierDecl *qualifier);
210
211 karl 1.35 // Called when a new qualifier declaration heading is discovered
212 CIMQualifier *newQualifier(const String &name, const CIMValue &val,
213 const CIMFlavor & flav);
214
215 // Called when a new instance declaration heading is discovered
216 CIMInstance *newInstance(const CIMName &name);
217
218 // Called when a new property is discovered
219 CIMProperty *newProperty(const CIMName &name, const CIMValue &val,
220 const Boolean isArray,
221 const Uint32 arraySize,
222 const CIMName &referencedObj = CIMName()) const;
223
224 // Called when a property production inside a class is complete
225 int applyProperty(CIMClass &c, CIMProperty &p);
226
227 // Called when a property production inside an instance is complete
228 int applyProperty(CIMInstance &instance, CIMProperty &p);
229
230 // Called when a new method is discovered
231 CIMMethod *newMethod(const CIMName &name, const CIMType type);
232 karl 1.35
233 // Called when a method production inside a class is complete
234 int applyMethod(CIMClass &c, CIMMethod &m);
235
236 // Called when a method parameter is discovered
237 CIMParameter *newParameter(const CIMName &name, const CIMType type,
238 Boolean isArray=false, Uint32 array=0,
239 const CIMName &objName=CIMName());
240
241 // Called when a method parameter production is complete
242 int applyParameter(CIMMethod &method, CIMParameter &parm);
243
244 // Called when a qualifier value production is complete
245 CIMValue *QualifierValue(const CIMName &qualifierName,
246 Boolean isNull, const String &valstr);
247
248 // Called to retrieve the value object for an existing parameter
249 CIMProperty *PropertyFromInstance(CIMInstance &instance,
250 const CIMName &propertyName) const;
251
252 CIMValue *ValueFromProperty(const CIMProperty &prop) const;
253 karl 1.35
254 CIMValue *PropertyValueFromInstance(CIMInstance &instance,
255 const CIMName &propertyName) const;
256
257 // Called when a class alias is found
258 void addClassAlias(const String &alias, const CIMClass *cd,
259 Boolean isInstance);
260
261 // Called when an instance alias is found
262 Uint32 addInstanceAlias(const String &alias, const CIMInstance *cd,
263 Boolean isInstance);
264
265 // Called when an instance alias reference is found
266 Uint32 getInstanceAlias(const String &alias, CIMObjectPath &ObjPath);
267
268 // Called when a reference declaration is found
269 CIMObjectPath *newReference(const objectName &oname);
270
271 // Make a clone of a property object, inserting a new value object
272 CIMProperty *copyPropertyWithNewValue(const CIMProperty &p,
273 const CIMValue &v) const;
|
274 mike 1.11 };
275
276 // Exceptions
277
278 class PEGASUS_COMPILER_LINKAGE LexerError : public Exception {
279 public:
280 static const char MSG[];
281 LexerError(const String &lexerr) : Exception(MSG + lexerr) {}
282 };
283
284 #endif
|
285 karl 1.35
|
286 mike 1.11
287
|