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