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