1 martin 1.17 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.18 //
|
3 martin 1.17 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.18 //
|
10 martin 1.17 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.18 //
|
17 martin 1.17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.18 //
|
20 martin 1.17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.18 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.18 //
|
28 martin 1.17 //////////////////////////////////////////////////////////////////////////
|
29 chuck 1.2 %{
30 #include <Pegasus/Common/Config.h>
31 #include <Pegasus/Common/String.h>
32 #include <Pegasus/Common/CommonUTF.h>
33 #include <Pegasus/Query/QueryCommon/QueryException.h>
34 #include <Pegasus/Common/MessageLoader.h>
35 #include <Pegasus/CQL/CQLFactory.h>
36 #include "CQLObjects.h"
37 #include <stdio.h>
38
39 #define yyparse CQL_parse
40 #define CQLPREDICATE 0
41 #define CQLVALUE 1
42 #define CQLIDENTIFIER 2
43 #define CQLFUNCTION 3
44 #define CQLCHAINEDIDENTIFIER 4
45
46 int yylex();
|
47 karl 1.13 #ifdef CQL_DEBUG_GRAMMAR
|
48 dave.sudlik 1.15 #define CQL_DEBUG_TRACE(X) \
49 printf(X);
50 #define CQL_DEBUG_TRACE2(X,Y) \
51 printf(X,Y);
|
52 karl 1.13 #else
|
53 dave.sudlik 1.15 #define CQL_DEBUG_TRACE(X)
54 #define CQL_DEBUG_TRACE2(X,Y)
|
55 karl 1.13 #endif
56
57
|
58 chuck 1.2 extern char * yytext;
59 int chain_state;
60 CQLFactory _factory = CQLFactory();
61 extern int CQL_error(const char *err);
|
62 humberto 1.6
63 enum CQLType { Id, CId, Val, Func, Fact, Trm, Expr, SPred, Pred, Str };
64
65 typedef struct CQLObjPtr {
66 void* _ptr;
|
67 kumpf 1.19 CQLType type;
|
68 humberto 1.6 } CQLOBJPTR;
69
70 Array<CQLObjPtr> _ptrs;
71 CQLOBJPTR _ObjPtr;
72
|
73 karl 1.13 PEGASUS_NAMESPACE_BEGIN
|
74 kumpf 1.19
|
75 karl 1.13 extern CQLParserState* CQL_globalParserState;
76 Array<CQLPredicate> _arglist;
77
78
79 PEGASUS_NAMESPACE_END
80
|
81 humberto 1.8
|
82 venkat.puvvada 1.16 void CQL_Arglist_Cleanup()
83 {
84 _arglist.clear();
85 }
86
|
87 humberto 1.8 void CQL_Bison_Cleanup(){
|
88 karl 1.13 for(Uint32 i = 0; i < _ptrs.size(); i++)
89 {
90 if(_ptrs[i]._ptr)
91 {
92 switch(_ptrs[i].type)
93 {
94 case Id:
95 delete (CQLIdentifier*)_ptrs[i]._ptr;
96 break;
97 case CId:
98 delete (CQLChainedIdentifier*)_ptrs[i]._ptr;
99 break;
100 case Val:
101 delete (CQLValue*)_ptrs[i]._ptr;
102 break;
103 case Func:
104 delete (CQLFunction*)_ptrs[i]._ptr;
105 break;
106 case Fact:
107 delete (CQLFactor*)_ptrs[i]._ptr;
108 break;
109 karl 1.13 case Trm:
110 delete (CQLTerm*)_ptrs[i]._ptr;
111 break;
112 case Expr:
113 delete (CQLExpression*)_ptrs[i]._ptr;
114 break;
115 case SPred:
116 delete (CQLSimplePredicate*)_ptrs[i]._ptr;
117 break;
118 case Pred:
119 delete (CQLPredicate*)_ptrs[i]._ptr;
120 break;
121 case Str:
122 delete (String*)_ptrs[i]._ptr;
123 }
124 }
125 }
|
126 venkat.puvvada 1.16 CQL_Arglist_Cleanup();
|
127 karl 1.13 _ptrs.clear();
|
128 humberto 1.6 _factory.cleanup();
|
129 karl 1.13 _factory = CQLFactory();
|
130 humberto 1.6 }
131
|
132 chuck 1.2 %}
133 %union {
|
134 karl 1.14 char * strValue;
135 String * _string;
136 CQLValue * _value;
137 CQLIdentifier * _identifier;
138 CQLChainedIdentifier * _chainedIdentifier;
139 CQLPredicate * _predicate;
140 ExpressionOpType _opType;
141 void * _node;
|
142 chuck 1.2 }
143
144 /* terminals */
|
145 kumpf 1.19 %token <strValue> TOK_IDENTIFIER
|
146 karl 1.13 %token <strValue> TOK_STRING_LITERAL
147 %token <strValue> TOK_BINARY
148 %token <strValue> TOK_NEGATIVE_BINARY
149 %token <strValue> TOK_HEXADECIMAL
150 %token <strValue> TOK_NEGATIVE_HEXADECIMAL
|
151 kumpf 1.19 %token <strValue> TOK_INTEGER
|
152 karl 1.13 %token <strValue> TOK_NEGATIVE_INTEGER
|
153 kumpf 1.19 %token <strValue> TOK_REAL
|
154 karl 1.13 %token <strValue> TOK_NEGATIVE_REAL
|
155 kumpf 1.19 %token <strValue> TOK_TRUE
156 %token <strValue> TOK_FALSE
|
157 karl 1.13 %token <strValue> TOK_SCOPED_PROPERTY
|
158 kumpf 1.19 %token <strValue> TOK_LPAR
159 %token <strValue> TOK_RPAR
|
160 karl 1.13 %token <strValue> TOK_HASH
|
161 kumpf 1.19 %token <strValue> TOK_DOT
162 %token <strValue> TOK_LBRKT
163 %token <strValue> TOK_RBRKT
|
164 karl 1.13 %token <strValue> TOK_UNDERSCORE
|
165 kumpf 1.19 %token <strValue> TOK_COMMA
166 %token <strValue> TOK_CONCAT
|
167 karl 1.13 %token <strValue> TOK_DBL_PIPE
168 %token <strValue> TOK_PLUS
|
169 kumpf 1.19 %token <strValue> TOK_MINUS
170 %token <strValue> TOK_TIMES
171 %token <strValue> TOK_DIV
172 %token <strValue> TOK_IS
173 %token <strValue> TOK_NULL
|
174 karl 1.13 %token <_opType> TOK_EQ
|
175 kumpf 1.19 %token <_opType> TOK_NE
176 %token <_opType> TOK_GT
177 %token <_opType> TOK_LT
178 %token <_opType> TOK_GE
179 %token <_opType> TOK_LE
180 %token <_opType> TOK_ISA
181 %token <_opType> TOK_LIKE
182 %token <strValue> TOK_NOT TOK_AND TOK_OR
183 %token <strValue> TOK_SCOPE
184 %token <strValue> TOK_ANY TOK_EVERY TOK_IN TOK_SATISFIES
185 %token <strValue> TOK_STAR
186 %token <strValue> TOK_DOTDOT
187 %token <strValue> TOK_SHARP TOK_DISTINCT
188 %token <strValue> TOK_SELECT
189 %token <strValue> TOK_FIRST
190 %token <strValue> TOK_FROM
191 %token <strValue> TOK_WHERE
192 %token <strValue> TOK_ORDER
193 %token <strValue> TOK_BY
194 %token <strValue> TOK_ASC
195 %token <strValue> TOK_DESC
196 kumpf 1.19 %token <strValue> TOK_AS
|
197 karl 1.13 %token <strValue> TOK_UNEXPECTED_CHAR
|
198 chuck 1.2
199
200 /* grammar - non terminals */
201 %type <_identifier> identifier
202 %type <_identifier> class_name
203 %type <_identifier> class_path
204 %type <_identifier> scoped_property
205 %type <_string> literal_string
206 %type <_value> binary_value
207 %type <_value> hex_value
208 %type <_value> decimal_value
209 %type <_value> real_value
210 %type <_value> literal
211 %type <_string> array_index
212 %type <_string> array_index_list
213 %type <_node> chain
214 %type <_predicate> concat
215 %type <_predicate> factor
216 %type <_predicate> term
217 %type <_predicate> arith
218 %type <_value> value_symbol
219 chuck 1.2 %type <_predicate> arith_or_value_symbol
220 %type <_opType> comp_op
221 %type <_predicate> comp
222 %type <_predicate> expr_factor
223 %type <_predicate> expr_term
224 %type <_predicate> expr
225 %type <_node> arg_list
226 %type <_node> from_specifier
227 %type <_node> from_criteria
228 %type <_chainedIdentifier> star_expr
229 %type <_node> selected_entry
230 %type <_node> select_list
231 %type <_node> select_list_tail
232 %type <_node> search_condition
233 %type <_node> optional_where
234 %type <_node> select_statement
235
236 %start select_statement
237
238 %%
239
|
240 karl 1.13 /**
241 The general pattern: We construct small objects first (CQLIdentifiers,
242 CQLValues etc) which get forwared to more complex rules where more
243 complex objects are made. Eventually we have constructed a top level
244 CQLPredicate that gets added to the CQL_globalParserState select
245 statement.
246
247 Along the way we keep track of which rule we are processing so that
248 any errors encountered are specific enough to actually do us some good.
249
250 The CQLFactory object is used primarily to save space/coding efforts.
251 It enables us to build complex CQL objects with one simple call,
252 or query complex objects through one simple call.
|
253 kumpf 1.19
|
254 karl 1.13 */
|
255 humberto 1.4
|
256 chuck 1.2 /* CQLIdentifier */
|
257 kumpf 1.19 identifier : TOK_IDENTIFIER
258 {
|
259 dave.sudlik 1.15 CQL_globalParserState->currentRule = "identifier";
260 CQL_DEBUG_TRACE("BISON::identifier\n");
|
261 karl 1.13
|
262 karl 1.14 if(isUTF8Str(CQL_lval.strValue))
|
263 kumpf 1.19 {
|
264 karl 1.14 $$ = new CQLIdentifier(String(CQL_lval.strValue));
|
265 karl 1.13 _ObjPtr._ptr = $$;
266 _ObjPtr.type = Id;
267 _ptrs.append(_ObjPtr);
|
268 karl 1.14 }
269 else
270 {
|
271 dave.sudlik 1.15 CQL_DEBUG_TRACE("BISON::identifier-> BAD UTF\n");
|
272 karl 1.14
273 throw CQLSyntaxErrorException(
274 MessageLoaderParms("CQL.CQL_y.BAD_UTF8",
275 "Bad UTF8 encountered parsing rule $0"
276 " in position $1.",
277 "identifier",
278 CQL_globalParserState->currentTokenPos) );
279 }
280 }
|
281 chuck 1.2 ;
282
|
283 kumpf 1.19 class_name : identifier
|
284 karl 1.14 {
|
285 dave.sudlik 1.15 CQL_globalParserState->currentRule = "class_name";
|
286 kumpf 1.19 CQL_DEBUG_TRACE2("BISON::class_name = %s\n",
|
287 dave.sudlik 1.15 (const char *)($1->getName().getString().getCString()));
|
288 karl 1.14 $$ = $1;
289 }
|
290 chuck 1.2 ;
291
|
292 kumpf 1.19 class_path : class_name
293 {
|
294 dave.sudlik 1.15 CQL_globalParserState->currentRule = "class_path";
295 CQL_DEBUG_TRACE("BISON::class_path\n");
|
296 karl 1.14 $$ = $1;
297 }
|
298 chuck 1.2 ;
|
299 karl 1.14 /**********************************
|
300 karl 1.13 property_scope : class_path TOK_SCOPE
|
301 kumpf 1.19 {
302 CQL_DEBUG_TRACE2("BISON::property_scope = %s\n",$1);
|
303 karl 1.14 }
304 ***********************************/
|
305 chuck 1.2 ;
306
307 /* CQLIdentifier */
|
308 karl 1.13 scoped_property : TOK_SCOPED_PROPERTY
|
309 karl 1.14 {
310 /*
311 TOK_SCOPED_PROPERTY can be:
312 - "A::prop"
313 - "A::class.prop"
314 - "A::class.prop#'OK'
315 - "A::class.prop[4]"
316 */
|
317 dave.sudlik 1.15 CQL_globalParserState->currentRule = "scoped_property";
318 CQL_DEBUG_TRACE2("BISON::scoped_property = %s\n", CQL_lval.strValue);
|
319 kumpf 1.19
|
320 karl 1.14 if(isUTF8Str(CQL_lval.strValue))
321 {
|
322 karl 1.13 String tmp(CQL_lval.strValue);
323 $$ = new CQLIdentifier(tmp);
324 _ObjPtr._ptr = $$;
325 _ObjPtr.type = Id;
326 _ptrs.append(_ObjPtr);
|
327 karl 1.14 }
328 else
329 {
|
330 dave.sudlik 1.15 CQL_DEBUG_TRACE("BISON::scoped_property-> BAD UTF\n");
|
331 karl 1.13 throw CQLSyntaxErrorException(
332 MessageLoaderParms("CQL.CQL_y.BAD_UTF8",
333 "Bad UTF8 encountered parsing rule $0 in position $1.",
334 "scoped_property",
335 CQL_globalParserState->currentTokenPos) );
|
336 karl 1.14 }
337 }
|
338 kumpf 1.19 ;
|
339 chuck 1.2
340 /* String */
|
341 kumpf 1.19 literal_string : TOK_STRING_LITERAL
342 {
|
343 karl 1.14 /*
344 Make sure the literal is valid UTF8, then make a String
345 */
|
346 dave.sudlik 1.15 CQL_globalParserState->currentRule = "literal_string";
347 CQL_DEBUG_TRACE2("BISON::literal_string-> %s\n", CQL_lval.strValue);
|
348 kumpf 1.19
|
349 karl 1.14 if(isUTF8Str(CQL_lval.strValue))
350 {
|
351 karl 1.13 $$ = new String(CQL_lval.strValue);
352 _ObjPtr._ptr = $$;
353 _ObjPtr.type = Str;
354 _ptrs.append(_ObjPtr);
|
355 karl 1.14 }
356 else
357 {
|
358 dave.sudlik 1.15 CQL_DEBUG_TRACE("BISON::literal_string-> BAD UTF\n");
|
359 kumpf 1.19
|
360 karl 1.13 throw CQLSyntaxErrorException(
361 MessageLoaderParms("CQL.CQL_y.BAD_UTF8",
362 "Bad UTF8 encountered parsing rule $0 in position $1.",
363 "literal_string",
364 CQL_globalParserState->currentTokenPos));
365 }
|
366 karl 1.14 }
|
367 chuck 1.2 ;
368
369 /* CQLValue */
|
370 kumpf 1.19 binary_value : TOK_BINARY
371 {
|
372 dave.sudlik 1.15 CQL_globalParserState->currentRule = "binary_value->TOK_BINARY";
373 CQL_DEBUG_TRACE2("BISON::binary_value-> %s\n", CQL_lval.strValue);
|
374 kumpf 1.19
375 $$ = new CQLValue(CQL_lval.strValue, CQLValue::Binary);
|
376 dave.sudlik 1.15 _ObjPtr._ptr = $$;
377 _ObjPtr.type = Val;
378 _ptrs.append(_ObjPtr);
|
379 karl 1.14 }
|
380 kumpf 1.19 | TOK_NEGATIVE_BINARY
381 {
382 CQL_globalParserState->currentRule =
|
383 dave.sudlik 1.15 "binary_value->TOK_NEGATIVE_BINARY";
384 CQL_DEBUG_TRACE2("BISON::binary_value-> %s\n", CQL_lval.strValue);
|
385 kumpf 1.19
386 $$ = new CQLValue(CQL_lval.strValue, CQLValue::Binary, false);
|
387 dave.sudlik 1.15 _ObjPtr._ptr = $$;
388 _ObjPtr.type = Val;
389 _ptrs.append(_ObjPtr);
|
390 karl 1.14 }
|
391 chuck 1.2 ;
392
393 /* CQLValue */
|
394 kumpf 1.19 hex_value : TOK_HEXADECIMAL
395 {
|
396 dave.sudlik 1.15 CQL_globalParserState->currentRule = "hex_value->TOK_HEXADECIMAL";
397 CQL_DEBUG_TRACE2("BISON::hex_value-> %s\n", CQL_lval.strValue);
|
398 kumpf 1.19
|
399 karl 1.14 $$ = new CQLValue(CQL_lval.strValue, CQLValue::Hex);
400 _ObjPtr._ptr = $$;
401 _ObjPtr.type = Val;
402 _ptrs.append(_ObjPtr);
403 }
|
404 kumpf 1.19 | TOK_NEGATIVE_HEXADECIMAL
405 {
406 CQL_globalParserState->currentRule =
|
407 dave.sudlik 1.15 "hex_value->TOK_NEGATIVE_HEXADECIMAL";
408 CQL_DEBUG_TRACE2("BISON::hex_value-> %s\n", CQL_lval.strValue);
|
409 kumpf 1.19
|
410 karl 1.14 $$ = new CQLValue(CQL_lval.strValue, CQLValue::Hex, false);
411 _ObjPtr._ptr = $$;
412 _ObjPtr.type = Val;
413 _ptrs.append(_ObjPtr);
414 }
|
415 chuck 1.2 ;
416
417 /* CQLValue */
|
418 kumpf 1.19 decimal_value : TOK_INTEGER
419 {
|
420 dave.sudlik 1.15 CQL_globalParserState->currentRule = "decimal_value->TOK_INTEGER";
421 CQL_DEBUG_TRACE2("BISON::decimal_value-> %s\n", CQL_lval.strValue);
|
422 kumpf 1.19
423 $$ = new CQLValue(CQL_lval.strValue, CQLValue::Decimal);
|
424 karl 1.14 _ObjPtr._ptr = $$;
425 _ObjPtr.type = Val;
426 _ptrs.append(_ObjPtr);
427 }
|
428 kumpf 1.19 | TOK_NEGATIVE_INTEGER
429 {
430 CQL_globalParserState->currentRule =
|
431 dave.sudlik 1.15 "decimal_value->TOK_NEGATIVE_INTEGER";
432 CQL_DEBUG_TRACE2("BISON::decimal_value-> %s\n", CQL_lval.strValue);
|
433 kumpf 1.19
|
434 karl 1.14 $$ = new CQLValue(CQL_lval.strValue, CQLValue::Decimal, false);
435 _ObjPtr._ptr = $$;
436 _ObjPtr.type = Val;
437 _ptrs.append(_ObjPtr);
438 }
|
439 chuck 1.2 ;
440
441 /* CQLValue */
|
442 kumpf 1.19 real_value : TOK_REAL
443 {
|
444 dave.sudlik 1.15 CQL_globalParserState->currentRule = "real_value->TOK_REAL";
445 CQL_DEBUG_TRACE2("BISON::real_value-> %s\n", CQL_lval.strValue);
|
446 kumpf 1.19
|
447 karl 1.14 $$ = new CQLValue(CQL_lval.strValue, CQLValue::Real);
448 _ObjPtr._ptr = $$;
449 _ObjPtr.type = Val;
450 _ptrs.append(_ObjPtr);
451 }
|
452 kumpf 1.19 | TOK_NEGATIVE_REAL
453 {
|
454 dave.sudlik 1.15 CQL_globalParserState->currentRule = "real_value->TOK_NEGATIVE_REAL";
455 CQL_DEBUG_TRACE2("BISON::real_value-> %s\n", CQL_lval.strValue);
|
456 kumpf 1.19
|
457 karl 1.14 $$ = new CQLValue(CQL_lval.strValue, CQLValue::Real, false);
458 _ObjPtr._ptr = $$;
459 _ObjPtr.type = Val;
460 _ptrs.append(_ObjPtr);
461 }
|
462 chuck 1.2 ;
463
464 /* CQLValue */
|
465 kumpf 1.19 literal : literal_string
|
466 karl 1.14 {
|
467 dave.sudlik 1.15 CQL_globalParserState->currentRule = "literal->literal_string";
468 CQL_DEBUG_TRACE("BISON::literal->literal_string\n");
|
469 karl 1.14 $$ = new CQLValue(*$1);
470 _ObjPtr._ptr = $$;
471 _ObjPtr.type = Val;
472 _ptrs.append(_ObjPtr);
473 }
474 | decimal_value
475 {
|
476 dave.sudlik 1.15 CQL_globalParserState->currentRule = "literal->decimal_value";
477 CQL_DEBUG_TRACE("BISON::literal->decimal_value\n");
|
478 karl 1.14 }
479 | binary_value
480 {
|
481 dave.sudlik 1.15 CQL_globalParserState->currentRule = "literal->binary_value";
482 CQL_DEBUG_TRACE("BISON::literal->binary_value\n");
|
483 karl 1.14 }
484 | hex_value
485 {
|
486 dave.sudlik 1.15 CQL_globalParserState->currentRule = "literal->hex_value";
487 CQL_DEBUG_TRACE("BISON::literal->hex_value\n");
|
488 karl 1.14 }
489 | real_value
490 {
|
491 dave.sudlik 1.15 CQL_globalParserState->currentRule = "literal->real_value";
492 CQL_DEBUG_TRACE("BISON::literal->real_value\n");
|
493 karl 1.14 }
494 | TOK_TRUE
495 {
|
496 dave.sudlik 1.15 CQL_globalParserState->currentRule = "literal->TOK_TRUE";
497 CQL_DEBUG_TRACE("BISON::literal->TOK_TRUE\n");
|
498 kumpf 1.19
|
499 karl 1.14 $$ = new CQLValue(Boolean(true));
|
500 karl 1.13 _ObjPtr._ptr = $$;
|
501 karl 1.14 _ObjPtr.type = Val;
502 _ptrs.append(_ObjPtr);
503 }
504 | TOK_FALSE
505 {
|
506 dave.sudlik 1.15 CQL_globalParserState->currentRule = "literal->TOK_FALSE";
507 CQL_DEBUG_TRACE("BISON::literal->TOK_FALSE\n");
|
508 kumpf 1.19
|
509 dave.sudlik 1.15 $$ = new CQLValue(Boolean(false));
510 _ObjPtr._ptr = $$;
511 _ObjPtr.type = Val;
512 _ptrs.append(_ObjPtr);
|
513 karl 1.14 }
|
514 chuck 1.2 ;
515
516 /* String */
517 array_index : expr
|
518 karl 1.14 {
|
519 dave.sudlik 1.15 CQL_globalParserState->currentRule = "array_index->expr";
520 CQL_DEBUG_TRACE("BISON::array_index->expr\n");
|
521 kumpf 1.19
|
522 karl 1.14 CQLValue* _val = (CQLValue*)_factory.getObject($1,Predicate,Value);
523 $$ = new String(_val->toString());
524 _ObjPtr._ptr = $$;
525 _ObjPtr.type = Str;
526 _ptrs.append(_ObjPtr);
527 }
|
528 chuck 1.2 ;
529
530 /* String */
531 array_index_list : array_index
|
532 karl 1.14 {
|
533 dave.sudlik 1.15 CQL_globalParserState->currentRule = "array_index_list->array_index";
534 CQL_DEBUG_TRACE("BISON::array_index_list->array_index\n");
|
535 kumpf 1.19
|
536 karl 1.14 $$ = $1;
537 }
|
538 chuck 1.2 ;
539
540 /* void* */
541 chain : literal
|
542 karl 1.14 {
|
543 dave.sudlik 1.15 CQL_globalParserState->currentRule = "chain->literal";
544 CQL_DEBUG_TRACE("BISON::chain->literal\n");
|
545 kumpf 1.19
|
546 karl 1.14 chain_state = CQLVALUE;
|
547 kumpf 1.19 $$ = _factory.makeObject($1,Predicate);
|
548 karl 1.14 }
549
550 | TOK_LPAR expr TOK_RPAR
551 {
|
552 dave.sudlik 1.15 CQL_globalParserState->currentRule = "chain-> ( expr )";
553 CQL_DEBUG_TRACE("BISON::chain-> ( expr )\n");
|
554 karl 1.14
555 chain_state = CQLPREDICATE;
556 $$ = $2;
557 }
558
559 | identifier
560 {
|
561 dave.sudlik 1.15 CQL_globalParserState->currentRule = "chain->identifier";
562 CQL_DEBUG_TRACE("BISON::chain->identifier\n");
|
563 kumpf 1.19
|
564 karl 1.14 chain_state = CQLIDENTIFIER;
565 $$ = _factory.makeObject($1,Predicate);
566 }
567
568 | identifier TOK_HASH literal_string
569 {
|
570 kumpf 1.19 CQL_globalParserState->currentRule =
|
571 dave.sudlik 1.15 "chain->identifier#literal_string";
572 CQL_DEBUG_TRACE("BISON::chain->identifier#literal_string\n");
|
573 kumpf 1.19
|
574 karl 1.14 String tmp = $1->getName().getString();
575 tmp.append("#").append(*$3);
576 CQLIdentifier _id(tmp);
577 $$ = _factory.makeObject(&_id,Predicate);
578 chain_state = CQLIDENTIFIER;
579 }
|
580 karl 1.13
|
581 karl 1.14 | scoped_property
582 {
|
583 dave.sudlik 1.15 CQL_globalParserState->currentRule = "chain->scoped_property";
584 CQL_DEBUG_TRACE("BISON::chain->scoped_property\n");
|
585 kumpf 1.19
|
586 dave.sudlik 1.15 chain_state = CQLIDENTIFIER;
587 $$ = _factory.makeObject($1,Predicate);
|
588 karl 1.14 }
|
589 karl 1.13
|
590 karl 1.14 | identifier TOK_LPAR arg_list TOK_RPAR
591 {
|
592 dave.sudlik 1.15 CQL_globalParserState->currentRule = "identifier( arg_list )";
593 CQL_DEBUG_TRACE("BISON::identifier( arg_list )\n");
|
594 kumpf 1.19
|
595 dave.sudlik 1.15 chain_state = CQLFUNCTION;
596 CQLFunction _func(*$1,_arglist);
597 $$ = (CQLPredicate*)(_factory.makeObject(&_func,Predicate));
|
598 venkat.puvvada 1.16 CQL_Arglist_Cleanup();
|
599 karl 1.14 }
|
600 chuck 1.2
|
601 karl 1.14 | chain TOK_DOT scoped_property
602 {
|
603 dave.sudlik 1.15 CQL_globalParserState->currentRule = "chain->chain.scoped_property";
604 CQL_DEBUG_TRACE2(
605 "BISON::chain-> chain TOK_DOT scoped_property : chain_state = %d\n"
606 ,chain_state);
|
607 kumpf 1.19
|
608 karl 1.14 CQLIdentifier *_id;
609 if(chain_state == CQLIDENTIFIER)
610 {
|
611 karl 1.13 _id = ((CQLIdentifier*)(_factory.getObject(
612 $1,Predicate,Identifier)));
613 CQLChainedIdentifier _cid(*_id);
614 _cid.append(*$3);
615 $$ = _factory.makeObject(&_cid,Predicate);
|
616 karl 1.14 }
617 else if(chain_state == CQLCHAINEDIDENTIFIER)
618 {
|
619 karl 1.13 CQLChainedIdentifier *_cid;
620 _cid = ((CQLChainedIdentifier*)(_factory.getObject(
621 $1,Predicate,ChainedIdentifier)));
622 _cid->append(*$3);
623 _factory.setObject(((CQLPredicate*)$1),_cid,ChainedIdentifier);
624 $$ = $1;
|
625 karl 1.14 }
626 else /* error */
627 {
|
628 karl 1.13 String _msg("chain-> chain TOK_DOT scoped_property :"
629 " chain state not CQLIDENTIFIER or CQLCHAINEDIDENTIFIER");
|
630 karl 1.14
|
631 karl 1.13 throw CQLSyntaxErrorException(
|
632 karl 1.14 MessageLoaderParms("CQL.CQL_y.NOT_CHAINID_OR_IDENTIFIER",
633 "Chain state not a CQLIdentifier or a"
634 " CQLChainedIdentifier while parsing rule $0 in"
635 " position $1.",
636 "chain.scoped_property",
637 CQL_globalParserState->currentTokenPos));
638 }
|
639 kumpf 1.19
|
640 karl 1.14 chain_state = CQLCHAINEDIDENTIFIER;
641 }
|
642 chuck 1.2
|
643 karl 1.14 | chain TOK_DOT identifier
644 {
|
645 dave.sudlik 1.15 CQL_globalParserState->currentRule = "chain->chain.identifier";
646 CQL_DEBUG_TRACE2("BISON::chain->chain.identifier : chain_state = %d\n"
647 ,chain_state);
|
648 kumpf 1.19
|
649 karl 1.14 if(chain_state == CQLIDENTIFIER)
650 {
|
651 karl 1.13 CQLIdentifier *_id = ((CQLIdentifier*)(_factory.getObject(
|
652 karl 1.14 $1,Predicate,Identifier)));
|
653 karl 1.13 CQLChainedIdentifier _cid(*_id);
654 _cid.append(*$3);
655 $$ = _factory.makeObject(&_cid,Predicate);
|
656 karl 1.14 }
657 else if(chain_state == CQLCHAINEDIDENTIFIER)
658 {
|
659 kumpf 1.19 CQLChainedIdentifier *_cid =
|
660 karl 1.14 ((CQLChainedIdentifier*)(_factory.getObject(
661 $1,Predicate,ChainedIdentifier)));
|
662 karl 1.13 _cid->append(*$3);
663 _factory.setObject(((CQLPredicate*)$1),_cid,ChainedIdentifier);
664 $$ = $1;
|
665 karl 1.14 }
666 else /* error */
667 {
|
668 karl 1.13 String _msg("chain-> chain TOK_DOT identifier : chain state not"
669 " CQLIDENTIFIER or CQLCHAINEDIDENTIFIER");
|
670 karl 1.14
|
671 karl 1.13 throw CQLSyntaxErrorException(
|
672 karl 1.14 MessageLoaderParms("CQL.CQL_y.NOT_CHAINID_OR_IDENTIFIER",
673 "Chain state not a CQLIdentifier or a CQLChainedId"
674 "Identifier while parsing rule $0 in position $1.",
675 "chain.identifier",
676 CQL_globalParserState->currentTokenPos));
677 }
|
678 karl 1.13 chain_state = CQLCHAINEDIDENTIFIER;
|
679 karl 1.14 }
|
680 chuck 1.2
|
681 karl 1.14 | chain TOK_DOT identifier TOK_HASH literal_string
682 {
|
683 kumpf 1.19 CQL_globalParserState->currentRule =
|
684 dave.sudlik 1.15 "chain->chain.identifier#literal_string";
685 CQL_DEBUG_TRACE2(
686 "BISON::chain->chain.identifier#literal_string : chain_state = %d\n"
687 ,chain_state);
|
688 kumpf 1.19
|
689 karl 1.14 if(chain_state == CQLIDENTIFIER)
690 {
|
691 karl 1.13 CQLIdentifier *_id = ((CQLIdentifier*)(_factory.getObject(
|
692 kumpf 1.19 $1,Predicate,Identifier)));
|
693 karl 1.13 CQLChainedIdentifier _cid(*_id);
694 String tmp($3->getName().getString());
695 tmp.append("#").append(*$5);
696 CQLIdentifier _id1(tmp);
697 _cid.append(_id1);
698 _factory.setObject(((CQLPredicate*)$1),&_cid,ChainedIdentifier);
699 $$ = $1;
|
700 karl 1.14 }
701 else if(chain_state == CQLCHAINEDIDENTIFIER)
702 {
|
703 karl 1.13 CQLChainedIdentifier *_cid = ((CQLChainedIdentifier*)(
704 _factory.getObject($1,Predicate,ChainedIdentifier)));
705 String tmp($3->getName().getString());
706 tmp.append("#").append(*$5);
707 CQLIdentifier _id1(tmp);
708 _cid->append(_id1);
709 _factory.setObject(((CQLPredicate*)$1),_cid,ChainedIdentifier);
710 $$ = $1;
|
711 karl 1.14 }
712 else /* error */
713 {
|
714 karl 1.13 String _msg("chain->chain.identifier#literal_string : chain"
715 " state not CQLIDENTIFIER or CQLCHAINEDIDENTIFIER");
|
716 karl 1.14
|
717 karl 1.13 throw CQLSyntaxErrorException(
718 MessageLoaderParms("CQL.CQL_y.NOT_CHAINID_OR_IDENTIFIER",
719 "Chain state not a CQLIdentifier or a CQLChained"
720 "Identifier while parsing rule $0 in position $1.",
721 "chain.identifier#literal_string",
722 CQL_globalParserState->currentTokenPos) );
|
723 karl 1.14 }
724 chain_state = CQLCHAINEDIDENTIFIER;
725 }
|
726 karl 1.13
|
727 karl 1.14 | chain TOK_LBRKT array_index_list TOK_RBRKT
728 {
|
729 kumpf 1.19 CQL_globalParserState->currentRule =
|
730 dave.sudlik 1.15 "chain->chain[ array_index_list ]";
731 CQL_DEBUG_TRACE2(
732 "BISON::chain->chain[ array_index_list ] : chain_state = %d\n"
733 ,chain_state);
|
734 kumpf 1.19
|
735 karl 1.14 if(chain_state == CQLIDENTIFIER)
736 {
|
737 karl 1.13 CQLIdentifier *_id = ((CQLIdentifier*)
738 (_factory.getObject($1,Predicate,Identifier)));
739 String tmp = _id->getName().getString();
740 tmp.append("[").append(*$3).append("]");
741 CQLIdentifier _id1(tmp);
742 CQLChainedIdentifier _cid(_id1);
743 _factory.setObject(((CQLPredicate*)$1),&_cid,ChainedIdentifier);
|
744 kumpf 1.19 $$ = $1;
|
745 karl 1.14 }
746 else if(chain_state == CQLCHAINEDIDENTIFIER || chain_state == CQLVALUE)
747 {
|
748 karl 1.13 CQLPredicate* _pred = (CQLPredicate*)$1;
749 CQLChainedIdentifier *_cid = ((CQLChainedIdentifier*)
750 (_factory.getObject
751 ($1,Predicate,ChainedIdentifier)));
752 CQLIdentifier tmpid = _cid->getLastIdentifier();
753 String tmp = tmpid.getName().getString();
754 tmp.append("[").append(*$3).append("]");
755 CQLIdentifier _id1(tmp);
756 CQLChainedIdentifier _tmpcid(_id1);
|
757 karl 1.14
|
758 karl 1.13 if(_cid->size() == 1)
759 {
|
760 karl 1.14 _cid = &_tmpcid;
|
761 karl 1.13 }
762 else
763 {
|
764 karl 1.14 _cid->append(_id1);
|
765 karl 1.13 }
766 _factory.setObject(((CQLPredicate*)$1),_cid,ChainedIdentifier);
767 $$ = $1;
|
768 karl 1.14 }
769 else /* error */
770 {
|
771 karl 1.13 String _msg("chain->chain[ array_index_list ] : chain state not"
772 " CQLIDENTIFIER or CQLCHAINEDIDENTIFIER or CQLVALUE");
|
773 karl 1.14
|
774 karl 1.13 throw CQLSyntaxErrorException(
775 MessageLoaderParms(
776 "CQL.CQL_y.NOT_CHAINID_OR_IDENTIFIER_OR_VALUE",
777 "Chain state not a CQLIdentifier or a "
778 "CQLChainedIdentifier or a CQLValue while parsing rule"
779 " $0 in position $1.",
780 "chain->chain[ array_index_list ]",
781 CQL_globalParserState->currentTokenPos) );
|
782 chuck 1.2 }
|
783 karl 1.14 }
|
784 chuck 1.2 ;
785
786 concat : chain
|
787 karl 1.14 {
|
788 dave.sudlik 1.15 CQL_globalParserState->currentRule = "concat->chain";
789 CQL_DEBUG_TRACE("BISON::concat->chain\n");
|
790 kumpf 1.19
|
791 karl 1.14 $$ = ((CQLPredicate*)$1);
792 }
|
793 chuck 1.2
|
794 karl 1.14 | concat TOK_DBL_PIPE literal_string
795 {
|
796 kumpf 1.19 CQL_globalParserState->currentRule =
|
797 dave.sudlik 1.15 "concat->concat || literal_string";
798 CQL_DEBUG_TRACE("BISON::concat->concat || literal_string\n");
|
799 kumpf 1.19
|
800 karl 1.14 CQLValue* tmpval = new CQLValue(*$3);
801 _ObjPtr._ptr = tmpval;
802 _ObjPtr.type = Val;
|
803 kumpf 1.19 _ptrs.append(_ObjPtr);
804
|
805 karl 1.14 if((CQLPredicate*)$1->isSimple())
806 {
807 CQLSimplePredicate sp = ((CQLPredicate*)$1)->getSimplePredicate();
808 if(sp.isSimple())
|
809 humberto 1.8 {
|
810 karl 1.14 CQLExpression exp = sp.getLeftExpression();
811 if(exp.isSimple())
812 {
813 CQLTerm* _term = ((CQLTerm*)
814 (_factory.getObject($1, Predicate, Term)));
815 // check for simple literal values
816 Array<CQLFactor> factors = _term->getFactors();
817 for(Uint32 i = 0; i < factors.size(); i++)
818 {
819 if(!factors[i].isSimpleValue())
820 {
821 MessageLoaderParms mparms(
822 "CQL.CQL_y.CONCAT_PRODUCTION_FACTORS_NOT"
823 "_SIMPLE",
824 "The CQLFactors are not simple while"
825 " processing rule $0.",
826 CQL_globalParserState->currentRule);
827 throw CQLSyntaxErrorException(mparms);
828 }
829 else /* !factors[i].isSimpleValue() */
|
830 karl 1.13 {
|
831 karl 1.14 CQLValue val = factors[i].getValue();
832 if(val.getValueType() != CQLValue::String_type)
833 {
834 MessageLoaderParms mparms(
835 "CQL.CQL_y."
836 "CONCAT_PRODUCTION_VALUE_NOT_LITERAL",
837 "The CQLValue is not a string literal while"
838 " processing rule $0.",
|
839 karl 1.13 CQL_globalParserState->currentRule);
|
840 karl 1.14 throw CQLSyntaxErrorException(mparms);
841 }
|
842 karl 1.13 }
|
843 karl 1.14 } // End For factors.size() Loop
844
845 CQLFactor* _fctr2 = ((CQLFactor*)
846 (_factory.makeObject(tmpval, Factor)));
847 _term->appendOperation(concat,*_fctr2);
848 $$ = (CQLPredicate*)(_factory.makeObject
|
849 kumpf 1.19 (_term,Predicate));
|
850 karl 1.14 }
851 else /* exp.isSimple() */
852 {
853 MessageLoaderParms mparms(
|
854 karl 1.13 "CQL.CQL_y.CONCAT_PRODUCTION_NOT_SIMPLE",
855 "The $0 is not simple while processing rule $1.",
|
856 karl 1.14 "CQLExpression",
|
857 karl 1.13 CQL_globalParserState->currentRule);
|
858 karl 1.14 throw CQLSyntaxErrorException(mparms);
859 }
860 }
861 else /*sp.isSimple() */
862 {
863 MessageLoaderParms mparms(
864 "CQL.CQL_y.CONCAT_PRODUCTION_NOT_SIMPLE",
865 "The $0 is not simple while processing rule $1.",
866 "CQLSimplePredicate",
867 CQL_globalParserState->currentRule);
868 throw CQLSyntaxErrorException(mparms);
869 }
870 }
871 else /* end if((CQLPredicate*)$1->isSimple()) */
872 {
873 MessageLoaderParms mparms(
874 "CQL.CQL_y.CONCAT_PRODUCTION_NOT_SIMPLE",
875 "The $0 is not simple while processing rule $1.",
876 "CQLPredicate",
877 CQL_globalParserState->currentRule);
878 throw CQLSyntaxErrorException(mparms);
879 karl 1.14 }
880 }
|
881 chuck 1.2 ;
882
883 factor : concat
|
884 karl 1.14 {
|
885 dave.sudlik 1.15 CQL_globalParserState->currentRule = "factor->concat";
886 CQL_DEBUG_TRACE("BISON::factor->concat\n");
|
887 kumpf 1.19
|
888 karl 1.14 $$ = $1;
|
889 kumpf 1.19 }
|
890 karl 1.14 /*
891 | TOK_PLUS concat
892 {
893 add enum instead of _invert to CQLFactor,has to be either nothing,
894 + or -
895 get the factor and set the optype appropriately
|
896 kumpf 1.19 CQL_globalParserState->currentRule = "concat->TOK_PLUS concat";
|
897 karl 1.14 printf("BISON::factor->TOK_PLUS concat\n");
898 ...
899 $$ = new CQLFactor(*(CQLValue*)$2);
900 }
901 | TOK_MINUS concat
902 {
|
903 kumpf 1.19 get the factor and set the optype appropriately
|
904 karl 1.14 CQL_globalParserState->currentRule = "concat->TOK_MINUS concat";
905 printf("BISON::factor->TOK_MINUS concat\n");
906 ...
907 CQLValue *tmp = (CQLValue*)$2;
908 tmp->invert();
909 $$ = new CQLFactor(*tmp);
910 }
911 */
|
912 chuck 1.2 ;
913
914 term : factor
|
915 karl 1.14 {
|
916 dave.sudlik 1.15 CQL_globalParserState->currentRule = "term->factor";
917 CQL_DEBUG_TRACE("BISON::term->factor\n");
|
918 kumpf 1.19
|
919 karl 1.14 $$ = $1;
920 }
921 /*
922 | term TOK_STAR factor
923 {
|
924 kumpf 1.19 get factor out of $1, get factor out of $3, appendoperation,
925 then construct predicate and forward it
|
926 karl 1.14 printf("BISON::term->term TOK_STAR factor\n");
927 CQL_globalParserState->currentRule = "term->term TOK_STAR factor";
928 $1->appendOperation(mult, *$3);
929 $$ = $1;
930 }
931 | term TOK_DIV factor
932 {
|
933 kumpf 1.19 get factor out of $1, get factor out of $3, appendoperation,
934 then construct predicate and forward it
|
935 karl 1.14 CQL_globalParserState->currentRule = "term->term TOK_DIV factor";
936 printf("BISON::term->term TOK_DIV factor\n");
937 $1->appendOperation(divide, *$3);
938 $$ = $1;
939 }
940 */
|
941 chuck 1.2 ;
942
943 arith : term
|
944 dave.sudlik 1.15 {
945 CQL_globalParserState->currentRule = "arith->term";
946 CQL_DEBUG_TRACE("BISON::arith->term\n");
|
947 kumpf 1.19
|
948 dave.sudlik 1.15 //CQLPredicate* _pred = new CQLPredicate(*$1);
949 // _factory._predicates.append(_pred);
950 $$ = $1;
951 }
|
952 karl 1.14 /***********************8
|
953 karl 1.13 | arith TOK_PLUS term
|
954 karl 1.14 {
|
955 kumpf 1.19 get term out of $1, get term out of $3, appendoperation, then
|
956 karl 1.13 construct predicate and forward it
957 CQL_globalParserState->currentRule = "arith->arith TOK_PLUS term";
958 printf("BISON::arith->arith TOK_PLUS term\n");
959 $1->appendOperation(TERM_ADD, *$3);
960 $$ = $1;
|
961 karl 1.14 }
|
962 karl 1.13 | arith TOK_MINUS term
|
963 karl 1.14 {
|
964 kumpf 1.19 get term out of $1, get term out of $3, append operation, then
965 construct predicate and forward it
|
966 karl 1.13 CQL_globalParserState->currentRule = "arith->arith TOK_MINUS term";
967 printf("BISON::arith->arith TOK_MINUS term\n");
968 $1->appendOperation(TERM_SUBTRACT, *$3);
969 $$ = $1;
|
970 karl 1.14 }
971 ************************/
|
972 karl 1.13 ;
973
974 value_symbol : TOK_HASH literal_string
|
975 karl 1.14 {
|
976 dave.sudlik 1.15 CQL_globalParserState->currentRule = "value_symbol->#literal_string";
977 CQL_DEBUG_TRACE("BISON::value_symbol->#literal_string\n");
|
978 kumpf 1.19
|
979 karl 1.14 String tmp("#");
980 tmp.append(*$2);
981 CQLIdentifier tmpid(tmp);
982 $$ = new CQLValue(tmpid);
983 _ObjPtr._ptr = $$;
984 _ObjPtr.type = Val;
985 _ptrs.append(_ObjPtr);
986 }
|
987 chuck 1.2 ;
988
989 arith_or_value_symbol : arith
|
990 karl 1.14 {
|
991 dave.sudlik 1.15 CQL_globalParserState->currentRule = "arith_or_value_symbol->arith";
992 CQL_DEBUG_TRACE("BISON::arith_or_value_symbol->arith\n");
|
993 kumpf 1.19
|
994 karl 1.14 $$ = $1;
995 }
996 | value_symbol
997 {
998 /* make into predicate */
|
999 kumpf 1.19 CQL_globalParserState->currentRule =
|
1000 dave.sudlik 1.15 "arith_or_value_symbol->value_symbol";
1001 CQL_DEBUG_TRACE("BISON::arith_or_value_symbol->value_symbol\n");
|
1002 kumpf 1.19
|
1003 karl 1.14 CQLFactor _fctr(*$1);
1004 $$ = (CQLPredicate*)(_factory.makeObject(&_fctr, Predicate));
1005 }
|
1006 karl 1.13 ;
1007
|
1008 kumpf 1.19 comp_op : TOK_EQ
|
1009 karl 1.14 {
|
1010 dave.sudlik 1.15 CQL_globalParserState->currentRule = "comp_op->TOK_EQ";
1011 CQL_DEBUG_TRACE("BISON::comp_op->TOK_EQ\n");
|
1012 kumpf 1.19
|
1013 dave.sudlik 1.15 $$ = EQ;
|
1014 karl 1.14 }
1015 | TOK_NE
1016 {
|
1017 dave.sudlik 1.15 CQL_globalParserState->currentRule = "comp_op->TOK_NE";
1018 CQL_DEBUG_TRACE("BISON::comp_op->TOK_NE\n");
1019 $$ = NE;
|
1020 karl 1.14 }
|
1021 kumpf 1.19 | TOK_GT
|
1022 karl 1.14 {
|
1023 dave.sudlik 1.15 CQL_globalParserState->currentRule = "comp_op->TOK_GT";
1024 CQL_DEBUG_TRACE("BISON::comp_op->TOK_GT\n");
|
1025 kumpf 1.19
|
1026 dave.sudlik 1.15 $$ = GT;
|
1027 karl 1.14 }
1028 | TOK_LT
1029 {
|
1030 dave.sudlik 1.15 CQL_globalParserState->currentRule = "comp_op->TOK_LT";
1031 CQL_DEBUG_TRACE("BISON::comp_op->TOK_LT\n");
1032 $$ = LT;
|
1033 karl 1.14 }
1034 | TOK_GE
1035 {
|
1036 dave.sudlik 1.15 CQL_globalParserState->currentRule = "comp_op->TOK_GE";
1037 CQL_DEBUG_TRACE("BISON::comp_op->TOK_GE\n");
1038 $$ = GE;
|
1039 karl 1.14 }
1040 | TOK_LE
1041 {
|
1042 dave.sudlik 1.15 CQL_globalParserState->currentRule = "comp_op->TOK_LE";
1043 CQL_DEBUG_TRACE("BISON::comp_op->TOK_LE\n");
1044 $$ = LE;
|
1045 karl 1.14 }
|
1046 chuck 1.2 ;
1047
1048 comp : arith
|
1049 karl 1.14 {
|
1050 dave.sudlik 1.15 CQL_globalParserState->currentRule = "comp->arith";
1051 CQL_DEBUG_TRACE("BISON::comp->arith\n");
|
1052 kumpf 1.19
|
1053 karl 1.14 $$ = $1;
1054 }
1055 | arith TOK_IS TOK_NOT TOK_NULL
1056 {
|
1057 kumpf 1.19 CQL_globalParserState->currentRule =
|
1058 dave.sudlik 1.15 "comp->arith TOK_IS TOK_NOT TOK_NULL";
1059 CQL_DEBUG_TRACE("BISON::comp->arith TOK_IS TOK_NOT TOK_NULL\n");
|
1060 kumpf 1.19
|
1061 karl 1.14 CQLExpression *_expr =
|
1062 dave.sudlik 1.15 (CQLExpression*)(_factory.getObject($1,Expression));
|
1063 karl 1.14 CQLSimplePredicate _sp(*_expr, IS_NOT_NULL);
1064 _factory.setObject($1,&_sp,SimplePredicate);
1065 $$ = $1;
1066 }
1067 | arith TOK_IS TOK_NULL
1068 {
|
1069 dave.sudlik 1.15 CQL_globalParserState->currentRule = "comp->arith TOK_IS TOK_NULL";
1070 CQL_DEBUG_TRACE("BISON::comp->arith TOK_IS TOK_NULL\n");
|
1071 kumpf 1.19
|
1072 karl 1.14 CQLExpression *_expr =
|
1073 dave.sudlik 1.15 (CQLExpression*)(_factory.getObject($1,Expression));
|
1074 karl 1.14 CQLSimplePredicate _sp(*_expr, IS_NULL);
1075 _factory.setObject($1,&_sp,SimplePredicate);
1076 $$ = $1;
1077 }
1078 | arith comp_op arith_or_value_symbol
1079 {
|
1080 kumpf 1.19 CQL_globalParserState->currentRule =
|
1081 dave.sudlik 1.15 "comp->arith comp_op arith_or_value_symbol";
1082 CQL_DEBUG_TRACE("BISON::comp->arith comp_op arith_or_value_symbol\n");
|
1083 kumpf 1.19
|
1084 karl 1.14 if($1->isSimple() && $3->isSimple())
1085 {
|
1086 karl 1.13 CQLExpression* _exp1 = (CQLExpression*)
|
1087 karl 1.14 (_factory.getObject($1,Predicate,Expression));
|
1088 karl 1.13 CQLExpression* _exp2 = (CQLExpression*)
|
1089 karl 1.14 (_factory.getObject($3,Predicate,Expression));
|
1090 karl 1.13 CQLSimplePredicate _sp(*_exp1, *_exp2, $2);
1091 $$ = new CQLPredicate(_sp);
1092 _ObjPtr._ptr = $$;
|
1093 humberto 1.6 _ObjPtr.type = Pred;
1094 _ptrs.append(_ObjPtr);
|
1095 karl 1.14 }
1096 else /* error */
1097 {
1098 String _msg("comp->arith comp_op arith_or_value_symbol : $1 is "
1099 "not simple OR $3 is not simple");
1100 throw CQLSyntaxErrorException(
1101 MessageLoaderParms("CQL.CQL_y.NOT_SIMPLE",
1102 "The CQLSimplePredicate is not simple while parsing "
1103 "rule $0 in position $1.",
1104 "comp->arith comp_op arith_or_value_symbol",
1105 CQL_globalParserState->currentTokenPos) );
1106 }
1107 }
1108 | value_symbol comp_op arith
1109 {
|
1110 kumpf 1.19 CQL_globalParserState->currentRule =
|
1111 dave.sudlik 1.15 "comp->value_symbol comp_op arith";
1112 CQL_DEBUG_TRACE("BISON::comp->value_symbol comp_op arith\n");
|
1113 kumpf 1.19
|
1114 karl 1.14 if($3->isSimple())
1115 {
|
1116 karl 1.13 CQLExpression* _exp1 = (CQLExpression*)
1117 (_factory.makeObject($1, Expression));
1118 CQLExpression* _exp2 = (CQLExpression*)
1119 (_factory.getObject($3,Predicate,Expression));
1120 CQLSimplePredicate _sp(*_exp1, *_exp2, $2);
1121 $$ = new CQLPredicate(_sp);
1122 _ObjPtr._ptr = $$;
|
1123 humberto 1.6 _ObjPtr.type = Pred;
1124 _ptrs.append(_ObjPtr);
|
1125 karl 1.14 }
1126 else /* error */
1127 {
|
1128 karl 1.13 String _msg("comp->value_symbol comp_op arith : $3 is not simple");
1129 throw CQLSyntaxErrorException(
|
1130 karl 1.14 MessageLoaderParms("CQL.CQL_y.NOT_SIMPLE",
1131 "The CQLSimplePredicate is not simple while parsing"
1132 " rule $0 in position $1.",
1133 "comp->value_symbol comp_op arith",
1134 CQL_globalParserState->currentTokenPos) );
|
1135 kumpf 1.19
|
1136 karl 1.14 }
1137 }
1138 | arith TOK_ISA identifier
1139 {
|
1140 kumpf 1.19 /* make sure $1 isSimple(), get its expression, make
1141 simplepred->predicate
|
1142 karl 1.14 */
|
1143 dave.sudlik 1.15 CQL_globalParserState->currentRule = "comp->arith _TOK_ISA identifier";
1144 CQL_DEBUG_TRACE("BISON::comp->arith _TOK_ISA identifier\n");
|
1145 kumpf 1.19
|
1146 karl 1.14 CQLExpression *_expr1 = (CQLExpression*)
1147 (_factory.getObject($1,Predicate,Expression));
1148 CQLChainedIdentifier _cid(*$3);
1149 CQLExpression *_expr2 = (CQLExpression*)
1150 (_factory.makeObject(&_cid,Expression));
1151 CQLSimplePredicate _sp(*_expr1, *_expr2, ISA);
1152 _factory.setObject($1,&_sp,SimplePredicate);
1153 $$ = $1;
1154 }
1155 | arith TOK_LIKE literal_string
1156 {
|
1157 kumpf 1.19 CQL_globalParserState->currentRule =
|
1158 dave.sudlik 1.15 "comp->arith TOK_LIKE literal_string";
1159 CQL_DEBUG_TRACE("BISON::comp->arith TOK_LIKE literal_string\n");
|
1160 kumpf 1.19
|
1161 dave.sudlik 1.15 CQLExpression *_expr1 = (CQLExpression*)
|
1162 karl 1.13 (_factory.getObject($1,Predicate,Expression));
|
1163 dave.sudlik 1.15 CQLValue _val(*$3);
1164 CQLExpression *_expr2 = (CQLExpression*)
|
1165 karl 1.13 (_factory.makeObject(&_val,Expression));
|
1166 dave.sudlik 1.15 CQLSimplePredicate _sp(*_expr1, *_expr2, LIKE);
1167 _factory.setObject($1,&_sp,SimplePredicate);
1168 $$ = $1;
|
1169 karl 1.14 }
|
1170 chuck 1.2 ;
1171 expr_factor : comp
|
1172 karl 1.14 {
|
1173 dave.sudlik 1.15 CQL_globalParserState->currentRule = "expr_factor->comp";
1174 CQL_DEBUG_TRACE("BISON::expr_factor->comp\n");
|
1175 kumpf 1.19
|
1176 karl 1.14 $$ = $1;
1177 }
1178 | TOK_NOT comp
1179 {
|
1180 dave.sudlik 1.15 CQL_globalParserState->currentRule = "expr_factor->TOK_NOT comp";
1181 CQL_DEBUG_TRACE("BISON::expr_factor->TOK_NOT comp\n");
|
1182 kumpf 1.19
|
1183 karl 1.14 $2->setInverted(!($2->getInverted()));
1184 $$ = $2;
1185 }
|
1186 chuck 1.2 ;
1187
1188 expr_term : expr_factor
|
1189 karl 1.14 {
|
1190 dave.sudlik 1.15 CQL_globalParserState->currentRule = "expr_term->expr_factor";
1191 CQL_DEBUG_TRACE("BISON::expr_term->expr_factor\n");
|
1192 kumpf 1.19
|
1193 karl 1.14 $$ = $1;
1194 }
1195 | expr_term TOK_AND expr_factor
1196 {
|
1197 kumpf 1.19 CQL_globalParserState->currentRule =
|
1198 dave.sudlik 1.15 "expr_term->expr_term AND expr_factor";
1199 CQL_DEBUG_TRACE("BISON::expr_term->expr_term AND expr_factor\n");
|
1200 kumpf 1.19
|
1201 karl 1.14 $$ = new CQLPredicate();
1202 $$->appendPredicate(*$1);
|
1203 kumpf 1.19 $$->appendPredicate(*$3, AND);
|
1204 karl 1.14 _ObjPtr._ptr = $$;
1205 _ObjPtr.type = Pred;
1206 _ptrs.append(_ObjPtr);
1207 }
|
1208 chuck 1.2 ;
1209
|
1210 kumpf 1.19 expr : expr_term
|
1211 karl 1.14 {
|
1212 dave.sudlik 1.15 CQL_globalParserState->currentRule = "expr->expr_term";
1213 CQL_DEBUG_TRACE("BISON::expr->expr_term\n");
|
1214 kumpf 1.19
1215 $$ = $1;
|
1216 karl 1.14 }
1217 | expr TOK_OR expr_term
1218 {
|
1219 dave.sudlik 1.15 CQL_globalParserState->currentRule = "expr->expr OR expr_term";
1220 CQL_DEBUG_TRACE("BISON::expr->expr OR expr_term\n");
|
1221 kumpf 1.19
|
1222 karl 1.14 $$ = new CQLPredicate();
1223 $$->appendPredicate(*$1);
1224 $$->appendPredicate(*$3, OR);
1225 _ObjPtr._ptr = $$;
1226 _ObjPtr.type = Pred;
1227 _ptrs.append(_ObjPtr);
1228 }
|
1229 chuck 1.2 ;
1230
1231 arg_list : {;}
|
1232 karl 1.14 /****************
|
1233 karl 1.13 | TOK_STAR
1234 {
|
1235 dave.sudlik 1.15 CQL_globalParserState->currentRule = "arg_list->TOK_STAR";
1236 CQL_DEBUG_TRACE("BISON::arg_list->TOK_STAR\n");
|
1237 kumpf 1.19
|
1238 karl 1.13 CQLIdentifier _id("*");
1239 CQLPredicate* _pred = (CQLPredicate*)
1240 (_factory.makeObject(&_id,Predicate));
|
1241 kumpf 1.19 _arglist.append(*_pred);
1242 since arg_list can loop back on itself,
1243 we need to store away previous solutions
|
1244 karl 1.13 production. We keep track of previous productions
1245 in the _arglist array and later pass that to CQLFunction
1246 as part of chain: identifier TOK_LPAR arg_list TOK_RPAR
|
1247 kumpf 1.19
|
1248 karl 1.13 }
|
1249 karl 1.14 *******************/
1250 | expr
1251 {
|
1252 dave.sudlik 1.15 CQL_globalParserState->currentRule = "arg_list->arg_list_sub->expr";
1253 CQL_DEBUG_TRACE("BISON::arg_list->arg_list_sub->expr\n");
|
1254 kumpf 1.19
|
1255 karl 1.14 _arglist.append(*$1);
1256 /*
1257 since arg_list can loop back on itself,
1258 we need to store away previous solutions
1259 production. We keep track of previous productions
1260 in the _arglist array and later pass that to CQLFunction
1261 as part of chain: identifier TOK_LPAR arg_list TOK_RPAR
1262 */
1263 }
|
1264 karl 1.13 /****************************
1265 | TOK_DISTINCT TOK_STAR
1266 {
|
1267 dave.sudlik 1.15 CQL_globalParserState->currentRule = "arg_list->TOK_DISTINCT TOK_STAR";
1268 CQL_DEBUG_TRACE("BISON::arg_list->TOK_DISTINCT TOK_STAR\n");
|
1269 karl 1.13
1270 CQLIdentifier _id("DISTINCTSTAR");
1271 CQLPredicate* _pred = (CQLPredicate*)
1272 (_factory.makeObject(&_id,Predicate));
1273 _arglist.append(*_pred);
1274 }
1275 | arg_list_sub arg_list_tail
1276 {
|
1277 dave.sudlik 1.15 CQL_DEBUG_TRACE("BISON::arg_list->arg_list_sub arg_list_tail\n");
|
1278 karl 1.13 }
|
1279 chuck 1.2 ;
1280
1281 arg_list_sub : expr
|
1282 karl 1.13 {
|
1283 dave.sudlik 1.15 CQL_DEBUG_TRACE("BISON::arg_list_sub->expr\n");
|
1284 kumpf 1.19
1285 _arlist.append(*$1);
1286 }
|
1287 karl 1.13 | TOK_DISTINCT expr
1288 {
|
1289 dave.sudlik 1.15 CQL_DEBUG_TRACE("BISON::arg_list_sub->TOK_DISTINCT expr\n");
|
1290 kumpf 1.19
|
1291 karl 1.13 String tmp1("TOK_DISTINCT");
1292 CQLIdentifier* _id = (CQLIdentifier*)
1293 (_factory.getObject($1,Predicate,Identifier));
1294 String tmp2(_id->getName().getString());
1295 tmp1.append(tmp2);
1296 CQLIdentifier _id1(tmp1);
1297 }
|
1298 chuck 1.2 ;
1299
1300 arg_list_tail : {;}
|
1301 karl 1.13 | TOK_COMMA arg_list_sub arg_list_tail
1302 {
|
1303 dave.sudlik 1.15 CQL_DEBUG_TRACE("BISON::arg_list_tail->TOK_COMMA arg_list_sub"
|
1304 karl 1.14 " arg_list_tail\n");
|
1305 karl 1.13 }
|
1306 chuck 1.2 ;
|
1307 karl 1.13 *******************/
1308
|
1309 chuck 1.2 from_specifier : class_path
|
1310 karl 1.14 {
|
1311 dave.sudlik 1.15 CQL_globalParserState->currentRule = "from_specifier->class_path";
1312 CQL_DEBUG_TRACE("BISON::from_specifier->class_path\n");
|
1313 kumpf 1.19
|
1314 karl 1.14 CQL_globalParserState->statement->appendClassPath(*$1);
|
1315 kumpf 1.19 }
|
1316 karl 1.14 | class_path TOK_AS identifier
1317 {
|
1318 kumpf 1.19 CQL_globalParserState->currentRule =
|
1319 dave.sudlik 1.15 "from_specifier->class_path TOK_AS identifier";
1320 CQL_DEBUG_TRACE(
1321 "BISON::from_specifier->class_path TOK_AS identifier\n");
|
1322 kumpf 1.19
|
1323 karl 1.14 CQLIdentifier _class(*$1);
1324 String _alias($3->getName().getString());
1325 CQL_globalParserState->statement->insertClassPathAlias(_class,_alias);
1326 CQL_globalParserState->statement->appendClassPath(_class);
1327 }
1328 | class_path identifier
1329 {
|
1330 kumpf 1.19 CQL_globalParserState->currentRule =
|
1331 dave.sudlik 1.15 "from_specifier->class_path identifier";
1332 CQL_DEBUG_TRACE("BISON::from_specifier->class_path identifier\n");
|
1333 kumpf 1.19
|
1334 karl 1.14 CQLIdentifier _class(*$1);
1335 String _alias($2->getName().getString());
1336 CQL_globalParserState->statement->insertClassPathAlias(_class,_alias);
1337 CQL_globalParserState->statement->appendClassPath(_class);
1338 }
|
1339 chuck 1.2 ;
1340
1341 from_criteria : from_specifier
|
1342 karl 1.14 {
|
1343 dave.sudlik 1.15 CQL_globalParserState->currentRule = "from_criteria->from_specifier";
1344 CQL_DEBUG_TRACE("BISON::from_criteria->from_specifier\n");
|
1345 karl 1.14 }
|
1346 karl 1.13 ;
1347
1348 star_expr : TOK_STAR
|
1349 karl 1.14 {
|
1350 dave.sudlik 1.15 CQL_globalParserState->currentRule = "star_expr->TOK_STAR";
1351 CQL_DEBUG_TRACE("BISON::star_expr->TOK_STAR\n");
|
1352 kumpf 1.19
|
1353 karl 1.14 CQLIdentifier _id("*");
1354 $$ = (CQLChainedIdentifier*)
1355 (_factory.makeObject(&_id,ChainedIdentifier));
1356 }
1357 | chain TOK_DOT TOK_STAR
1358 {
|
1359 dave.sudlik 1.15 CQL_globalParserState->currentRule = "star_expr->chain.*";
1360 CQL_DEBUG_TRACE("BISON::star_expr->chain.*\n");
|
1361 kumpf 1.19
|
1362 karl 1.14 CQLChainedIdentifier* _tmp = (CQLChainedIdentifier*)
1363 (_factory.getObject($1,Predicate,ChainedIdentifier));
1364 CQLChainedIdentifier* _cid = new CQLChainedIdentifier(*_tmp);
|
1365 karl 1.13 CQLIdentifier _id("*");
|
1366 karl 1.14 _cid->append(_id);
1367 $$ = _cid;
1368 _ObjPtr._ptr = $$;
1369 _ObjPtr.type = CId;
1370 _ptrs.append(_ObjPtr);
1371 }
|
1372 chuck 1.2 ;
1373
|
1374 kumpf 1.19 selected_entry : expr
|
1375 karl 1.14 {
|
1376 dave.sudlik 1.15 CQL_globalParserState->currentRule = "selected_entry->expr";
1377 CQL_DEBUG_TRACE("BISON::selected_entry->expr\n");
|
1378 kumpf 1.19
|
1379 karl 1.14 if($1->isSimpleValue())
1380 {
|
1381 karl 1.13 CQLChainedIdentifier *_cid = (CQLChainedIdentifier*)
1382 (_factory.getObject($1,Predicate,ChainedIdentifier));
1383 CQL_globalParserState->statement->appendSelectIdentifier(*_cid);
|
1384 karl 1.14 }
1385 else /* errot*/
1386 {
|
1387 karl 1.13 String _msg("selected_entry->expr : $1 is not a simple value");
1388 throw CQLSyntaxErrorException(
1389 MessageLoaderParms("CQL.CQL_y.NOT_SIMPLE_VALUE",
1390 "The CQLPredicate is not a simple value while "
1391 "parsing rule $0 in position $1.",
1392 "selected_entry->expr",
|
1393 kumpf 1.19 CQL_globalParserState->currentTokenPos) );
|
1394 karl 1.14 }
1395 }
1396 | star_expr
1397 {
|
1398 dave.sudlik 1.15 CQL_globalParserState->currentRule = "selected_entry->star_expr";
1399 CQL_DEBUG_TRACE("BISON::selected_entry->star_expr\n");
|
1400 kumpf 1.19
|
1401 karl 1.14 CQL_globalParserState->statement->appendSelectIdentifier(*$1);
1402 }
|
1403 chuck 1.2 ;
1404
1405 select_list : selected_entry select_list_tail
|
1406 karl 1.14 {
|
1407 kumpf 1.19 CQL_globalParserState->currentRule =
|
1408 dave.sudlik 1.15 "select_list->selected_entry select_list_tail";
1409 CQL_DEBUG_TRACE(
1410 "BISON::select_list->selected_entry select_list_tail\n");
|
1411 karl 1.14 }
|
1412 chuck 1.2 ;
1413
1414 select_list_tail : {;} /* empty */
|
1415 karl 1.14
1416 | TOK_COMMA selected_entry select_list_tail
1417 {
|
1418 kumpf 1.19 CQL_globalParserState->currentRule =
|
1419 dave.sudlik 1.15 "select_list_tail->TOK_COMMA selected_entry select_list_tail";
1420 CQL_DEBUG_TRACE(
1421 "BISON::select_list_tail->TOK_COMMA"
1422 " selected_entry select_list_tail\n");
|
1423 karl 1.14 }
|
1424 chuck 1.2 ;
1425
1426 search_condition : expr
|
1427 karl 1.14 {
|
1428 dave.sudlik 1.15 CQL_globalParserState->currentRule = "search_condition->expr";
1429 CQL_DEBUG_TRACE("BISON::search_condition->expr\n");
|
1430 kumpf 1.19
|
1431 karl 1.14 CQL_globalParserState->statement->setPredicate(*$1);
1432 }
|
1433 chuck 1.2 ;
1434
|
1435 humberto 1.6 optional_where : {}
|
1436 karl 1.13
|
1437 karl 1.14 | TOK_WHERE search_condition
1438 {
|
1439 kumpf 1.19 CQL_globalParserState->currentRule =
|
1440 dave.sudlik 1.15 "optional_where->TOK_WHERE search_condition";
1441 CQL_DEBUG_TRACE(
1442 "BISON::optional_where->TOK_WHERE search_condition\n");
|
1443 kumpf 1.19
|
1444 karl 1.14 CQL_globalParserState->statement->setHasWhereClause();
1445 }
|
1446 karl 1.13 ;
1447
|
1448 kumpf 1.19 select_statement : TOK_SELECT select_list TOK_FROM from_criteria optional_where
|
1449 karl 1.14 {
|
1450 dave.sudlik 1.15 CQL_globalParserState->currentRule = "select_statement";
1451 CQL_DEBUG_TRACE("select_statement\n");
|
1452 kumpf 1.19
|
1453 karl 1.14 CQL_Bison_Cleanup();
1454 }
|
1455 kumpf 1.19
|
1456 chuck 1.2 ;
1457
1458 %%
|
1459 karl 1.14 /*int yyerror(char * err){yyclearin; yyerrok;throw Exception(String(err));
1460 return 1;}*/
|