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