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