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