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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2