📄 cql.y
字号:
CQL_globalParserState->currentTokenPos) ); } } | value_symbol comp_op arith { CQL_globalParserState->currentRule = "comp->value_symbol comp_op arith"; sprintf(msg,"BISON::comp->value_symbol comp_op arith\n"); printf_(msg); if($3->isSimple()){ CQLExpression* _exp1 = (CQLExpression*)(_factory.makeObject($1, Expression)); CQLExpression* _exp2 = (CQLExpression*)(_factory.getObject($3,Predicate,Expression)); CQLSimplePredicate _sp(*_exp1, *_exp2, $2); $$ = new CQLPredicate(_sp); _ObjPtr._ptr = $$; _ObjPtr.type = Pred; _ptrs.append(_ObjPtr); }else{ /* error */ String _msg("comp->value_symbol comp_op arith : $3 is not simple"); throw CQLSyntaxErrorException( MessageLoaderParms(String("CQL.CQL_y.NOT_SIMPLE"), String("The CQLSimplePredicate is not simple while parsing rule $0 in position $1."), String("comp->value_symbol comp_op arith"), CQL_globalParserState->currentTokenPos) ); } } | arith _ISA identifier { CQL_globalParserState->currentRule = "comp->arith _ISA identifier"; /* make sure $1 isSimple(), get its expression, make simplepred->predicate */ sprintf(msg,"BISON::comp->arith _ISA identifier\n"); printf_(msg); CQLExpression *_expr1 = (CQLExpression*)(_factory.getObject($1,Predicate,Expression)); CQLChainedIdentifier _cid(*$3); CQLExpression *_expr2 = (CQLExpression*)(_factory.makeObject(&_cid,Expression)); CQLSimplePredicate _sp(*_expr1, *_expr2, ISA); _factory.setObject($1,&_sp,SimplePredicate); $$ = $1; } | arith _LIKE literal_string { CQL_globalParserState->currentRule = "comp->arith _LIKE literal_string"; sprintf(msg,"BISON::comp->arith _LIKE literal_string\n"); printf_(msg); CQLExpression *_expr1 = (CQLExpression*)(_factory.getObject($1,Predicate,Expression)); CQLValue _val(*$3); CQLExpression *_expr2 = (CQLExpression*)(_factory.makeObject(&_val,Expression)); CQLSimplePredicate _sp(*_expr1, *_expr2, LIKE); _factory.setObject($1,&_sp,SimplePredicate); $$ = $1; };expr_factor : comp { CQL_globalParserState->currentRule = "expr_factor->comp"; sprintf(msg,"BISON::expr_factor->comp\n"); printf_(msg); $$ = $1; } | NOT comp { CQL_globalParserState->currentRule = "expr_factor->NOT comp"; sprintf(msg,"BISON::expr_factor->NOT comp\n"); printf_(msg); $2->setInverted(!($2->getInverted())); $$ = $2; };expr_term : expr_factor { CQL_globalParserState->currentRule = "expr_term->expr_factor"; sprintf(msg,"BISON::expr_term->expr_factor\n"); printf_(msg); $$ = $1; } | expr_term _AND expr_factor { CQL_globalParserState->currentRule = "expr_term->expr_term AND expr_factor"; sprintf(msg,"BISON::expr_term->expr_term AND expr_factor\n"); printf_(msg); $$ = new CQLPredicate(); $$->appendPredicate(*$1); $$->appendPredicate(*$3, AND); _ObjPtr._ptr = $$; _ObjPtr.type = Pred; _ptrs.append(_ObjPtr); };expr : expr_term { CQL_globalParserState->currentRule = "expr->expr_term"; sprintf(msg,"BISON::expr->expr_term\n"); printf_(msg); $$ = $1; } | expr _OR expr_term { CQL_globalParserState->currentRule = "expr->expr OR expr_term"; sprintf(msg,"BISON::expr->expr OR expr_term\n"); printf_(msg); $$ = new CQLPredicate(); $$->appendPredicate(*$1); $$->appendPredicate(*$3, OR); _ObjPtr._ptr = $$; _ObjPtr.type = Pred; _ptrs.append(_ObjPtr); };arg_list : {;} /* | STAR { CQL_globalParserState->currentRule = "arg_list->STAR"; sprintf(msg,"BISON::arg_list->STAR\n"); printf_(msg); CQLIdentifier _id("*"); CQLPredicate* _pred = (CQLPredicate*)(_factory.makeObject(&_id,Predicate)); _arglist.append(*_pred); since arg_list can loop back on itself, we need to store away previous solutions production. We keep track of previous productions in the _arglist array and later pass that to CQLFunction as part of chain: identifier LPAR arg_list RPAR }*/ | expr { CQL_globalParserState->currentRule = "arg_list->arg_list_sub->expr"; sprintf(msg,"BISON::arg_list_sub->expr\n"); printf_(msg); _arglist.append(*$1);/* since arg_list can loop back on itself, we need to store away previous solutions production. We keep track of previous productions in the _arglist array and later pass that to CQLFunction as part of chain: identifier LPAR arg_list RPAR */ }/* | DISTINCT STAR { sprintf(msg,"BISON::arg_list->DISTINCT STAR\n"); printf_(msg); CQLIdentifier _id("DISTINCTSTAR"); CQLPredicate* _pred = (CQLPredicate*)(_factory.makeObject(&_id,Predicate)); _arglist.append(*_pred); } | arg_list_sub arg_list_tail { sprintf(msg,"BISON::arg_list->arg_list_sub arg_list_tail\n"); printf_(msg); };arg_list_sub : expr { sprintf(msg,"BISON::arg_list_sub->expr\n"); printf_(msg); _arlist.append(*$1); } | DISTINCT expr { sprintf(msg,"BISON::arg_list_sub->DISTINCT expr\n"); printf_(msg); String tmp1("DISTINCT"); CQLIdentifier* _id = (CQLIdentifier*)(_factory.getObject($1,Predicate,Identifier)); String tmp2(_id->getName().getString()); tmp1.append(tmp2); CQLIdentifier _id1(tmp1); };arg_list_tail : {;} | COMMA arg_list_sub arg_list_tail { sprintf(msg,"BISON::arg_list_tail->COMMA arg_list_sub arg_list_tail\n"); printf_(msg); };*/from_specifier : class_path { CQL_globalParserState->currentRule = "from_specifier->class_path"; sprintf(msg,"BISON::from_specifier->class_path\n"); printf_(msg); CQL_globalParserState->statement->appendClassPath(*$1); } | class_path AS identifier { CQL_globalParserState->currentRule = "from_specifier->class_path AS identifier"; sprintf(msg,"BISON::from_specifier->class_path AS identifier\n"); printf_(msg); CQLIdentifier _class(*$1); String _alias($3->getName().getString()); CQL_globalParserState->statement->insertClassPathAlias(_class,_alias); CQL_globalParserState->statement->appendClassPath(_class); } | class_path identifier { CQL_globalParserState->currentRule = "from_specifier->class_path identifier"; sprintf(msg,"BISON::from_specifier->class_path identifier\n"); printf_(msg); CQLIdentifier _class(*$1); String _alias($2->getName().getString()); CQL_globalParserState->statement->insertClassPathAlias(_class,_alias); CQL_globalParserState->statement->appendClassPath(_class); };from_criteria : from_specifier { CQL_globalParserState->currentRule = "from_criteria->from_specifier"; sprintf(msg,"BISON::from_criteria->from_specifier\n"); printf_(msg); };star_expr : STAR { CQL_globalParserState->currentRule = "star_expr->STAR"; sprintf(msg,"BISON::star_expr->STAR\n"); printf_(msg); CQLIdentifier _id("*"); $$ = (CQLChainedIdentifier*)(_factory.makeObject(&_id,ChainedIdentifier)); } | chain DOT STAR { CQL_globalParserState->currentRule = "star_expr->chain.*"; sprintf(msg,"BISON::star_expr->chain.*\n"); printf_(msg); CQLChainedIdentifier* _tmp = (CQLChainedIdentifier*)(_factory.getObject($1,Predicate,ChainedIdentifier)); CQLChainedIdentifier* _cid = new CQLChainedIdentifier(*_tmp); CQLIdentifier _id("*"); _cid->append(_id); $$ = _cid; _ObjPtr._ptr = $$; _ObjPtr.type = CId; _ptrs.append(_ObjPtr); };selected_entry : expr { CQL_globalParserState->currentRule = "selected_entry->expr"; sprintf(msg,"BISON::selected_entry->expr\n"); printf_(msg); if($1->isSimpleValue()){ CQLChainedIdentifier *_cid = (CQLChainedIdentifier*)(_factory.getObject($1,Predicate,ChainedIdentifier)); CQL_globalParserState->statement->appendSelectIdentifier(*_cid); }else{ /* error */ String _msg("selected_entry->expr : $1 is not a simple value"); throw CQLSyntaxErrorException( MessageLoaderParms(String("CQL.CQL_y.NOT_SIMPLE_VALUE"), String("The CQLPredicate is not a simple value while parsing rule $0 in position $1."), String("selected_entry->expr"), CQL_globalParserState->currentTokenPos) ); } } | star_expr { CQL_globalParserState->currentRule = "selected_entry->star_expr"; sprintf(msg,"BISON::selected_entry->star_expr\n"); printf_(msg); CQL_globalParserState->statement->appendSelectIdentifier(*$1); };select_list : selected_entry select_list_tail { CQL_globalParserState->currentRule = "select_list->selected_entry select_list_tail"; sprintf(msg,"BISON::select_list->selected_entry select_list_tail\n"); printf_(msg); };select_list_tail : {;} /* empty */ | COMMA selected_entry select_list_tail { CQL_globalParserState->currentRule = "select_list_tail->COMMA selected_entry select_list_tail"; sprintf(msg,"BISON::select_list_tail->COMMA selected_entry select_list_tail\n"); printf_(msg); };search_condition : expr { CQL_globalParserState->currentRule = "search_condition->expr"; sprintf(msg,"BISON::search_condition->expr\n"); printf_(msg); CQL_globalParserState->statement->setPredicate(*$1); };optional_where : {} | WHERE search_condition { CQL_globalParserState->currentRule = "optional_where->WHERE search_condition"; sprintf(msg,"BISON::optional_where->WHERE search_condition\n"); printf_(msg); CQL_globalParserState->statement->setHasWhereClause(); };select_statement : SELECT select_list FROM from_criteria optional_where { CQL_globalParserState->currentRule = "select_statement"; sprintf(msg,"select_statement\n\n"); printf_(msg); CQL_Bison_Cleanup(); } ;%%/*int yyerror(char * err){yyclearin; yyerrok;throw Exception(String(err));return 1;}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -