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

  1 karl  1.14 /*//%2006////////////////////////////////////////////////////////////////////////
  2 karl  1.10 //
  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.14 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 karl  1.10 //
 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.14 //============================================================================*/
 31            
 32 humberto 1.9  /* 
 33                  This file describes the language tokens possible for CQL. When a token is matched,
 34               	the token postion is updated in the CQL_globalParserState, copying from the lex buffer
 35               	to a shared buffer (shared with the lexer and parser) may happen, then a token identifier
 36               	is returned to the parser.
 37               
 38               */	
 39               
 40 chuck    1.2  %option never-interactive
 41               %{
 42               extern int CQLInput(char* buffer, int& numRead, int numRequested);
 43               extern int CQL_error(const char*);
 44               
 45               #ifdef CQLINPUT
 46               #define YY_INPUT(BUF, NREAD, NREQUESTED) CQLInput(BUF, NREAD, NREQUESTED)
 47               #endif
 48               
 49               #ifdef CQL_DEBUG_LEXER
 50               #define DEBUG_LEX 1
 51               #else
 52               #define DEBUG_LEX 0
 53               #endif
 54               
 55               #include <Pegasus/Common/Config.h>
 56 chuck    1.12 #include <Pegasus/Common/CommonUTF.h>
 57               #include <Pegasus/Common/MessageLoader.h>
 58 chuck    1.2  #include "CQLParserState.h"
 59               #include <stdlib.h>
 60               #include <stdio.h>
 61               #include <cstring>
 62               #include "CQLObjects.h"
 63               #include "CQLYACC.h"
 64               PEGASUS_NAMESPACE_BEGIN
 65                                                                                               
 66 humberto 1.8  extern CQLParserState* CQL_globalParserState;
 67 chuck    1.2                                                                                  
 68               PEGASUS_NAMESPACE_END
 69 lucier   1.13 static char msg_[100];
 70 chuck    1.2  void printf__(char * msg){
 71                       if(DEBUG_LEX == 1)
 72                               printf("%s\n",msg);
 73               }
 74               
 75               int lineno;
 76               
 77               %}
 78               SIGN [+-]
 79               BINARY_DIGIT [01]
 80               HEX_DIGIT [A-Fa-f0-9]
 81               HEX_IDENT 0[Xx]
 82               POSITIVE_DECIMAL_DIGIT [1-9]
 83               DECIMAL_DIGIT [0-9]
 84               BLANK [ \t]
 85               IDENT_CHAR [0-9A-Za-z_\x80-\xFF]
 86 humberto 1.9  IDENT_CHAR_1 [0-9A-Za-z_\x80-\xFF]
 87               IDENT_CHAR_NO_NUM [A-Za-z_\x80-\xFF]
 88 chuck    1.2  PROP_CHAR [A-Za-z0-9_\[\]\-\#\']
 89               
 90               A [Aa]
 91               B [Bb]
 92               C [Cc]
 93               D [Dd]
 94               E [Ee]
 95               F [Ff]
 96               G [Gg]
 97               H [Hh]
 98               I [Ii]
 99               J [Jj]
100               K [Kk]
101               L [Ll]
102               M [Mm]
103               N [Nn]
104               O [Oo]
105               P [Pp]
106               Q [Qq]
107               R [Rr]
108               S [Ss]
109 chuck    1.2  T [Tt]
110               U [Uu]
111               V [Vv]
112               W [Ww]
113               X [Xx]
114               Y [Yy]
115               Z [Zz]
116               
117               %%
118               
119               {S}{E}{L}{E}{C}{T} {
120               
121                   sprintf(msg_,"LEX: %s [SELECT] ", yytext);
122                   printf__(msg_);
123 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;    
124                   CQL_globalParserState->tokenCount++;
125 chuck    1.2      return SELECT;
126               }
127               
128               {F}{R}{O}{M} {
129               
130                   sprintf(msg_,"LEX: %s [FROM] ", yytext);
131                   printf__(msg_);
132 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
133                   CQL_globalParserState->tokenCount++;
134 chuck    1.2      return FROM;
135               }
136               
137               {W}{H}{E}{R}{E} {
138               
139                   sprintf(msg_,"LEX: %s [WHERE] ", yytext);
140                   printf__(msg_);
141 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
142                   CQL_globalParserState->tokenCount++;
143 chuck    1.2      return WHERE;
144               }
145               
146               {A}{N}{Y} {
147               
148                   sprintf(msg_,"LEX: %s [ANY] ", yytext);
149                   printf__(msg_);
150 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
151                   CQL_globalParserState->tokenCount++;
152 chuck    1.2      return ANY;
153               }
154               
155               {A}{S} {
156                   sprintf(msg_,"LEX: %s [AS] ", yytext);
157                   printf__(msg_);
158 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
159                   CQL_globalParserState->tokenCount++;
160 chuck    1.2      return AS;
161               }
162               
163               {A}{S}{C} {
164                   sprintf(msg_,"LEX: %s [ASC] ", yytext);
165                   printf__(msg_);
166 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
167                   CQL_globalParserState->tokenCount++;
168 chuck    1.2      return ASC;
169               }
170               
171               {B}{Y} {
172                   sprintf(msg_,"LEX: %s [BY] ", yytext);
173                   printf__(msg_);
174 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
175                   CQL_globalParserState->tokenCount++;
176 chuck    1.2      return BY;
177               }
178               
179               {D}{E}{S}{C} {
180                   sprintf(msg_,"LEX: %s [DESC] ", yytext);
181                   printf__(msg_);
182 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
183                   CQL_globalParserState->tokenCount++;
184 chuck    1.2      return DESC;
185               }
186               
187               
188               {D}{I}{S}{T}{I}{N}{C}{T} {
189                   sprintf(msg_,"LEX: %s [DISTINCT] ", yytext);
190                   printf__(msg_);
191 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
192                   CQL_globalParserState->tokenCount++;
193 chuck    1.2      return DISTINCT;
194               }
195               
196               {E}{V}{E}{R}{Y} {
197                   sprintf(msg_,"LEX: %s [EVERY] ", yytext);
198                   printf__(msg_);
199 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
200                   CQL_globalParserState->tokenCount++;
201 chuck    1.2      return EVERY;
202               }
203               
204               {F}{I}{R}{S}{T} {
205                   sprintf(msg_,"LEX: %s [FIRST] ", yytext);
206                   printf__(msg_);
207 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
208                   CQL_globalParserState->tokenCount++;
209 chuck    1.2      return FIRST;
210               }
211               
212               {I}{N} {
213                   sprintf(msg_,"LEX: %s [IN] ", yytext);
214                   printf__(msg_);
215 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
216                   CQL_globalParserState->tokenCount++;
217 chuck    1.2      return IN;
218               }
219               
220               {I}{S} {
221                   sprintf(msg_,"LEX: %s [IS] ", yytext);
222                   printf__(msg_);
223 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
224                   CQL_globalParserState->tokenCount++;
225 chuck    1.2      return IS;
226               }
227               
228               {I}{S}{A} {
229                   sprintf(msg_,"LEX: %s [ISA] ", yytext);
230                   printf__(msg_);
231 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
232                   CQL_globalParserState->tokenCount++;
233 chuck    1.2      return _ISA;
234               }
235               
236               {L}{I}{K}{E} {
237                   sprintf(msg_,"LEX: %s [LIKE] ", yytext);
238                   printf__(msg_);
239 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
240                   CQL_globalParserState->tokenCount++;
241 chuck    1.2      return _LIKE;
242               }
243               
244               {O}{R}{D}{E}{R} {
245                   sprintf(msg_,"LEX: %s [ORDER] ", yytext);
246                   printf__(msg_);
247 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
248                   CQL_globalParserState->tokenCount++;
249 chuck    1.2      return ORDER;
250               }
251               
252               {S}{A}{T}{I}{S}{F}{I}{E}{S} {
253                   sprintf(msg_,"LEX: %s [SATISFIES] ", yytext);
254                   printf__(msg_);
255 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
256                   CQL_globalParserState->tokenCount++;
257 chuck    1.2      return SATISFIES;
258               }
259               
260               {T}{R}{U}{E} {
261                   sprintf(msg_,"LEX: %s [_TRUE] ", yytext);
262                   printf__(msg_);
263 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
264                   CQL_globalParserState->tokenCount++;
265 chuck    1.2      return _TRUE;
266               }
267               
268               {F}{A}{L}{S}{E} {
269                   sprintf(msg_,"LEX: %s [_FALSE] ", yytext);
270                   printf__(msg_);
271 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
272                   CQL_globalParserState->tokenCount++;
273 chuck    1.2      return _FALSE;
274               }
275               
276               {N}{U}{L}{L} {
277                   sprintf(msg_,"LEX: %s [_NULL] ", yytext);
278                   printf__(msg_);
279 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
280                   CQL_globalParserState->tokenCount++;
281 chuck    1.2      return _NULL;
282               }
283               
284               {N}{O}{T} {
285                   sprintf(msg_,"LEX: %s [NOT] ", yytext);
286                   printf__(msg_);
287 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
288                   CQL_globalParserState->tokenCount++;
289 chuck    1.2      return NOT;
290               }
291               
292               {A}{N}{D} {
293                   sprintf(msg_,"LEX: %s [AND] ", yytext);
294                   printf__(msg_);
295 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
296                   CQL_globalParserState->tokenCount++;
297 chuck    1.2      return _AND;
298               }
299               
300               {O}{R} {
301                   sprintf(msg_,"LEX: %s [OR] ", yytext);
302                   printf__(msg_);
303 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
304                   CQL_globalParserState->tokenCount++;
305 chuck    1.2      return _OR;
306               }
307               
308 humberto 1.9  {IDENT_CHAR_NO_NUM}{IDENT_CHAR}*\:\:{IDENT_CHAR_NO_NUM}({IDENT_CHAR}*|{IDENT_CHAR}*\[.*\]|{IDENT_CHAR}*#\'.*\') {
309 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
310                   CQL_globalParserState->tokenCount++;
311 humberto 1.4  	 /* remove any single quotes surrounding embedded literals */
312 humberto 1.5  	 size_t n;
313               	 if(CQL_lval.strValue)
314               	         delete [] CQL_lval.strValue;
315 chuck    1.12 
316                   // chuck
317                   if (!isUTF8Str(yytext))
318                   {	
319                       sprintf(msg_,"LEX: [STRING]-> BAD UTF\n");
320                       printf__(msg_);
321                       throw CQLSyntaxErrorException(
322                                                     MessageLoaderParms(String("CQL.CQL_y.BAD_UTF8"),
323                                                     String("Bad UTF8 encountered parsing rule $0 in position $1."),
324                                                     String("identifier"),
325                                                     CQL_globalParserState->currentTokenPos));
326                   }
327 humberto 1.5  				
328 humberto 1.4  	 String s(yytext);
329 humberto 1.5  	 Uint32 index = s.find("'");
330 humberto 1.4  	 if(index != PEG_NOT_FOUND){
331               	 	s.remove(index,1);
332               		s.remove(s.size()-1,1);
333               		CString cstr = s.getCString();
334 humberto 1.5  	 	const char* string = (const char*)cstr;
335               		n = strlen(string);
336               		CQL_lval.strValue = new char[n+1];
337               		memcpy(CQL_lval.strValue, string, n);
338               	 }else{
339               	 	n = strlen(yytext);
340               		CQL_lval.strValue = new char[n+1];
341                     memcpy(CQL_lval.strValue, yytext, n);
342 humberto 1.4  	 }
343 chuck    1.2      CQL_lval.strValue[n] = '\0';
344                   sprintf(msg_,"LEX: %s [SCOPED_PROPERTY] ", CQL_lval.strValue);
345                   printf__(msg_);
346               
347                   return SCOPED_PROPERTY;
348               }
349               
350               [-]{1}[0][Xx]{HEX_DIGIT}{HEX_DIGIT}* {
351                   sprintf(msg_,"LEX: %s [NEGATIVE_HEXADECIMAL] ", yytext);
352                   printf__(msg_);
353 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
354                   CQL_globalParserState->tokenCount++;
355 chuck    1.2      /* copy the hex value */
356                   {
357                       size_t n = strlen(yytext);
358               	if(CQL_lval.strValue)
359               		delete [] CQL_lval.strValue;
360                       CQL_lval.strValue = new char[n + 1];
361                       memcpy(CQL_lval.strValue, yytext, n);
362                       CQL_lval.strValue[n] = '\0';
363                   }
364                   return NEGATIVE_HEXADECIMAL;
365               }
366               
367               [+]?[0][Xx]{HEX_DIGIT}{HEX_DIGIT}* {
368                   sprintf(msg_,"LEX: %s [HEXADECIMAL] ", yytext);
369                   printf__(msg_);
370 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
371                   CQL_globalParserState->tokenCount++;
372 chuck    1.2      /* copy the hex value */
373                   {
374                       size_t n = strlen(yytext);
375                       if(CQL_lval.strValue)
376                               delete [] CQL_lval.strValue;
377                       CQL_lval.strValue = new char[n + 1];
378                       memcpy(CQL_lval.strValue, yytext, n);
379                       CQL_lval.strValue[n] = '\0';
380                   }
381                   return HEXADECIMAL;
382               }
383               
384               [-]{1}{BINARY_DIGIT}{BINARY_DIGIT}*{B} {
385                   sprintf(msg_,"LEX: %s [NEGATIVE_BINARY] ", yytext);
386                   printf__(msg_);
387 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
388                   CQL_globalParserState->tokenCount++;
389 chuck    1.2      /* copy the bin value */ 
390                   {
391                       size_t n = strlen(yytext);
392               	if(CQL_lval.strValue)
393                               delete [] CQL_lval.strValue;
394                       CQL_lval.strValue = new char[n + 1];
395                       memcpy(CQL_lval.strValue, yytext, n);
396                       CQL_lval.strValue[n] = '\0';
397                   }
398                   return NEGATIVE_BINARY;
399               }
400               
401               [+]?{BINARY_DIGIT}{BINARY_DIGIT}*{B} {
402                   sprintf(msg_,"LEX: %s [BINARY] ", yytext);
403                   printf__(msg_);
404 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
405                   CQL_globalParserState->tokenCount++;
406 chuck    1.2      /* copy the bin value */
407                   {
408                       size_t n = strlen(yytext);
409                       if(CQL_lval.strValue)
410                               delete [] CQL_lval.strValue;
411                       CQL_lval.strValue = new char[n + 1];
412                       memcpy(CQL_lval.strValue, yytext, n);
413                       CQL_lval.strValue[n] = '\0';
414                   }
415                   return BINARY;
416               }
417               
418               
419               [-]{1}{POSITIVE_DECIMAL_DIGIT}{DECIMAL_DIGIT}* {
420               
421                   sprintf(msg_,"LEX: %s [NEGATIVE_INTEGER] ", yytext);
422                   printf__(msg_);
423 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
424                   CQL_globalParserState->tokenCount++;
425 chuck    1.2      size_t n = strlen(yytext);
426                   if(CQL_lval.strValue)
427               	    delete [] CQL_lval.strValue;
428                   CQL_lval.strValue = new char[n + 1];
429                   memcpy(CQL_lval.strValue, yytext, n);
430                   CQL_lval.strValue[n] = '\0';
431               
432                   /*CQL_lval.intValue = strtol(yytext, (char**)0, 10);*/
433                   return NEGATIVE_INTEGER;
434               }
435               
436 humberto 1.9  [+]?{DECIMAL_DIGIT}+ {
437 chuck    1.2                                                                                                                                         
438                   sprintf(msg_,"LEX: %s [INTEGER] ", yytext);
439                   printf__(msg_);
440 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
441                   CQL_globalParserState->tokenCount++;
442 chuck    1.2      size_t n = strlen(yytext);
443                   if(CQL_lval.strValue)
444                           delete [] CQL_lval.strValue;
445                   CQL_lval.strValue = new char[n + 1];
446                   memcpy(CQL_lval.strValue, yytext, n);
447                   CQL_lval.strValue[n] = '\0';
448                                                                                                                                                      
449                   /*CQL_lval.intValue = strtol(yytext, (char**)0, 10);*/
450                   return INTEGER;
451               }
452               
453               [-]{1}{DECIMAL_DIGIT}*\.{DECIMAL_DIGIT}+([eE][+-]?{DECIMAL_DIGIT}+)? {
454               
455                   sprintf(msg_,"LEX: %s [NEGATIVE_REAL] ", yytext);
456                   printf__(msg_);
457 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
458                   CQL_globalParserState->tokenCount++;
459 chuck    1.2      size_t n = strlen(yytext);
460                   if(CQL_lval.strValue)
461                           delete [] CQL_lval.strValue;
462                   CQL_lval.strValue = new char[n + 1];
463                   memcpy(CQL_lval.strValue, yytext, n);
464                   CQL_lval.strValue[n] = '\0';
465               
466                   /*CQL_lval.realValue = strtod((char*)yytext, (char**)0);*/
467                   return NEGATIVE_REAL;
468               }
469               
470 humberto 1.9  ([+]?{DECIMAL_DIGIT}*\.{DECIMAL_DIGIT}+([eE][+-]?{DECIMAL_DIGIT}+)?)|([+]?{DECIMAL_DIGIT}+\.{DECIMAL_DIGIT}*([eE][+-]?{DECIMAL_DIGIT}+)?) {
471 chuck    1.2                                                                                                                                         
472                   sprintf(msg_,"LEX: %s [REAL] ", yytext);
473                   printf__(msg_);
474 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
475                   CQL_globalParserState->tokenCount++;
476 chuck    1.2      size_t n = strlen(yytext);
477                   if(CQL_lval.strValue)
478                           delete [] CQL_lval.strValue;
479                   CQL_lval.strValue = new char[n + 1];
480                   memcpy(CQL_lval.strValue, yytext, n);
481                   CQL_lval.strValue[n] = '\0';
482                                                                                                                                                      
483                   /*CQL_lval.realValue = strtod((char*)yytext, (char**)0);*/
484                   return REAL;
485               }
486               
487 humberto 1.9  \'((\\')|(\\\\)|[^'(\\')])*\' {
488 chuck    1.2  	/* \'[^\'\n]*\' */
489                   /* ATTN-B: handle long literals by using yyinput(). */
490                   /* ATTN-B: Handle expansion of special characters */
491               
492                   sprintf(msg_,"LEX: %s [STRING] ", yytext);
493                   printf__(msg_);
494 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
495                   CQL_globalParserState->tokenCount++;
496 chuck    1.2      /* remove any escaped \ OR escaped ' */
497               
498                   String _esc_doubleslash = "\\\\";
499                   String _esc_singlequote = "\\'";
500 chuck    1.12 
501                   // chuck
502                   if (!isUTF8Str(yytext))
503                   {	
504                       sprintf(msg_,"LEX: [STRING]-> BAD UTF\n");
505                       printf__(msg_);
506                       throw CQLSyntaxErrorException(
507                                                     MessageLoaderParms(String("CQL.CQL_y.BAD_UTF8"),
508                                                     String("Bad UTF8 encountered parsing rule $0 in position $1."),
509                                                     String("literal_string"),
510                                                     CQL_globalParserState->currentTokenPos));
511                   }
512               
513 chuck    1.2      String s(yytext);
514               
515                   Uint32 index = 1;
516 humberto 1.6      while((index = s.find(_esc_doubleslash)) != PEG_NOT_FOUND || 
517 humberto 1.9  	       (index = s.find(_esc_singlequote)) != PEG_NOT_FOUND)
518 humberto 1.6  	 {
519               				if(index == s.size() - 2) // make sure we dont remove the slash from say 'abc\'
520               				break;
521               				s.remove(index,1);
522 chuck    1.2      }
523                   CString cstr = s.getCString();
524                   const char* string = (const char*)cstr;
525               
526                   /* Copy the string (but remove the surrounding quotes */
527               
528                   {
529               	size_t n = strlen(string) - 2;
530               	if(CQL_lval.strValue)
531               		delete [] CQL_lval.strValue;
532               	CQL_lval.strValue = new char[n + 1];
533               	memcpy(CQL_lval.strValue, string + 1, n);
534               	CQL_lval.strValue[n] = '\0';
535                   }
536                   return STRING_LITERAL;
537               }
538               
539               \'[^\'\n]*$ {
540               
541                   sprintf(msg_,"Unterminated string");
542                   printf__(msg_);
543 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
544                   CQL_globalParserState->tokenCount++;
545 chuck    1.2  }
546               
547               \*{1} {
548                  sprintf(msg_,"LEX: [STAR] ");
549                  printf__(msg_);
550 humberto 1.8     CQL_globalParserState->currentTokenPos+=yyleng;
551                  CQL_globalParserState->tokenCount++;
552 chuck    1.2     return STAR;
553               }
554               
555               \/{1} {
556                  sprintf(msg_,"LEX: [DIV] ");
557                  printf__(msg_);
558 humberto 1.8     CQL_globalParserState->currentTokenPos+=yyleng;
559                  CQL_globalParserState->tokenCount++;
560 chuck    1.2     return DIV;
561               }
562               
563               \+{1} {
564                  sprintf(msg_,"LEX: [PLUS] ");
565                  printf__(msg_);
566 humberto 1.8     CQL_globalParserState->currentTokenPos+=yyleng;
567                  CQL_globalParserState->tokenCount++;
568 chuck    1.2     return PLUS;
569               }
570               
571               \-{1} {
572                  sprintf(msg_,"LEX: [MINUS] ");
573                  printf__(msg_);
574 humberto 1.8     CQL_globalParserState->currentTokenPos+=yyleng;
575                  CQL_globalParserState->tokenCount++;
576 chuck    1.2     return MINUS;
577               }
578               
579               \,{1} {
580                  sprintf(msg_,"LEX: [COMMA] ");
581                  printf__(msg_);
582 humberto 1.8     CQL_globalParserState->currentTokenPos+=yyleng;
583                  CQL_globalParserState->tokenCount++;
584 chuck    1.2     return COMMA;
585               }
586               
587               \.{2} {
588                   sprintf(msg_,"LEX: [DOTDOT] ");
589                   printf__(msg_);
590 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
591                   CQL_globalParserState->tokenCount++;
592 chuck    1.2      return DOTDOT;
593               }
594               
595               \#{1} {
596                   sprintf(msg_,"LEX: [HASH] ");
597                   printf__(msg_);
598 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;                                                                   
599                   CQL_globalParserState->tokenCount++;
600 chuck    1.2      return HASH;
601               }
602               
603               \.{1} {
604                   sprintf(msg_,"LEX: [DOT] ");
605                   printf__(msg_);
606 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
607                   CQL_globalParserState->tokenCount++;
608 chuck    1.2      return DOT;
609               }
610               
611               \[{1} {
612                   sprintf(msg_,"LEX: [LBRKT] ");
613                   printf__(msg_);
614 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
615                   CQL_globalParserState->tokenCount++;
616 chuck    1.2      return LBRKT;
617               }
618               
619               \]{1} {
620                   sprintf(msg_,"LEX: [RBRKT] ");
621                   printf__(msg_);
622 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
623                   CQL_globalParserState->tokenCount++;
624 chuck    1.2      return RBRKT;
625               }
626               
627               \({1} {
628                   sprintf(msg_,"LEX: [LPAR] ");
629                   printf__(msg_);
630 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
631                   CQL_globalParserState->tokenCount++;
632 chuck    1.2      return LPAR;
633               }
634               
635               \){1} {
636                   sprintf(msg_,"LEX: [RPAR] ");
637                   printf__(msg_);
638 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
639                   CQL_globalParserState->tokenCount++;
640 chuck    1.2      return RPAR;
641               }
642               
643               "||" {
644                   sprintf(msg_,"LEX: %s [DBL_PIPE] ", yytext);
645                   printf__(msg_);
646 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
647                   CQL_globalParserState->tokenCount++;
648 chuck    1.2      return DBL_PIPE;
649               }
650               
651               "_" {
652                   sprintf(msg_,"LEX: %s [UNDERSCORE] ", yytext);
653                   printf__(msg_);
654 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
655                   CQL_globalParserState->tokenCount++;
656 chuck    1.2      return UNDERSCORE;
657               }
658               
659               "=" { 
660                   sprintf(msg_,"LEX: %s [_EQ] ", yytext);
661                   printf__(msg_);
662 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
663                   CQL_globalParserState->tokenCount++;
664 chuck    1.2      return _EQ; 
665               }
666               
667 humberto 1.7  
668               "<>" { 
669 chuck    1.2  
670                   sprintf(msg_,"LEX: %s [_NE] ", yytext);
671                   printf__(msg_);
672 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
673                   CQL_globalParserState->tokenCount++;
674 chuck    1.2      return _NE; 
675               }
676               
677 humberto 1.7  
678 chuck    1.2  "<=" { 
679               
680                   sprintf(msg_,"LEX: %s [_LE] ", yytext);
681                   printf__(msg_);
682 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
683                   CQL_globalParserState->tokenCount++;
684 chuck    1.2      return _LE; 
685               }
686               
687               "<" { 
688               
689                   sprintf(msg_,"LEX: %s [_LT] ", yytext);
690                   printf__(msg_);
691 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
692                   CQL_globalParserState->tokenCount++;
693 chuck    1.2      return _LT; 
694               }
695               
696               ">=" { 
697               
698                   sprintf(msg_,"LEX: %s [_GE] ", yytext);
699                   printf__(msg_);
700 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
701                   CQL_globalParserState->tokenCount++;
702 chuck    1.2      return _GE; 
703               }
704               
705               ">" { 
706               
707                   sprintf(msg_,"LEX: %s [_GT] ", yytext);
708                   printf__(msg_);
709 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
710                   CQL_globalParserState->tokenCount++;
711 chuck    1.2      return _GT; 
712               }
713               
714 humberto 1.9  {IDENT_CHAR_NO_NUM}({IDENT_CHAR})*  {
715 chuck    1.2  
716                   sprintf(msg_,"LEX: %s [IDENTIFIER] ", yytext);
717                   printf__(msg_);
718 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
719                   CQL_globalParserState->tokenCount++;
720 chuck    1.2      {
721               	size_t n = strlen(yytext);
722               	if(CQL_lval.strValue)
723               		delete [] CQL_lval.strValue;
724               	CQL_lval.strValue = new char[n + 1];
725               	memcpy(CQL_lval.strValue, yytext, n);
726               	CQL_lval.strValue[n] = '\0';
727                   }
728               
729                   return IDENTIFIER;
730               }
731               
732               {BLANK}+ {
733               
734                   /* Ignore blanks */
735 humberto 1.8      CQL_globalParserState->currentTokenPos+=yyleng;
736 chuck    1.2  }
737               
738               \n {
739 humberto 1.8  	CQL_globalParserState->currentTokenPos=0;
740 chuck    1.2  	return 0;
741                  }
742               
743               <<EOF>> {
744                            return 0;
745                       }
746               
747               . {
748                   CQL_lval.strValue = 0;
749                   sprintf(msg_,"LEX::UNEXPECTED_CHAR\n");
750                   printf__(msg_);
751               
752                   return UNEXPECTED_CHAR;
753               }
754               
755               %%
756               extern "C" int CQL_wrap()
757               {
758                   return 1;
759               }
760               
761 chuck    1.2  

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2