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 #include <string>
30
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 // and the destrucot
42 static cimmofParser *_instance;
43 bob 1.1 cimmofParser();
44 ~cimmofParser();
45
46 const mofCompilerOptions *_cmdline;
47 string _includefile; // temp storage for included file to be entered
48 cimmofRepository *_repository; // the repository object to use
49 String _defaultNamespacePath; // The path we'll use if none is given
50 String _currentNamespacePath; // a namespace set from a #pragma
51 public:
52 // Provide a way for the singleton to be constructed, or a
53 // pointer to be returned:
54 static cimmofParser *Instance();
55 // Since this class became s singleton, we need to allow someone
56 // to provide us the compiler options information
57 void setCompilerOptions(const mofCompilerOptions *co);
58 const mofCompilerOptions *getCompilerOptions() const;
59 // if the command line options say we need one, establish a repository.
60 // The repository path is part of the compiler command line object
61 bool setRepository(void);
62 // Set a default root namespace path for the repository
63 void setDefaultNamespacePath(const String &path);
64 bob 1.1 void setCurrentNamespacePath(const String &path); // current override
|
66 bob 1.1 const cimmofRepository *getRepository() const;
67 const String &getDefaultNamespacePath() const;
68 const String &getCurrentNamespacePath() const;
69 const String &getNamespacePath() const;
70 // establish an input buffer given an input file stream
71 int setInputBuffer(const FILE *f);
72 // establish an input buffer given an existing context (YY_BUFFERSTATE)
73 int setInputBuffer(void *buffstate);
74
75 // Dig into an include file given its name
76 int enterInlineInclude(const String &filename);
77 // Dig into an include file given an input file stream
78 int enterInlineInclude(const FILE *f);
79 // Handle end-of-file
80 int wrapCurrentBuffer();
81 // Parse an input file
82 int parse();
83
84 // Do various representation transformations
85 // Octal character input to decimal character output
86 char *oct_to_dec(const String &octrep) const;
87 bob 1.1 // Hex character input to decimal character output
88 char *hex_to_dec(const String &hexrep) const;
89 // Binary character input to decimal character output
90 char *binary_to_dec(const String &binrep) const;
91
92 void processPragma(const String &pragmaName, const String &pragmaString);
93
94 int addClass(CIMClass *classdecl);
95 CIMClass *newClassDecl(const String &name, const String &superclass);
96
97 int addInstance(CIMInstance *instance);
98 CIMQualifierDecl *newQualifierDecl(const String &name, const CIMValue *value,
99 Uint32 scope, Uint32 flavor);
100 int addQualifier(CIMQualifierDecl *qualifier);
101
102 CIMQualifier *newQualifier(const String &name, const CIMValue &val, Uint32 flav);
103 CIMProperty *newProperty(const String &name, const CIMValue &val);
104 int applyProperty(CIMClass &c, CIMProperty &p);
105 CIMMethod *newMethod(const String &name, const CIMType type);
106 int applyMethod(CIMClass &c, CIMMethod &m);
107 CIMParameter *newParameter(const String &name, const CIMType type);
108 bob 1.1 int applyParameter(CIMMethod &method, CIMParameter &parm);
109
110 CIMValue *QualifierValue(const String &qualifierName, const String &valstr);
111
112 void addClassAlias(const String &alias, const CIMClass *cd,
113 bool isInstance);
114 void addInstanceAlias(const String &alias, const CIMInstance *cd,
115 bool isInstance);
116 };
117
118 // Exceptions
119
120 class PEGASUS_COMPILER_LINKAGE ParseError : public Exception {
121 public:
122 static const char MSG[];
123 ParseError() : Exception(MSG) {}
124 };
125
126 #endif
127
128
129 bob 1.1
|