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 kumpf 1.20 #include <Pegasus/Compiler/Linkage.h>
|
60 mike 1.11 #include "memobjs.h"
61 #include "objname.h"
62
63 extern int cimmof_parse(); // the yacc parser entry point
64
|
65 bob 1.15 //class cimmofRepository;
|
66 mike 1.11
67 // This class extends class parser (see parser.h)
68 class PEGASUS_COMPILER_LINKAGE cimmofParser : public parser {
69 private:
70 // This is meant to be a singleton, so we hide the constructor
71 // and the destructor
72 static cimmofParser *_instance;
73 cimmofParser();
74 ~cimmofParser();
75 void trace(const String &head, const String &tail) const;
76 //either throw us out or retry depending on user preference
77 void maybeThrowParseError(const String &msg) const;
78 void maybeThrowLexerError(const String &msg) const;
79
80 // Here are the members added by this specialization
81 const mofCompilerOptions *_cmdline;
82 String _includefile; // temp storage for included file to be entered
|
83 bob 1.15 cimmofRepositoryInterface _repository; // the repository interface object
|
84 mike 1.11 String _defaultNamespacePath; // The path we'll use if none is given
85 String _currentNamespacePath; // a namespace set from a #pragma
|
86 bob 1.12 compilerCommonDefs::operationType _ot;
|
87 mike 1.11 public:
88 // Provide a way for the singleton to be constructed, or a
89 // pointer to be returned:
90 static cimmofParser *Instance();
|
91 bob 1.15 void elog(const String &msg) const; // handle logging of errors
92 void wlog(const String &msg) const; // handle logging of warnings
|
93 mike 1.11
94 //------------------------------------------------------------------
95 // Methods for manipulating the members added in this specialization
96 //------------------------------------------------------------------
97 // compiler options. This may be set from command line data,
98 // or by an embedding application
99 void setCompilerOptions(const mofCompilerOptions *co);
100 const mofCompilerOptions *getCompilerOptions() const;
101 // for all, or nearly all, operations, a repository object is needed
102 Boolean setRepository(void);
|
103 bob 1.15 const cimmofRepositoryInterface *getRepository() const;
|
104 bob 1.12 // Whether you need a repository or not depends on the operationsType
105 void setOperationType(compilerCommonDefs::operationType);
106 compilerCommonDefs::operationType getOperationType() const;
|
107 mike 1.11 // Set a default root namespace path to pass to the repository
108 void setDefaultNamespacePath(const String &path); // default value
109 void setCurrentNamespacePath(const String &path); // current override
110 const String &getDefaultNamespacePath() const;
111 const String &getCurrentNamespacePath() const;
112 // Get the effective namespace path -- the override, if there is one.
113 const String &getNamespacePath() const;
114 //------------------------------------------------------------------
115 // Methods that implement or override base class methods
116 //------------------------------------------------------------------
117 // establish an input buffer given an input file stream
118 int setInputBuffer(const FILE *f);
119 // establish an input buffer given an existing context (YY_BUFFERSTATE)
120 int setInputBuffer(void *buffstate);
121 // Dig into an include file given its name
122 int enterInlineInclude(const String &filename);
123 // Dig into an include file given an input file stream
124 int enterInlineInclude(const FILE *f);
125 // Handle end-of-file
126 int wrapCurrentBuffer();
127 // Parse an input file
128 mike 1.11 int parse();
129 // Log a parser error
|
130 kumpf 1.17 void log_parse_error(char *token, const char *errmsg) const;
|
131 mike 1.11
132 //------------------------------------------------------------------
133 // Do various representation transformations.
134 // These are in this class simply because there wasn't another
135 // conventient place for them. They could just as well be static
136 // methods of some convenience class.
137 //------------------------------------------------------------------
138 // Octal character input to decimal character output
139 char *oct_to_dec(const String &octrep) const;
140 // Hex character input to decimal character output
141 char *hex_to_dec(const String &hexrep) const;
142 // Binary character input to decimal character output
143 char *binary_to_dec(const String &binrep) const;
144
145 //------------------------------------------------------------------
146 // Handle the processing of CIM-specific constructs
147 //------------------------------------------------------------------
148 // This is called after a completed #pragma production is formed
149 void processPragma(const String &pragmaName, const String &pragmaString);
150 // This is called when a completed class declaration production is formed
151 int addClass(CIMClass *classdecl);
152 mike 1.11 // This is called when a new class declaration heading is discovered
|
153 kumpf 1.21 CIMClass *newClassDecl(const CIMName &name, const CIMName &superclass);
|
154 mike 1.11 // Called when a completed instanace declaration production is formed
155 int addInstance(CIMInstance *instance);
156 // Called when a new qualifier declaration heading is discovered
157 CIMQualifierDecl *newQualifierDecl(const String &name, const CIMValue *value,
158 Uint32 scope, Uint32 flavor);
159 // Called when a completed qualifier declaration production is formed
160 int addQualifier(CIMQualifierDecl *qualifier);
161 // Called when a new qualifier declaration heading is discovered
162 CIMQualifier *newQualifier(const String &name, const CIMValue &val,
163 Uint32 flav);
164 // Called when a new instance declaration heading is discovered
165 CIMInstance *newInstance(const String &name);
166 // Called when a new property is discovered
|
167 kumpf 1.21 CIMProperty *newProperty(const CIMName &name, const CIMValue &val,
|
168 karl 1.14 const Boolean isArray,
169 const Uint32 arraySize,
|
170 kumpf 1.21 const CIMName &referencedObj = CIMName()) const;
|
171 mike 1.11 // Called when a property production inside a class is complete
172 int applyProperty(CIMClass &c, CIMProperty &p);
173 // Called when a property production inside an instance is complete
174 int applyProperty(CIMInstance &instance, CIMProperty &p);
175 // Called when a new method is discovered
|
176 kumpf 1.21 CIMMethod *newMethod(const CIMName &name, const CIMType type);
|
177 mike 1.11 // Called when a method production inside a class is complete
178 int applyMethod(CIMClass &c, CIMMethod &m);
179 // Called when a method parameter is discovered
|
180 kumpf 1.21 CIMParameter *newParameter(const CIMName &name, const CIMType type,
|
181 mike 1.11 Boolean isArray=false, Uint32 array=0,
|
182 kumpf 1.21 const CIMName &objName=CIMName());
|
183 mike 1.11 // Called when a method parameter production is complete
184 int applyParameter(CIMMethod &method, CIMParameter &parm);
185 // Called when a qualifier value production is complete
|
186 kumpf 1.17 CIMValue *QualifierValue(const String &qualifierName,
187 Boolean isNull, const String &valstr);
|
188 mike 1.11 // Called to retrieve the value object for an existing parameter
189 CIMProperty *PropertyFromInstance(CIMInstance &instance,
190 const String &propertyName) const;
191 CIMValue *ValueFromProperty(const CIMProperty &prop) const;
192 CIMValue *PropertyValueFromInstance(CIMInstance &instance,
193 const String &propertyName) const;
194 // Called when a class alias is found
195 void addClassAlias(const String &alias, const CIMClass *cd,
196 Boolean isInstance);
197 // Called when an instance alias is found
198 void addInstanceAlias(const String &alias, const CIMInstance *cd,
199 Boolean isInstance);
200 // Called when a reference declaration is found
|
201 kumpf 1.18 CIMObjectPath *newReference(const objectName &oname);
|
202 mike 1.11 // Make a clone of a property object, inserting a new value object
203 CIMProperty *copyPropertyWithNewValue(const CIMProperty &p,
204 const CIMValue &v) const;
205 };
206
207 // Exceptions
208
209 class PEGASUS_COMPILER_LINKAGE LexerError : public Exception {
210 public:
211 static const char MSG[];
212 LexerError(const String &lexerr) : Exception(MSG + lexerr) {}
213 };
214
215 #endif
216
217
218
|