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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2