1 /* ------------------------------------------------
2 Copyright 2014 AT&T Intellectual Property
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
7 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ------------------------------------------- */
18 bison --verbose --defines=ifq.tab.cc.h -p IfqParser -o ifq.tab.cc ifq.y
28 /* Some addn'l includes, necessary but not included by the
34 /* prototypes for the parser callbacks.
37 #include "parse_fta.h"
40 extern fta_parse_t *ifq_parse_result;
56 /* for FTA definition. */
58 scalarexp_t *scalarval;
59 se_list_t *se_listval;
60 select_list_t *select_listval;
63 literal_list_t *lit_l;
65 tablevar_list_t *tbl_list;
80 %token <strval> STRING_TOKEN
81 %token <strval> INTNUM
82 %token <strval> LONGINTNUM
83 %token <strval> APPROXNUM
85 /* for FTA definition. */
86 %type <q_list> query_list
88 %type <tblp> select_statement
89 %type <tblp> table_exp
90 %type <predp> where_clause
91 %type <predp> search_condition
92 %type <predp> predicate
93 %type <litval> literal
94 %type <scalarval> scalar_exp
95 %type <se_listval> scalar_exp_commalist
107 /* literal keyword tokens */
108 %token SEMICOLON LEFTBRACE RIGHTBRACE
109 /* For query definition */
112 %token FROM INNER_JOIN OUTER_JOIN LEFT_OUTER_JOIN RIGHT_OUTER_JOIN
113 %token GROUP HAVING IN
118 %token TRUE_V FALSE_V
119 %token TIMEVAL_L HEX_L LHEX_L IP_L
122 %token DEFINE_SEC PARAM_SEC
124 /* For table definition */
125 %token RIGHTBRACE PROTOCOL TABLE STREAM FTA
126 %token OPERATOR OPERATOR_VIEW FIELDS SUBQUERIES SELECTION_PUSHDOWN
131 /* Union of possible results */
132 parse_result: query_list {
133 ifq_parse_result->parse_tree_list = $1;
134 ifq_parse_result->tables = NULL;
135 ifq_parse_result->parse_type = QUERY_PARSE;
142 WARNING: there might be some relics.
145 gsql: NAME ':' select_statement {
146 $$ = $3; $$->nmap["name"] = $1;
150 query_list: gsql {$$ = new query_list_t($1);}
151 | query_list SEMICOLON gsql {$$ = $1->append($3);}
160 /* query expressions */
165 where_clause {$$=new table_exp_t(NULL,$1,NULL,NULL,NULL,NULL,NULL,NULL);}
171 search_condition {$$ = $1;}
176 /* search conditions */
179 search_condition OR search_condition {$$=new predicate_t("OR",$1,$3);}
180 | search_condition AND search_condition {$$=new predicate_t("AND",$1,$3);}
181 | NOT search_condition {$$ = new predicate_t("NOT", $2 );}
182 | '(' search_condition ')' {$$ = $2;}
183 | predicate {$$ = $1;}
187 PRED '[' scalar_exp_commalist ']' {$$ = new predicate_t($1, $3->get_se_list()); }
191 /* scalar expressions */
194 literal { $$= scalarexp_t::make_param_reference($1->to_string().c_str());}
195 | NAME {$$ = scalarexp_t::make_param_reference($1);}
199 scalar_exp_commalist:
200 scalar_exp { $$= new se_list_t($1); }
201 | scalar_exp_commalist ',' scalar_exp { $$=$1->append($3); }
205 STRING_TOKEN {$$ = new literal_t($1,LITERAL_STRING);}
206 | INTNUM {$$ = new literal_t($1,LITERAL_INT);}
207 | LONGINTNUM {$$ = new literal_t($1,LITERAL_LONGINT);}
208 | APPROXNUM {$$ = new literal_t($1,LITERAL_FLOAT);}
209 | TRUE_V {$$ = new literal_t("TRUE",LITERAL_BOOL);}
210 | FALSE_V {$$ = new literal_t("FALSE",LITERAL_BOOL);}
211 | TIMEVAL_L STRING_TOKEN {$$ = new literal_t($2,LITERAL_TIMEVAL);}
212 | HEX_L STRING_TOKEN {$$ = new literal_t($2,LITERAL_HEX);}
213 | LHEX_L STRING_TOKEN {$$ = new literal_t($2,LITERAL_LONGHEX);}
214 | IP_L STRING_TOKEN {$$ = new literal_t($2,LITERAL_IP);}