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