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

  1 mike  1.1.2.1 /*
  2               **==============================================================================
  3               **
  4               ** Includes
  5               **
  6               **==============================================================================
  7               */
  8               
  9               %{
 10               
 11               #include <string.h>
 12               #include <stdlib.h>
 13               
 14               #ifdef PEGASUS_OS_TYPE_WINDOWS
 15               # include <malloc.h>
 16               #endif
 17               
 18               #if defined(PEGASUS_COMPILER_ACC) && defined(PEGASUS_OS_HPUX)
 19               # include <alloca.h>
 20               #endif
 21               
 22 mike  1.1.2.2 #if 0
 23               # define WQL_TRACE(X) printf(X)
 24               #else
 25               # define WQL_TRACE(X)
 26               #endif
 27               
 28 mike  1.1.2.1 extern int WQL_lex();
 29               extern int WQL_error(char*);
 30               
 31               %}
 32               
 33               /*
 34               **==============================================================================
 35               **
 36               ** Union used to pass tokens from Lexer to this Parser.
 37               **
 38               **==============================================================================
 39               */
 40               
 41               %union 
 42               {
 43                  int intValue;
 44                  double doubleValue;
 45                  char* strValue;
 46                  void* nodeValue;
 47               }
 48               
 49 mike  1.1.2.1 /*
 50               **==============================================================================
 51               **
 52               ** Tokens, types, and associative rules.
 53               **
 54               **==============================================================================
 55               */
 56               
 57               %token <intValue> TOK_INTEGER
 58               %token <doubleValue> TOK_DOUBLE
 59 mike  1.1.2.2 %token <strValue> TOK_STRING
 60               %token <intValue> TOK_TRUE
 61               %token <intValue> TOK_FALSE
 62               
 63               %token <intValue> TOK_EQ
 64               %token <intValue> TOK_NE
 65               %token <intValue> TOK_LT
 66               %token <intValue> TOK_LE
 67               %token <intValue> TOK_GT
 68               %token <intValue> TOK_GE
 69               
 70               %token <intValue> TOK_NOT
 71               %token <intValue> TOK_OR
 72               %token <intValue> TOK_AND
 73               %token <intValue> TOK_ISA
 74               
 75 mike  1.1.2.1 %token <strValue> TOK_IDENTIFIER
 76 mike  1.1.2.2 %token <intValue> TOK_SELECT
 77               %token <intValue> TOK_WHERE
 78               %token <intValue> TOK_FROM
 79               
 80               %token <strValue> TOK_UNEXPECTED_CHAR
 81 mike  1.1.2.1 
 82               %type <nodeValue> constant
 83               %type <nodeValue> property
 84               %type <nodeValue> propertyListOrStar
 85               %type <nodeValue> propertyList
 86               %type <nodeValue> expressionTerm
 87               %type <nodeValue> expression
 88               %type <nodeValue> whereClause
 89               %type <strValue> fromClass
 90               %type <nodeValue> selectStatement
 91               %type <strValue> className
 92               %type <nodeValue> function
 93               %type <nodeValue> functionParameterList
 94               %type <nodeValue> functionParameter
 95               
 96 mike  1.1.2.2 %left TOK_OR
 97               %left TOK_AND
 98               %nonassoc TOK_NOT
 99               
