1 karl 1.17 //%2004////////////////////////////////////////////////////////////////////////
|
2 mike 1.8 //
|
3 karl 1.17 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.16 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.17 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 mike 1.8 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 kumpf 1.12 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
14 mike 1.8 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
16 //
|
17 kumpf 1.12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
18 mike 1.8 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
20 kumpf 1.12 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
23 mike 1.8 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26 //==============================================================================
27 //
28 // Author: Bob Blair (bblair@bmc.com)
29 //
30 // Modified By:
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34
35 //
36 // Header for a class to generate CIMValue objects from String values
37 //
38 //
39 //
40 // This is a generic parser class from which controllers for particular
41 // yacc parsers can be derived. It keeps enough state information that
42 // you should be able to get by without a reentrant parser. You should
43 // compile both parser and lexer with a C++ compiler, although there
44 mike 1.8 // is no need to generate a C++ lexer.
45 //
46 // The include file and compile-from-String techniques used here are
47 // supported only by bison and flex.
48 //
49
50 #ifndef _PARSER_H_
51 #define _PARSER_H_
52
|
53 marek 1.15 #include <Pegasus/Common/Config.h>
|
54 mike 1.8 #include <cstdio>
55 #include <Pegasus/Common/String.h>
56 #include <Pegasus/Common/Stack.h>
|
57 kumpf 1.13 #include <Pegasus/Compiler/Linkage.h>
|
58 mike 1.8
59 PEGASUS_USING_STD;
60 PEGASUS_USING_PEGASUS;
61
|
62 kumpf 1.9 #define CIMMOF_CONSTANT_VALUE 1
63 #define CIMMOF_ARRAY_VALUE 2
64 #define CIMMOF_REFERENCE_VALUE 3
65 #define CIMMOF_NULL_VALUE 4
66
67 typedef struct typedInitializerValue {
68 Uint16 type;
69 const String *value;
70 } TYPED_INITIALIZER_VALUE;
71
|
72 mike 1.8 struct bufstate {
73 void *buffer_state; // the YY_BUFFER_STATE of the stacked context
74 String filename; // the name of the file open in the stacked context
75 int lineno; // the line number of the file
76 };
77
78 class PEGASUS_COMPILER_LINKAGE parser {
79 private:
80 unsigned int _buffer_size; // the value of the YY_BUFFER_SIZE macro
81 Stack<bufstate*> _include_stack; // a stack of YY_BUFFER_STATEs
82 String _current_filename; // name of the file being parsed
83 unsigned int _lineno; // current line number in the file
84 protected:
85 void push_statebuff(bufstate *statebuff) { _include_stack.push(statebuff); }
86 bufstate *pop_statebuff();
87 public:
88
89 // Constructor, destructor
90 parser() : _buffer_size(16384), _lineno(0) {;}
91 virtual ~parser() {;}
92
93 mike 1.8 virtual int parse() = 0; // call the parser main yy_parse()
94 virtual int wrap(); // handle the end of the current stream
95
96 int setInputBufferFromName(const String &filename); // start parsing this file
|
97 kumpf 1.14 virtual int setInputBuffer(const FILE *f,
98 Boolean closeCurrent) = 0; // start parsing this handle
|
99 mike 1.8 // int setInputBuffer(const char *buf); // start parsing this String
|
100 kumpf 1.14 virtual int setInputBuffer(void *buffstate,
101 Boolean closeCurrent) = 0; // start parsing this buffer
|
102 mike 1.8
103 // given a file stream, treat it as an include file
104 virtual int enterInlineInclude(const FILE *f) = 0;
105 virtual int wrapCurrentBuffer() = 0;
106
107 unsigned int get_buffer_size() { return _buffer_size; }
108 void set_buffer_size(unsigned int siz) { _buffer_size = siz; }
109
110 // We keep track of the filename associated with the current input
111 // buffer so we can report on it.
112 void set_current_filename(const String &filename)
113 { _current_filename = filename; }
114 const String &get_current_filename() const { return _current_filename; }
115
116 // Ditto the line number
117 void set_lineno(int n) { _lineno = n; }
118 void increment_lineno() { ++_lineno; }
119 unsigned int get_lineno() const { return _lineno; }
120
121 // This is the main entry point for parser error logging
|
122 kumpf 1.10 virtual void log_parse_error(char *token, const char *errmsg) const;
|
123 mike 1.8 };
124 #endif
|