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