100               %%
101 mike  1.1.2.1 
102               /*
103               **==============================================================================
104               **
105               ** The grammar itself.
106               **
107               **==============================================================================
108               */
109               
110               start
111                   : selectStatement
112                   {
113 mike  1.1.2.2 	WQL_TRACE(("YACC: start: selectStatement\n"));
114 mike  1.1.2.1     }
115               
116               selectStatement
117                   : TOK_SELECT propertyListOrStar fromClass
118                   {
119 mike  1.1.2.2 	WQL_TRACE(("YACC: selectStatement\n"));
120 mike  1.1.2.1     } 
121                   | TOK_SELECT propertyListOrStar fromClass whereClause
122                   {
123 mike  1.1.2.2 	WQL_TRACE(("YACC: selectStatement\n"));
124 mike  1.1.2.1     }
125               
126 mike  1.1.2.2 fromClass : TOK_FROM className
127 mike  1.1.2.1     {
128 mike  1.1.2.2 	WQL_TRACE(("YACC: fromClass : TOK_FROM %s\n", $2));
129 mike  1.1.2.1 	$$ = $2;
130                   }
131               
132               className : TOK_IDENTIFIER
133                   {
134 mike  1.1.2.2 	WQL_TRACE(("YACC: className : %s\n", $1));
135 mike  1.1.2.1 	$$ = $1
136                   }
137               
138 mike  1.1.2.2 whereClause : TOK_WHERE expression
139 mike  1.1.2.1     {
140 mike  1.1.2.2 	WQL_TRACE(("YACC: whereClause : TOK_WHERE expression\n"));
141 mike  1.1.2.1     }
142               
143               propertyListOrStar 
144                   : propertyList
145                   {
146               
147                   }
148                   | '*'
149                   {
150 mike  1.1.2.2 	WQL_TRACE(("YACC: propertyListOrStar: '*'\n"));
151 mike  1.1.2.1     }
152               
153               propertyList : property
154                   {
155               
156                   }
157                   | propertyList ',' property
158                   {
159               
160                   }
161               
162               property 
163                   : TOK_IDENTIFIER
164                   {
165               
166                   }
167                   | TOK_IDENTIFIER '.' TOK_IDENTIFIER
168                   {
169               
170                   }
171               
172 mike  1.1.2.1 expression 
173 mike  1.1.2.2     : expression TOK_OR expression
174 mike  1.1.2.1     {
175               
176                   }
177 mike  1.1.2.2     | expression TOK_AND expression
178 mike  1.1.2.1     {
179               
180                   }
181 mike  1.1.2.2     | TOK_NOT expression
182 mike  1.1.2.1     {
183               
184                   }
185                   | '(' expression ')'
186                   {
187               
188                   }
189                   | expressionTerm
190                   {
191               
192                   }
193               
194               expressionTerm
195 mike  1.1.2.2     : property TOK_LT constant
196 mike  1.1.2.1     {
197               
198                   }
199 mike  1.1.2.2     | property TOK_GT constant
200 mike  1.1.2.1     {
201               
202                   }
203 mike  1.1.2.2     | property TOK_LE constant
204 mike  1.1.2.1     {
205               
206                   }
207 mike  1.1.2.2     | property TOK_GE constant
208 mike  1.1.2.1     {
209               
210                   }
211 mike  1.1.2.2     | property TOK_EQ constant
212 mike  1.1.2.1     {
213               
214                   }
215 mike  1.1.2.2     | property TOK_NE constant
216 mike  1.1.2.1     {
217               
218                   }
219 mike  1.1.2.2     | constant TOK_LT property
220 mike  1.1.2.1     {
221               
222                   }
223 mike  1.1.2.2     | constant TOK_GT property
224 mike  1.1.2.1     {
225               
226                   }
227 mike  1.1.2.2     | constant TOK_LE property
228 mike  1.1.2.1     {
229               
230                   }
231 mike  1.1.2.2     | constant TOK_GE property
232 mike  1.1.2.1     {
233               
234                   }
235 mike  1.1.2.2     | constant TOK_EQ property
236 mike  1.1.2.1     {
237               
238                   }
239 mike  1.1.2.2     | constant TOK_NE property
240 mike  1.1.2.1     {
241               
242                   }
243 mike  1.1.2.2     | function TOK_LT constant
244 mike  1.1.2.1     {
245               
246                   }
247 mike  1.1.2.2     | function TOK_GT constant
248 mike  1.1.2.1     {
249               
250                   }
251 mike  1.1.2.2     | function TOK_LE constant
252 mike  1.1.2.1     {
253               
254                   }
255 mike  1.1.2.2     | function TOK_GE constant
256 mike  1.1.2.1     {
257               
258                   }
259 mike  1.1.2.2     | function TOK_EQ constant
260 mike  1.1.2.1     {
261               
262                   }
263 mike  1.1.2.2     | function TOK_NE constant
264 mike  1.1.2.1     {
265               
266                   }
267 mike  1.1.2.2     | constant TOK_LT function
268 mike  1.1.2.1     {
269               
270                   }
271 mike  1.1.2.2     | constant TOK_GT function
272 mike  1.1.2.1     {
273               
274                   }
275 mike  1.1.2.2     | constant TOK_LE function
276 mike  1.1.2.1     {
277               
278                   }
279 mike  1.1.2.2     | constant TOK_GE function
280 mike  1.1.2.1     {
281               
282                   }
283 mike  1.1.2.2     | constant TOK_EQ function
284 mike  1.1.2.1     {
285               
286                   }
287 mike  1.1.2.2     | constant TOK_NE function
288 mike  1.1.2.1     {
289               
290                   }
291 mike  1.1.2.2     | className TOK_ISA className
292 mike  1.1.2.1     {
293               
294                   }
295               
296               function 
297                   : TOK_IDENTIFIER '(' ')'
298                   {
299               
300                   }
301                   | TOK_IDENTIFIER '(' functionParameterList ')'
302                   {
303               
304                   }
305               
306               functionParameterList
307                   : functionParameter
308                   {
309               
310                   }
311                   | functionParameterList ',' functionParameter
312                   {
313 mike  1.1.2.1 
314                   }
315               
316               functionParameter
317                   : property
318                   | constant
319                   | function
320                   ;
321               
322               constant 
323                   : TOK_INTEGER
324                   {
325               
326                   }
327                   | TOK_DOUBLE
328                   {
329               
330                   }
331 mike  1.1.2.2     | TOK_STRING
332 mike  1.1.2.1     {
333 mike  1.1.2.2 	WQL_TRACE(("YACC: TOK_STRING: %s\n", $1));
334               	$$ = $1;
335 mike  1.1.2.1     }
336               
337               %%
338               
339               int WQL_error(char* errorMessage)
340               {
341                   fprintf(stderr, "WQL_error: %s\n", errorMessage);
342                   return -1;
343               }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2