⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cql.y

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 Y
📖 第 1 页 / 共 4 页
字号:
		String _msg("chain->chain.identifier#literal_string : chain state not CQLIDENTIFIER or CQLCHAINEDIDENTIFIER");		throw CQLSyntaxErrorException(                                        MessageLoaderParms(String("CQL.CQL_y.NOT_CHAINID_OR_IDENTIFIER"),                                                           String("Chain state not a CQLIdentifier or a CQLChainedIdentifier while parsing rule $0 in position $1."),							   String("chain.identifier#literal_string"),                                                           CQL_globalParserState->currentTokenPos)                                                 );            }                                                                                                                    chain_state = CQLCHAINEDIDENTIFIER;        }      | chain LBRKT array_index_list RBRKT        {	    CQL_globalParserState->currentRule = "chain->chain[ array_index_list ]";            sprintf(msg,"BISON::chain->chain[ array_index_list ] : chain_state = %d\n",chain_state);	    printf_(msg);	            if(chain_state == CQLIDENTIFIER){		CQLIdentifier *_id = ((CQLIdentifier*)(_factory.getObject($1,Predicate,Identifier)));		String tmp = _id->getName().getString();		tmp.append("[").append(*$3).append("]");		CQLIdentifier _id1(tmp);		CQLChainedIdentifier _cid(_id1);		_factory.setObject(((CQLPredicate*)$1),&_cid,ChainedIdentifier);                $$ = $1;		    }else if(chain_state == CQLCHAINEDIDENTIFIER || chain_state == CQLVALUE){		CQLPredicate* _pred = (CQLPredicate*)$1;		CQLChainedIdentifier *_cid = ((CQLChainedIdentifier*)(_factory.getObject($1,Predicate,ChainedIdentifier)));		CQLIdentifier tmpid = _cid->getLastIdentifier();		String tmp = tmpid.getName().getString();                tmp.append("[").append(*$3).append("]");		CQLIdentifier _id1(tmp);		CQLChainedIdentifier _tmpcid(_id1);		if(_cid->size() == 1){			_cid = &_tmpcid;		}else{			_cid->append(_id1);		}		_factory.setObject(((CQLPredicate*)$1),_cid,ChainedIdentifier);                $$ = $1;	    }else{		/* error */		String _msg("chain->chain[ array_index_list ] : chain state not CQLIDENTIFIER or CQLCHAINEDIDENTIFIER or CQLVALUE");		throw CQLSyntaxErrorException(                                        MessageLoaderParms(String("CQL.CQL_y.NOT_CHAINID_OR_IDENTIFIER_OR_VALUE"),                                                           String("Chain state not a CQLIdentifier or a CQLChainedIdentifier or a CQLValue while parsing rule $0 in position $1."),							   String("chain->chain[ array_index_list ]"),                                                           CQL_globalParserState->currentTokenPos)                                                 );	    }        };concat : chain         {	     CQL_globalParserState->currentRule = "concat->chain";             sprintf(msg,"BISON::concat->chain\n");	     printf_(msg);	     $$ = ((CQLPredicate*)$1);         }       | concat DBL_PIPE literal_string         {	         CQL_globalParserState->currentRule = "concat->concat || literal_string";            sprintf(msg,"BISON::concat||literal_string\n");	         printf_(msg);		      CQLValue* tmpval = new CQLValue(*$3);	         _ObjPtr._ptr = tmpval;            _ObjPtr.type = Val;            _ptrs.append(_ObjPtr);  			   if((CQLPredicate*)$1->isSimple())            {               CQLSimplePredicate sp = ((CQLPredicate*)$1)->getSimplePredicate();					if(sp.isSimple())					{                  CQLExpression exp = sp.getLeftExpression();						if(exp.isSimple())						{                    CQLTerm* _term = ((CQLTerm*)(_factory.getObject($1, Predicate, Term)));                    // check for simple literal values                    Array<CQLFactor> factors = _term->getFactors();                    for(Uint32 i = 0; i < factors.size(); i++){                       if(!factors[i].isSimpleValue()){                          MessageLoaderParms mparms("CQL.CQL_y.CONCAT_PRODUCTION_FACTORS_NOT_SIMPLE",                                                   "The CQLFactors are not simple while processing rule $0.",                                                    CQL_globalParserState->currentRule);                          throw CQLSyntaxErrorException(mparms);                       }else{                          CQLValue val = factors[i].getValue();                          if(val.getValueType() != CQLValue::String_type){                             MessageLoaderParms mparms("CQL.CQL_y.CONCAT_PRODUCTION_VALUE_NOT_LITERAL",                                                       "The CQLValue is not a string literal while processing rule $0.",                                                       CQL_globalParserState->currentRule);                             throw CQLSyntaxErrorException(mparms);		                    }                       }                    }                    CQLFactor* _fctr2 = ((CQLFactor*)(_factory.makeObject(tmpval, Factor)));                    _term->appendOperation(concat,*_fctr2);                    $$ = (CQLPredicate*)(_factory.makeObject(_term,Predicate)); 						}                  else                  {                     MessageLoaderParms mparms("CQL.CQL_y.CONCAT_PRODUCTION_NOT_SIMPLE",                                               "The $0 is not simple while processing rule $1.",															  String("CQLExpression"),                                               CQL_globalParserState->currentRule);                     throw CQLSyntaxErrorException(mparms);                  }					 }                else                {                     MessageLoaderParms mparms("CQL.CQL_y.CONCAT_PRODUCTION_NOT_SIMPLE",                                               "The $0 is not simple while processing rule $1.",															  String("CQLSimplePredicate"),                                               CQL_globalParserState->currentRule);                     throw CQLSyntaxErrorException(mparms);                }				 }             else             {                     MessageLoaderParms mparms("CQL.CQL_y.CONCAT_PRODUCTION_NOT_SIMPLE",                                               "The $0 is not simple while processing rule $1.",															  String("CQLPredicate"),                                               CQL_globalParserState->currentRule);                     throw CQLSyntaxErrorException(mparms);             }        };factor : concat	 {	     CQL_globalParserState->currentRule = "factor->concat";             sprintf(msg,"BISON::factor->concat\n");	     printf_(msg);	     $$ = $1;         }               /* | PLUS concat         {	      add enum instead of _invert to CQLFactor,has to be either nothing, + or -              get the factor and set the optype appropriately	     CQL_globalParserState->currentRule = "concat->PLUS concat";              printf("BISON::factor->PLUS concat\n");             $$ = new CQLFactor(*(CQLValue*)$2);         }       | MINUS concat         {              get the factor and set the optype appropriately 	     CQL_globalParserState->currentRule = "concat->MINUS concat";             printf("BISON::factor->MINUS concat\n");             CQLValue *tmp = (CQLValue*)$2;             tmp->invert();	     $$ = new CQLFactor(*tmp);         }*/;term : factor       {	   CQL_globalParserState->currentRule = "term->factor";           sprintf(msg,"BISON::term->factor\n");	   printf_(msg);           $$ = $1;       }    /* | term STAR factor       {	    get factor out of $1, get factor out of $3, appendoperation, then construct predicate and forward it            printf("BISON::term->term STAR factor\n");	   CQL_globalParserState->currentRule = "term->term STAR factor";           $1->appendOperation(mult, *$3);           $$ = $1;       }     | term DIV factor       {            get factor out of $1, get factor out of $3, appendoperation, then construct predicate and forward it 	   CQL_globalParserState->currentRule = "term->term DIV factor";           printf("BISON::term->term DIV factor\n");           $1->appendOperation(divide, *$3);           $$ = $1;       }*/;arith : term        {	    CQL_globalParserState->currentRule = "arith->term";            sprintf(msg,"BISON::arith->term\n");	    printf_(msg);	    //CQLPredicate* _pred = new CQLPredicate(*$1);//	    _factory._predicates.append(_pred);            $$ = $1;        }     /* | arith PLUS term        {	     get term out of $1, get term out of $3, appendoperation, then construct predicate and forward it	    CQL_globalParserState->currentRule = "arith->arith PLUS term";            printf("BISON::arith->arith PLUS term\n");            $1->appendOperation(TERM_ADD, *$3);            $$ = $1;        }      | arith MINUS term        {	    get term out of $1, get term out of $3, appendoperation, then construct predicate and forward it 	    CQL_globalParserState->currentRule = "arith->arith MINUS term";            printf("BISON::arith->arith MINUS term\n");	    $1->appendOperation(TERM_SUBTRACT, *$3);            $$ = $1;        }*/;value_symbol : HASH literal_string               {	  	   CQL_globalParserState->currentRule = "value_symbol->#literal_string";                   sprintf(msg,"BISON::value_symbol->#literal_string\n");                   printf_(msg);		   String tmp("#");		   tmp.append(*$2);		   CQLIdentifier tmpid(tmp);		   $$ = new CQLValue(tmpid);			_ObjPtr._ptr = $$;         _ObjPtr.type = Val;         _ptrs.append(_ObjPtr);               };arith_or_value_symbol : arith                        {			    CQL_globalParserState->currentRule = "arith_or_value_symbol->arith";                            sprintf(msg,"BISON::arith_or_value_symbol->arith\n");			    printf_(msg);			    $$ = $1;                        }                      | value_symbol                        {			    /* make into predicate */			    CQL_globalParserState->currentRule = "arith_or_value_symbol->value_symbol";                            sprintf(msg,"BISON::arith_or_value_symbol->value_symbol\n");			    printf_(msg);			    CQLFactor _fctr(*$1);			    $$ = (CQLPredicate*)(_factory.makeObject(&_fctr, Predicate));                        };comp_op : _EQ           {	      CQL_globalParserState->currentRule = "comp_op->_EQ";              sprintf(msg,"BISON::comp_op->_EQ\n");	      printf_(msg);	      $$ = EQ;          }        | _NE          {	      CQL_globalParserState->currentRule = "comp_op->_NE";              sprintf(msg,"BISON::comp_op->_NE\n");	      printf_(msg);	      $$ = NE;          }        | _GT           {	      CQL_globalParserState->currentRule = "comp_op->_GT";              sprintf(msg,"BISON::comp_op->_GT\n");	      printf_(msg);	      $$ = GT;          }        | _LT          { 	      CQL_globalParserState->currentRule = "comp_op->_LT";              sprintf(msg,"BISON::comp_op->_LT\n");	      printf_(msg);	      $$ = LT;          }        | _GE          {	      CQL_globalParserState->currentRule = "comp_op->_GE";              sprintf(msg,"BISON::comp_op->_GE\n");	      printf_(msg);	      $$ = GE;          }        | _LE          {	      CQL_globalParserState->currentRule = "comp_op->_LE";              sprintf(msg,"BISON::comp_op->_LE\n");	      printf_(msg);	      $$ = LE;          };comp : arith       {	   CQL_globalParserState->currentRule = "comp->arith";           sprintf(msg,"BISON::comp->arith\n");	   printf_(msg);	   $$ = $1;       }     | arith IS NOT _NULL       {	   CQL_globalParserState->currentRule = "comp->arith IS NOT _NULL";           sprintf(msg,"BISON::comp->arith IS NOT _NULL\n");	   printf_(msg);	   CQLExpression *_expr = (CQLExpression*)(_factory.getObject($1,Expression));	   CQLSimplePredicate _sp(*_expr, IS_NOT_NULL);           _factory.setObject($1,&_sp,SimplePredicate);	   $$ = $1;       }     | arith IS _NULL       {	   CQL_globalParserState->currentRule = "comp->arith IS _NULL";           sprintf(msg,"BISON::comp->arith IS _NULL\n");	   printf_(msg);	   CQLExpression *_expr = (CQLExpression*)(_factory.getObject($1,Expression));           CQLSimplePredicate _sp(*_expr, IS_NULL);           _factory.setObject($1,&_sp,SimplePredicate);           $$ = $1;       }     | arith comp_op arith_or_value_symbol       {	   CQL_globalParserState->currentRule = "comp->arith comp_op arith_or_value_symbol";           sprintf(msg,"BISON::comp->arith comp_op arith_or_value_symbol\n");	   printf_(msg);	   if($1->isSimple() && $3->isSimple()){		CQLExpression* _exp1 = (CQLExpression*)(_factory.getObject($1,Predicate,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->arith comp_op arith_or_value_symbol : $1 is not simple OR $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->arith comp_op arith_or_value_symbol"),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -