1 karl 1.9 /*//%2006////////////////////////////////////////////////////////////////////////
|
2 karl 1.4 //
3 // 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 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.9 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 karl 1.4 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
|
30 karl 1.9 //============================================================================*/
31
|
32 mike 1.2 %option never-interactive
33 %{
34
35 extern int WQLInput(char* buffer, int& numRead, int numRequested);
|
36 kumpf 1.3 extern int WQL_error(const char*);
|
37 mike 1.2
38 #define YY_INPUT(BUF, NREAD, NREQUESTED) WQLInput(BUF, NREAD, NREQUESTED)
39
40 #include <Pegasus/Common/Config.h>
41 #include <Pegasus/WQL/WQLParserState.h>
42 #include <cstring>
43 #include <cassert>
44 #include "WQLYACC.h"
45
46 #if 0
47 # define WQL_TRACE(X) printf X
48 #else
49 # define WQL_TRACE(X)
50 #endif
51
52 PEGASUS_NAMESPACE_BEGIN
53
54 extern WQLParserState* globalParserState;
55
56 static char* CloneString(const char* str, Uint32 size = (Uint32)-1);
57
58 mike 1.2 PEGASUS_NAMESPACE_END
59
60 PEGASUS_USING_PEGASUS;
61
62 %}
63
64 POSITIVE_DECIMAL_DIGIT [1-9]
65 DECIMAL_DIGIT [0-9]
66 BLANK [ \t\n]
67 IDENT_CHAR [A-Za-z_]
68
69 %%
70
71 [Ss][Ee][Ll][Ee][Cc][Tt] {
72
73 WQL_TRACE(("LEX: %s [TOK_SELECT]\n", yytext));
74 return TOK_SELECT;
75 }
76
77 [Ff][Rr][Oo][Mm] {
78
79 mike 1.2 WQL_TRACE(("LEX: %s [TOK_FROM]\n", yytext));
80 return TOK_FROM;
81 }
82
83 [Ww][Hh][Ee][Rr][Ee] {
84
85 WQL_TRACE(("LEX: %s [TOK_WHERE]\n", yytext));
86 return TOK_WHERE;
87 }
88
|
89 karl 1.7 [Ii][Ss][Aa] {
90
91 WQL_TRACE(("LEX: %s [TOK_ISA]\n", yytext));
92 return TOK_ISA;
93 }
94
|
95 karl 1.8 "\." {
96 WQL_TRACE(("LEX: %s [TOK_DOT]\n", yytext));
97 return TOK_DOT;
98 }
99
100
|
101 karl 1.7
|
102 mike 1.2 [Tt][Rr][Uu][Ee] {
103
104 WQL_TRACE(("LEX: %s [TOK_TRUE]\n", yytext));
105 return TOK_TRUE;
106 }
107
108 [Ff][Aa][Ll][Ss][Ee] {
109
110 WQL_TRACE(("LEX: %s [TOK_FALSE]\n", yytext));
111 return TOK_FALSE;
112 }
113
114 [Nn][Uu][Ll][Ll] {
115
116 WQL_TRACE(("LEX: %s [TOK_NULL]\n", yytext));
117 return TOK_NULL;
118 }
119
120 [Nn][Oo][Tt] {
121
122 WQL_TRACE(("LEX: %s [TOK_NOT]\n", yytext));
123 mike 1.2 return TOK_NOT;
124 }
125
126 [Aa][Nn][Dd] {
127
128 WQL_TRACE(("LEX: %s [TOK_AND]\n", yytext));
129 return TOK_AND;
130 }
131
132 [Oo][Rr] {
133
134 WQL_TRACE(("LEX: %s [TOK_OR]\n", yytext));
135 return TOK_OR;
136 }
137
138 [Ii][Ss] {
139
140 WQL_TRACE(("LEX: %s [TOK_IS]\n", yytext));
141 return TOK_IS;
142 }
143
144 mike 1.2 [-+]?{POSITIVE_DECIMAL_DIGIT}{DECIMAL_DIGIT}* {
145
146 WQL_TRACE(("LEX: %s [TOK_INTEGER]\n", yytext));
147 WQL_lval.intValue = strtol(yytext, (char**)0, 10);
148 return TOK_INTEGER;
149 }
150
151 [+-]?0 {
152
153 WQL_TRACE(("LEX: %s [TOK_INTEGER]\n", yytext));
154 WQL_lval.intValue = 0;
155 return TOK_INTEGER;
156 }
157
158 [-+]?{DECIMAL_DIGIT}*\.{DECIMAL_DIGIT}+([eE][+-]?{DECIMAL_DIGIT}+)? {
159
160 WQL_TRACE(("LEX: %s [TOK_DOUBLE]\n", yytext));
161 WQL_lval.doubleValue = strtod((char*)yytext, (char**)0);
162 return TOK_DOUBLE;
163 }
164
165 mike 1.2 \"[^\"\n]*\" {
166
167 /* ATTN-B: handle long literals by using yyinput(). */
168 /* ATTN-B: Handle expansion of special characters */
169
170 WQL_TRACE(("LEX: %s [TOK_STRING]\n", yytext));
171
172 /* Copy the string (but remove the surrounding quotes */
173
174 {
175 size_t n = strlen(yytext) - 2;
176 char* strValue = new char[n + 1];
177 memcpy(strValue, yytext + 1, n);
178 strValue[n] = '\0';
179 WQL_lval.strValue = strValue;
180 globalParserState->outstandingStrings.append(strValue);
181 }
182
183 return TOK_STRING;
184 }
185
186 mike 1.2 \"[^\"\n]*$ {
187
188 WQL_error("Unterminated string");
189 }
190
191 [\*(),] {
192
193 WQL_TRACE(("LEX: %c\n", yytext[0]));
194 return yytext[0];
195 }
196
197 "=" {
198 WQL_TRACE(("LEX: %s [TOK_EQ]\n", yytext));
199 return TOK_EQ;
200 }
201
202 "!=" {
203
204 WQL_TRACE(("LEX: %s [TOK_NE]\n", yytext));
205 return TOK_NE;
206 }
207 mike 1.2
208 "<=" {
209
210 WQL_TRACE(("LEX: %s [TOK_LE]\n", yytext));
211 return TOK_LE;
212 }
213
214 "<" {
215
216 WQL_TRACE(("LEX: %s [TOK_LT]\n", yytext));
217 return TOK_LT;
218 }
219
220 ">=" {
221
222 WQL_TRACE(("LEX: %s [TOK_GE]\n", yytext));
223 return TOK_GE;
224 }
225
|
226 karl 1.6 "<>" {
227
228 WQL_TRACE(("LEX: %s [TOK_NE]\n", yytext));
229 return TOK_NE;
230 }
231
|
232 mike 1.2 ">" {
233
234 WQL_TRACE(("LEX: %s [TOK_GT]\n", yytext));
235 return TOK_GT;
236 }
237
238 {IDENT_CHAR}({IDENT_CHAR}|{DECIMAL_DIGIT})* {
239
240 WQL_TRACE(("LEX: %s [TOK_IDENTIFIER]\n", yytext));
241
242 {
243 size_t n = strlen(yytext);
244 char* strValue = new char[n + 1];
245 memcpy(strValue, yytext, n);
246 strValue[n] = '\0';
247 WQL_lval.strValue = strValue;
248 globalParserState->outstandingStrings.append(strValue);
249 }
250
251 return TOK_IDENTIFIER;
252 }
253 mike 1.2
254 {BLANK}+ {
255
256 /* Ignore blanks */
257 }
258
259 . {
260 WQL_lval.intValue = 0;
261 return TOK_UNEXPECTED_CHAR;
262 }
263
264 %%
265
266 extern "C" int WQL_wrap()
267 {
268 return 1;
269 }
|