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