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