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

  1 mike  1.1.2.1 %option never-interactive
  2               %{
  3               
  4 mike  1.1.2.2 extern int WQLInput(char* buffer, int& numRead, int numRequested);
  5 mike  1.1.2.3 extern int WQL_error(char*);
  6 mike  1.1.2.2 
  7               /* ATTN: works with Flex only */
  8               #define YY_INPUT(BUF, NREAD, NREQUESTED) WQLInput(BUF, NREAD, NREQUESTED)
  9               
 10 mike  1.1.2.1 #include "WQLYACC.h"
 11               #include <cstring>
 12               
 13 mike  1.1.2.3 #define WQL_TRACE(X) printf X
 14               
 15 mike  1.1.2.1 %}
 16               
 17               POSITIVE_DECIMAL_DIGIT [1-9]
 18               DECIMAL_DIGIT [0-9]
 19               BLANK [ \t\n]
 20               IDENT_CHAR [A-Za-z_]
 21               
 22               %%
 23               
 24               [Ss][Ee][Ll][Ee][Cc][Tt] {
 25               
 26 mike  1.1.2.3     WQL_TRACE(("LEX: TOK_SELECT: %s\n", yytext));
 27 mike  1.1.2.1     return TOK_SELECT;
 28               }
 29               
 30 mike  1.1.2.3 [Ff][Rr][Oo][Mm] {
 31               
 32                   WQL_TRACE(("LEX: TOK_FROM: %s\n", yytext));
 33                   return TOK_FROM;
 34               }
 35               
 36               [Ww][Hh][Ee][Rr][Ee] {
 37               
 38                   WQL_TRACE(("LEX: TOK_WHERE: %s\n", yytext));
 39                   return TOK_WHERE;
 40               }
 41               
 42               [Tt][Rr][Uu][Ee] {
 43               
 44                   WQL_TRACE(("LEX: TOK_TRUE: %s\n", yytext));
 45                   return TOK_TRUE;
 46               }
 47               
 48               [Ff][Aa][Ll][Ss][Ee] {
 49               
 50                   WQL_TRACE(("LEX: TOK_FALSE: %s\n", yytext));
 51 mike  1.1.2.3     return TOK_FALSE;
 52               }
 53               
 54               [Nn][Oo][Tt] {
 55               
 56                   WQL_TRACE(("LEX: TOK_NOT: %s\n", yytext));
 57                   return TOK_NOT;
 58               }
 59               
 60               [Aa][Nn][Dd] {
 61               
 62                   WQL_TRACE(("LEX: TOK_AND: %s\n", yytext));
 63                   return TOK_AND;
 64               }
 65               
 66               [Oo][Rr] {
 67               
 68                   WQL_TRACE(("LEX: TOK_OR: %s\n", yytext));
 69                   return TOK_OR;
 70               }
 71               
 72 mike  1.1.2.3 [Ii][Ss][Aa] {
 73               
 74                   WQL_TRACE(("LEX: TOK_ISA: %s\n", yytext));
 75                   return TOK_ISA;
 76               }
 77 mike  1.1.2.1 
 78               [-+]?{POSITIVE_DECIMAL_DIGIT}{DECIMAL_DIGIT}* {
 79               
 80 mike  1.1.2.3     WQL_TRACE(("LEX: TOK_INTEGER: %s\n", yytext));
 81 mike  1.1.2.1     WQL_lval.intValue = strtol(yytext, (char**)0, 10);
 82                   return TOK_INTEGER;
 83               }
 84               
 85               [+-]?0 {
 86               
 87 mike  1.1.2.3     WQL_TRACE(("LEX: TOK_INTEGER: %s\n", yytext));
 88 mike  1.1.2.1     WQL_lval.intValue = 0;
 89                   return TOK_INTEGER;
 90               }
 91               
 92               [-+]?{DECIMAL_DIGIT}*\.{DECIMAL_DIGIT}+([eE][+-]?{DECIMAL_DIGIT}+)? {
 93               
 94 mike  1.1.2.3     WQL_TRACE(("LEX: TOK_DOUBLE: %s\n", yytext));
 95 mike  1.1.2.1     WQL_lval.doubleValue = strtod((char*)yytext, (char**)0);
 96                   return TOK_DOUBLE;
 97               }
 98               
 99 mike  1.1.2.3 \"[^\"\n]*\" {
100 mike  1.1.2.1 
101 mike  1.1.2.3     /* ATTN: Can long string literals overflow the buffer? */
102 mike  1.1.2.1 
103 mike  1.1.2.3     WQL_TRACE(("LEX: TOK_STRING: %s\n", yytext));
104                   WQL_lval.strValue = strdup(yytext);
105                   return TOK_STRING;
106               }
107 mike  1.1.2.1 
108 mike  1.1.2.3 \"[^\"\n]*$ {
109               
110                   WQL_error("Unterminated string");
111               }
112               
113               [\*(),] { 
114               
115                   WQL_TRACE(("LEX: %c\n", yytext[0]));
116                   return yytext[0];
117               }
118               
119               "=" { 
120                   WQL_TRACE(("LEX: TOK_EQ: %s\n", yytext));
121                   return TOK_EQ; 
122               }
123               
124               "!=" { 
125               
126                   WQL_TRACE(("LEX: TOK_NE: %s\n", yytext));
127                   return TOK_NE; 
128               }
129 mike  1.1.2.3 
130               "<=" { 
131               
132                   WQL_TRACE(("LEX: TOK_LE: %s\n", yytext));
133                   return TOK_LE; 
134               }
135               
136               "<" { 
137               
138                   WQL_TRACE(("LEX: TOK_LT: %s\n", yytext));
139                   return TOK_LT; 
140               }
141               
142               ">=" { 
143               
144                   WQL_TRACE(("LEX: TOK_GE: %s\n", yytext));
145                   return TOK_GE; 
146               }
147               
148               ">" { 
149               
150 mike  1.1.2.3     WQL_TRACE(("LEX: TOK_GT: %s\n", yytext));
151                   return TOK_GT; 
152 mike  1.1.2.1 }
153               
154               {IDENT_CHAR}({IDENT_CHAR}|{DECIMAL_DIGIT})*  {
155               
156 mike  1.1.2.3     WQL_TRACE(("LEX: TOK_IDENTIFIER: %s\n", yytext));
157 mike  1.1.2.1     WQL_lval.strValue = strdup((char*)yytext);
158                   return TOK_IDENTIFIER;
159               }
160               
161               {BLANK}+ {
162               
163 mike  1.1.2.3     /* Ignore blanks */
164 mike  1.1.2.1 }
165               
166               . {
167 mike  1.1.2.3     WQL_lval.strValue = strdup((char*)yytext);
168                   return TOK_UNEXPECTED_CHAR;
169 mike  1.1.2.1 }
170               
171               %%
172               
173               extern "C" int WQL_wrap()
174               {
175                   return 1;
176               }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2