1 bob 1.1 //
2 //
3 // This header describes the cimmofParser class.
4 // It is a singleton, and can only be accessed via the pointer
5 // returned by its static Intance() method.
6 // //
7 // The instance of this
8 // class hold enough state information that there should be no need for
9 // the underlying YACC parser to be written reentrant.
10 //
11 // The YACCer (and LExer) communicate with the instance of this class
12 // via the ointer returned by the Instance() method.
13 //
14 // This specialization contains a reference to the containing program's
15 // mofComplerCmdLine object, which holds the command line arguments
16 // including the list of directories to search to find included mof files
17 //
18
19 #ifndef _CIMMOFPARSER_H_
20 #define _CIMMOFPARSER_H_
21
22 bob 1.1
23 #include "parser.h"
24 #include "mofCompilerOptions.h"
25 #include "cimmofRepository.h"
26 #include <Pegasus/Common/Config.h>
27 #include <Pegasus/Common/Exception.h>
28 #include "memobjs.h"
|
29 bob 1.3 #include "objname.h"
|
30 bob 1.1
31 extern int cimmof_parse(); // the yacc parser entry point
32
33 using namespace std;
34
35 class cimmofRepository;
36
37 // This class extends class parser (see parser.h)
38 class PEGASUS_COMPILER_LINKAGE cimmofParser : public parser {
39 private:
40 // This is meant to be a singleton, so we hide the constructor
|
41 bob 1.3 // and the destructor
|
42 bob 1.1 static cimmofParser *_instance;
43 cimmofParser();
44 ~cimmofParser();
|
45 bob 1.3 void elog(const String &msg) const; // handle logging of warnings
46 void wlog(const String &msg) const; // handle logging of warnings
47 void trace(const String &head, const String &tail) const;
48 //either throw us out or retry depending on user preference
49 void maybeThrowParseError(const String &msg) const;
50 void maybeThrowLexerError(const String &msg) const;
|
51 bob 1.1
|
52 bob 1.3 // Here are the members added by this specialization
|
53 bob 1.1 const mofCompilerOptions *_cmdline;
|
54 mike 1.5 String _includefile; // temp storage for included file to be entered
|
55 bob 1.1 cimmofRepository *_repository; // the repository object to use
56 String _defaultNamespacePath; // The path we'll use if none is given
57 String _currentNamespacePath; // a namespace set from a #pragma
58 public:
59 // Provide a way for the singleton to be constructed, or a
60 // pointer to be returned:
61 static cimmofParser *Instance();
|
62 bob 1.3
63 //------------------------------------------------------------------
64 // Methods for manipulating the members added in this specialization
65 //------------------------------------------------------------------
66 // compiler options. This may be set from command line data,
67 // or by an embedding application
|
68 bob 1.1 void setCompilerOptions(const mofCompilerOptions *co);
69 const mofCompilerOptions *getCompilerOptions() const;
|
70 bob 1.3 // for all, or nearly all, operations, a repository object is needed
|
71 bob 1.1 bool setRepository(void);
|
72 bob 1.3 const cimmofRepository *getRepository() const;
73 // Set a default root namespace path to pass to the repository
74 void setDefaultNamespacePath(const String &path); // default value
|
75 bob 1.1 void setCurrentNamespacePath(const String &path); // current override
76 const String &getDefaultNamespacePath() const;
77 const String &getCurrentNamespacePath() const;
|
78 bob 1.3 // Get the effective namespace path -- the override, if there is one.
|
79 bob 1.1 const String &getNamespacePath() const;
|
80 bob 1.3 //------------------------------------------------------------------
81 // Methods that implement or override base class methods
82 //------------------------------------------------------------------
|
83 bob 1.1 // establish an input buffer given an input file stream
84 int setInputBuffer(const FILE *f);
85 // establish an input buffer given an existing context (YY_BUFFERSTATE)
86 int setInputBuffer(void *buffstate);
87 // Dig into an include file given its name
88 int enterInlineInclude(const String &filename);
89 // Dig into an include file given an input file stream
90 int enterInlineInclude(const FILE *f);
91 // Handle end-of-file
92 int wrapCurrentBuffer();
93 // Parse an input file
94 int parse();
|
95 bob 1.3 // Log a parser error
96 void log_parse_error(char *token, char *errmsg) const;
|
97 bob 1.1
|
98 bob 1.3 //------------------------------------------------------------------
99 // Do various representation transformations.
100 // These are in this class simply because there wasn't another
101 // conventient place for them. They could just as well be static
102 // methods of some convenience class.
103 //------------------------------------------------------------------
|
104 bob 1.1 // Octal character input to decimal character output
105 char *oct_to_dec(const String &octrep) const;
106 // Hex character input to decimal character output
107 char *hex_to_dec(const String &hexrep) const;
108 // Binary character input to decimal character output
109 char *binary_to_dec(const String &binrep) const;
110
|
111 bob 1.3 //------------------------------------------------------------------
112 // Handle the processing of CIM-specific constructs
113 //------------------------------------------------------------------
114 // This is called after a completed #pragma production is formed
|
115 bob 1.1 void processPragma(const String &pragmaName, const String &pragmaString);
|
116 bob 1.3 // This is called when a completed class declaration production is formed
|
117 bob 1.1 int addClass(CIMClass *classdecl);
|
118 bob 1.3 // This is called when a new class declaration heading is discovered
|
119 bob 1.1 CIMClass *newClassDecl(const String &name, const String &superclass);
|
120 bob 1.3 // Called when a completed instanace declaration production is formed
|
121 bob 1.1 int addInstance(CIMInstance *instance);
|
122 bob 1.3 // Called when a new qualifier declaration heading is discovered
|
123 bob 1.1 CIMQualifierDecl *newQualifierDecl(const String &name, const CIMValue *value,
124 Uint32 scope, Uint32 flavor);
|
125 bob 1.3 // Called when a completed qualifier declaration production is formed
|
126 bob 1.1 int addQualifier(CIMQualifierDecl *qualifier);
|
127 bob 1.3 // Called when a new qualifier declaration heading is discovered
128 CIMQualifier *newQualifier(const String &name, const CIMValue &val,
129 Uint32 flav);
|
130 bob 1.4 // Called when a new instance declaration heading is discovered
131 CIMInstance *newInstance(const String &name);
|
132 bob 1.3 // Called when a new property is discovered
133 CIMProperty *newProperty(const String &name, const CIMValue &val,
|
134 bob 1.4 const String &referencedObj = String::EMPTY) const;
|
135 bob 1.3 // Called when a property production inside a class is complete
|
136 bob 1.1 int applyProperty(CIMClass &c, CIMProperty &p);
|
137 bob 1.3 // Called when a property production inside an instance is complete
138 int applyProperty(CIMInstance &instance, CIMProperty &p);
139 // Called when a new method is discovered
|
140 bob 1.1 CIMMethod *newMethod(const String &name, const CIMType type);
|
141 bob 1.3 // Called when a method production inside a class is complete
|
142 bob 1.1 int applyMethod(CIMClass &c, CIMMethod &m);
|
143 bob 1.3 // Called when a method parameter is discovered
144 CIMParameter *newParameter(const String &name, const CIMType type,
145 bool isArray=false, Uint32 array=0,
146 const String &objName=String::EMPTY);
147 // Called when a method parameter production is complete
|
148 bob 1.1 int applyParameter(CIMMethod &method, CIMParameter &parm);
|
149 bob 1.3 // Called when a qualifier value production is complete
150 CIMValue *QualifierValue(const String &qualifierName, const String &valstr);
151 // Called to retrieve the value object for an existing parameter
|
152 bob 1.4 CIMProperty *PropertyFromInstance(CIMInstance &instance,
|
153 bob 1.3 const String &propertyName) const;
154 CIMValue *ValueFromProperty(const CIMProperty &prop) const;
|
155 bob 1.4 CIMValue *PropertyValueFromInstance(CIMInstance &instance,
|
156 bob 1.3 const String &propertyName) const;
157 // Called when a class alias is found
|
158 bob 1.1 void addClassAlias(const String &alias, const CIMClass *cd,
159 bool isInstance);
|
160 bob 1.3 // Called when an instance alias is found
|
161 bob 1.1 void addInstanceAlias(const String &alias, const CIMInstance *cd,
162 bool isInstance);
|
163 bob 1.3 // Called when a reference declaration is found
164 CIMReference *newReference(const Pegasus::objectName &oname);
165 // Make a clone of a property object, inserting a new value object
166 CIMProperty *copyPropertyWithNewValue(const CIMProperty &p,
167 const CIMValue &v) const;
|
168 bob 1.1 };
169
170 // Exceptions
171
172 class PEGASUS_COMPILER_LINKAGE ParseError : public Exception {
173 public:
174 static const char MSG[];
|
175 bob 1.3 ParseError(const String &msg) : Exception(MSG + msg) {}
176 };
177
178 class PEGASUS_COMPILER_LINKAGE LexerError : public Exception {
179 public:
180 static const char MSG[];
181 LexerError(const String &lexerr) : Exception(MSG + lexerr) {}
|
182 bob 1.1 };
183
184 #endif
185
186
187
|