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