(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 mike  1.1.2.3 %token <intValue> TOK_NULL
 63 mike  1.1.2.2 
 64               %token <intValue> TOK_EQ
 65               %token <intValue> TOK_NE
 66               %token <intValue> TOK_LT
 67               %token <intValue> TOK_LE
 68               %token <intValue> TOK_GT
 69               %token <intValue> TOK_GE
 70               
 71               %token <intValue> TOK_NOT
 72               %token <intValue> TOK_OR
 73               %token <intValue> TOK_AND
 74 mike  1.1.2.3 %token <intValue> TOK_IS
 75 mike  1.1.2.2 
 76 mike  1.1.2.1 %token <strValue> TOK_IDENTIFIER
 77 mike  1.1.2.2 %token <intValue> TOK_SELECT
 78               %token <intValue> TOK_WHERE
 79               %token <intValue> TOK_FROM
 80               
 81               %token <strValue> TOK_UNEXPECTED_CHAR
 82 mike  1.1.2.1 
 83 mike  1.1.2.3 %type <nodeValue> propertyName
 84 mike  1.1.2.1 %type <nodeValue> propertyList
 85 mike  1.1.2.3 %type <nodeValue> predicate
 86               %type <nodeValue> comparisonPredicate
 87               %type <nodeValue> comparisonTerm
 88               %type <nodeValue> nullPredicate
 89               %type <nodeValue> searchCondition
 90               %type <nodeValue> fromClause
 91 mike  1.1.2.1 %type <nodeValue> whereClause
 92               %type <nodeValue> selectStatement
 93 mike  1.1.2.3 %type <nodeValue> selectList
 94               %type <nodeValue> selectExpression
 95 mike  1.1.2.1 %type <strValue> className
 96               
 97 mike  1.1.2.2 %left TOK_OR
 98               %left TOK_AND
 99               %nonassoc TOK_NOT
100               
101               %%
102 mike  1.1.2.1 
103               /*
104               **==============================================================================
105               **
106               ** The grammar itself.
107               **
108               **==============================================================================
109               */
110               
111               start
112                   : selectStatement
113                   {
114 mike  1.1.2.3 
115 mike  1.1.2.1     }
116               
117               selectStatement
118 mike  1.1.2.3     : TOK_SELECT selectList selectExpression
119 mike  1.1.2.1     {
120               
121                   }
122               
123 mike  1.1.2.3 selectList
124                   : '*'
125 mike  1.1.2.1     {
126               
127                   }
128 mike  1.1.2.3     | propertyList
129 mike  1.1.2.1     {
130               
131                   }
132               
133 mike  1.1.2.3 propertyList 
134                   : propertyName
135 mike  1.1.2.1     {
136               
137                   }
138 mike  1.1.2.3     | propertyList ',' propertyName
139 mike  1.1.2.1     {
140               
141                   }
142               
143 mike  1.1.2.3 selectExpression
144                   : fromClause whereClause
145 mike  1.1.2.1     {
146               
147                   }
148 mike  1.1.2.3     | fromClause
149 mike  1.1.2.1     {
150               
151                   }
152               
153 mike  1.1.2.3 fromClause
154                   : TOK_FROM className
155 mike  1.1.2.1     {
156               
157                   }
158               
159 mike  1.1.2.3 whereClause 
160                   : TOK_WHERE searchCondition
161 mike  1.1.2.1     {
162               
163                   }
164               
165 mike  1.1.2.3 searchCondition 
166                   : searchCondition TOK_OR searchCondition
167 mike  1.1.2.1     {
168               
169                   }
170 mike  1.1.2.3     | searchCondition TOK_AND searchCondition
171 mike  1.1.2.1     {
172               
173                   }
174 mike  1.1.2.3     | TOK_NOT searchCondition
175 mike  1.1.2.1     {
176               
177                   }
178 mike  1.1.2.3     | '(' searchCondition ')'
179 mike  1.1.2.1     {
180               
181                   }
182 mike  1.1.2.3     | predicate
183 mike  1.1.2.1     {
184               
185                   }
186 mike  1.1.2.3     | predicate TOK_IS truthValue
187 mike  1.1.2.1     {
188               
189                   }
190 mike  1.1.2.3     | predicate TOK_IS TOK_NOT truthValue
191 mike  1.1.2.1     {
192               
193                   }
194               
195 mike  1.1.2.3 predicate
196                   : comparisonPredicate
197 mike  1.1.2.1     {
198               
199                   }
200 mike  1.1.2.3     | nullPredicate
201 mike  1.1.2.1     {
202               
203                   }
204               
205 mike  1.1.2.3 comparisonPredicate
206                   : comparisonTerm TOK_LT comparisonTerm 
207 mike  1.1.2.1     {
208               
209                   }
210 mike  1.1.2.3     | comparisonTerm TOK_GT comparisonTerm
211 mike  1.1.2.1     {
212               
213                   }
214 mike  1.1.2.3     | comparisonTerm TOK_LE comparisonTerm
215 mike  1.1.2.1     {
216               
217                   }
218 mike  1.1.2.3     | comparisonTerm TOK_GE comparisonTerm
219 mike  1.1.2.1     {
220               
221                   }
222 mike  1.1.2.3     | comparisonTerm TOK_EQ comparisonTerm
223 mike  1.1.2.1     {
224               
225                   }
226 mike  1.1.2.3     | comparisonTerm TOK_NE comparisonTerm
227 mike  1.1.2.1     {
228               
229                   }
230               
231 mike  1.1.2.3 nullPredicate
232                   : comparisonTerm TOK_IS TOK_NULL
233 mike  1.1.2.1     {
234               
235                   }
236 mike  1.1.2.3     | comparisonTerm TOK_IS TOK_NOT TOK_NULL
237 mike  1.1.2.1     {
238               
239                   }
240               
241 mike  1.1.2.3 truthValue 
242                   : TOK_TRUE 
243 mike  1.1.2.1     {
244               
245                   }
246 mike  1.1.2.3     | TOK_FALSE
247 mike  1.1.2.1     {
248               
249                   }
250               
251 mike  1.1.2.3 propertyName 
252                   : TOK_IDENTIFIER
253 mike  1.1.2.1     {
254               
255                   }
256               
257 mike  1.1.2.3 className : TOK_IDENTIFIER
258 mike  1.1.2.1     {
259               
260                   }
261               
262 mike  1.1.2.3 comparisonTerm
263                   : propertyName
264 mike  1.1.2.1     {
265               
266                   }
267 mike  1.1.2.3     | TOK_INTEGER
268 mike  1.1.2.1     {
269               
270                   }
271 mike  1.1.2.3     | TOK_DOUBLE
272 mike  1.1.2.1     {
273               
274                   }
275 mike  1.1.2.3     | TOK_STRING
276 mike  1.1.2.1     {
277               
278                   }
279 mike  1.1.2.3     | truthValue
280 mike  1.1.2.1     {
281                   }
282               
283               %%
284               
285               int WQL_error(char* errorMessage)
286               {
287                   fprintf(stderr, "WQL_error: %s\n", errorMessage);
288                   return -1;
289               }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2