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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2