(file) Return to WQL.l CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / WQL

  1 kumpf 1.10 /*//%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 kumpf 1.10 /* NOCHKSRC */
 33            
 34 mike  1.2  %option never-interactive
 35            %{
 36            
 37            extern int WQLInput(char* buffer, int& numRead, int numRequested);
 38 kumpf 1.3  extern int WQL_error(const char*);
 39 mike  1.2  
 40            #define YY_INPUT(BUF, NREAD, NREQUESTED) WQLInput(BUF, NREAD, NREQUESTED)
 41            
 42            #include <Pegasus/Common/Config.h>
 43            #include <Pegasus/WQL/WQLParserState.h>
 44            #include <cstring>
 45            #include <cassert>
 46            #include "WQLYACC.h"
 47            
 48            #if 0
 49            # define WQL_TRACE(X) printf X
 50            #else
 51            # define WQL_TRACE(X)
 52            #endif
 53            
 54 kumpf 1.10 /* Avoid warn_unused_result warnings in Linux RPM build */
 55 kumpf 1.11 #ifndef ECHO
 56            # define ECHO do { size_t ignored = fwrite(yytext, yyleng, 1, yyout); } while(0)
 57            #endif
 58 kumpf 1.10 
 59 mike  1.2  PEGASUS_NAMESPACE_BEGIN
 60            
 61            extern WQLParserState* globalParserState;
 62            
 63            static char* CloneString(const char* str, Uint32 size = (Uint32)-1);
 64            
 65            PEGASUS_NAMESPACE_END
 66            
 67            PEGASUS_USING_PEGASUS;
 68            
 69            %}
 70            
 71            POSITIVE_DECIMAL_DIGIT [1-9]
 72            DECIMAL_DIGIT [0-9]
 73            BLANK [ \t\n]
 74            IDENT_CHAR [A-Za-z_]
 75            
 76            %%
 77            
 78            [Ss][Ee][Ll][Ee][Cc][Tt] {
 79            
 80 mike  1.2      WQL_TRACE(("LEX: %s [TOK_SELECT]\n", yytext));
 81                return TOK_SELECT;
 82            }
 83            
 84            [Ff][Rr][Oo][Mm] {
 85            
 86                WQL_TRACE(("LEX: %s [TOK_FROM]\n", yytext));
 87                return TOK_FROM;
 88            }
 89            
 90            [Ww][Hh][Ee][Rr][Ee] {
 91            
 92                WQL_TRACE(("LEX: %s [TOK_WHERE]\n", yytext));
 93                return TOK_WHERE;
 94            }
 95            
 96 karl  1.7  [Ii][Ss][Aa] {
 97            
 98               WQL_TRACE(("LEX: %s [TOK_ISA]\n", yytext));
 99               return TOK_ISA;
100            }
101            
102 karl  1.8  "\." {
103              WQL_TRACE(("LEX: %s [TOK_DOT]\n", yytext));
104              return TOK_DOT;
105            }
106            
107            
108 karl  1.7  
109 mike  1.2  [Tt][Rr][Uu][Ee] {
110            
111                WQL_TRACE(("LEX: %s [TOK_TRUE]\n", yytext));
112                return TOK_TRUE;
113            }
114            
115            [Ff][Aa][Ll][Ss][Ee] {
116            
117                WQL_TRACE(("LEX: %s [TOK_FALSE]\n", yytext));
118                return TOK_FALSE;
119            }
120            
121            [Nn][Uu][Ll][Ll] {
122            
123                WQL_TRACE(("LEX: %s [TOK_NULL]\n", yytext));
124                return TOK_NULL;
125            }
126            
127            [Nn][Oo][Tt] {
128            
129                WQL_TRACE(("LEX: %s [TOK_NOT]\n", yytext));
130 mike  1.2      return TOK_NOT;
131            }
132            
133            [Aa][Nn][Dd] {
134            
135                WQL_TRACE(("LEX: %s [TOK_AND]\n", yytext));
136                return TOK_AND;
137            }
138            
139            [Oo][Rr] {
140            
141                WQL_TRACE(("LEX: %s [TOK_OR]\n", yytext));
142                return TOK_OR;
143            }
144            
145            [Ii][Ss] {
146            
147                WQL_TRACE(("LEX: %s [TOK_IS]\n", yytext));
148                return TOK_IS;
149            }
150            
151 mike  1.2  [-+]?{POSITIVE_DECIMAL_DIGIT}{DECIMAL_DIGIT}* {
152            
153                WQL_TRACE(("LEX: %s [TOK_INTEGER]\n", yytext));
154                WQL_lval.intValue = strtol(yytext, (char**)0, 10);
155                return TOK_INTEGER;
156            }
157            
158            [+-]?0 {
159            
160                WQL_TRACE(("LEX: %s [TOK_INTEGER]\n", yytext));
161                WQL_lval.intValue = 0;
162                return TOK_INTEGER;
163            }
164            
165            [-+]?{DECIMAL_DIGIT}*\.{DECIMAL_DIGIT}+([eE][+-]?{DECIMAL_DIGIT}+)? {
166            
167                WQL_TRACE(("LEX: %s [TOK_DOUBLE]\n", yytext));
168                WQL_lval.doubleValue = strtod((char*)yytext, (char**)0);
169                return TOK_DOUBLE;
170            }
171            
172 mike  1.2  \"[^\"\n]*\" {
173            
174                /* ATTN-B: handle long literals by using yyinput(). */
175                /* ATTN-B: Handle expansion of special characters */
176            
177                WQL_TRACE(("LEX: %s [TOK_STRING]\n", yytext));
178            
179                /* Copy the string (but remove the surrounding quotes */
180            
181                {
182            	size_t n = strlen(yytext) - 2;
183            	char* strValue = new char[n + 1];
184            	memcpy(strValue, yytext + 1, n);
185            	strValue[n] = '\0';
186            	WQL_lval.strValue = strValue;
187            	globalParserState->outstandingStrings.append(strValue);
188                }
189            
190                return TOK_STRING;
191            }
192            
193 mike  1.2  \"[^\"\n]*$ {
194            
195                WQL_error("Unterminated string");
196            }
197            
198            [\*(),] { 
199            
200                WQL_TRACE(("LEX: %c\n", yytext[0]));
201                return yytext[0];
202            }
203            
204            "=" { 
205                WQL_TRACE(("LEX: %s [TOK_EQ]\n", yytext));
206                return TOK_EQ; 
207            }
208            
209            "!=" { 
210            
211                WQL_TRACE(("LEX: %s [TOK_NE]\n", yytext));
212                return TOK_NE; 
213            }
214 mike  1.2  
215            "<=" { 
216            
217                WQL_TRACE(("LEX: %s [TOK_LE]\n", yytext));
218                return TOK_LE; 
219            }
220            
221            "<" { 
222            
223                WQL_TRACE(("LEX: %s [TOK_LT]\n", yytext));
224                return TOK_LT; 
225            }
226            
227            ">=" { 
228            
229                WQL_TRACE(("LEX: %s [TOK_GE]\n", yytext));
230                return TOK_GE; 
231            }
232            
233 karl  1.6  "<>" { 
234            
235                WQL_TRACE(("LEX: %s [TOK_NE]\n", yytext));
236                return TOK_NE; 
237            }
238            
239 mike  1.2  ">" { 
240            
241                WQL_TRACE(("LEX: %s [TOK_GT]\n", yytext));
242                return TOK_GT; 
243            }
244            
245            {IDENT_CHAR}({IDENT_CHAR}|{DECIMAL_DIGIT})*  {
246            
247                WQL_TRACE(("LEX: %s [TOK_IDENTIFIER]\n", yytext));
248            
249                {
250            	size_t n = strlen(yytext);
251            	char* strValue = new char[n + 1];
252            	memcpy(strValue, yytext, n);
253            	strValue[n] = '\0';
254            	WQL_lval.strValue = strValue;
255            	globalParserState->outstandingStrings.append(strValue);
256                }
257            
258                return TOK_IDENTIFIER;
259            }
260 mike  1.2  
261            {BLANK}+ {
262            
263                /* Ignore blanks */
264            }
265            
266            . {
267                WQL_lval.intValue = 0;
268                return TOK_UNEXPECTED_CHAR;
269            }
270            
271            %%
272            
273            extern "C" int WQL_wrap()
274            {
275                return 1;
276            }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2