• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ParserError函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ParserError函数的典型用法代码示例。如果您正苦于以下问题:C++ ParserError函数的具体用法?C++ ParserError怎么用?C++ ParserError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ParserError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ParserError

  //------------------------------------------------------------------------------
  void FunMax::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
  {
	  if (a_iArgc < 1)
		throw ParserError(ErrorContext(ecTOO_FEW_PARAMS, GetExprPos(), GetIdent()));

	float_type smax(-1e30), sval(0);
	for (int i=0; i<a_iArgc; ++i)
	{
	  switch(a_pArg[i]->GetType())
	  {
	  case 'f': sval = a_pArg[i]->GetFloat();   break;
	  case 'i': sval = a_pArg[i]->GetFloat(); break;
	  case 'n': break; // ignore not in list entries (missing parameter)
	  case 'c':
	  default:
		{
		  ErrorContext err;
		  err.Errc = ecTYPE_CONFLICT_FUN;
		  err.Arg = i+1;
		  err.Type1 = a_pArg[i]->GetType();
		  err.Type2 = 'f';
		  throw ParserError(err);
		}
	  }
	  smax = max(smax, sval);
	}

	*ret = smax;
  }
开发者ID:shadeMe,项目名称:BGSEditorExtenderBase,代码行数:30,代码来源:mpFuncCommon.cpp


示例2: GetType

//---------------------------------------------------------------------------
bool IValue::operator<=(const IValue &a_Val) const
{
    char_type type1 = GetType(),
        type2 = a_Val.GetType();

    if (type1 == type2 || (IsScalar() && a_Val.IsScalar()))
    {
        switch (GetType())
        {
        case 's': return GetString() <= a_Val.GetString();
        case 'i':
        case 'f':
        case 'c': return GetFloat() <= a_Val.GetFloat();
        case 'b': return GetBool() <= a_Val.GetBool();
        default:
            ErrorContext err;
            err.Errc = ecINTERNAL_ERROR;
            err.Pos = -1;
            err.Type1 = GetType();
            err.Type2 = a_Val.GetType();
            throw ParserError(err);

        } // switch this type
    }
    else
    {
        ErrorContext err;
        err.Errc = ecTYPE_CONFLICT_FUN;
        err.Arg = (type1 != 'f' && type1 != 'i') ? 1 : 2;
        err.Type1 = type2;
        err.Type2 = type1;
        throw ParserError(err);
    }
}
开发者ID:cloudqiu1110,项目名称:math-parser-benchmark-project,代码行数:35,代码来源:mpIValue.cpp


示例3: Backwards_Fixed_Array_Format

/* this parsing rule allows compatibility with RTC fixed array formats
   like [17:char].  note it doesn't handle more general formats like
   [3,4:char]. use of these formats is deprecated: use, for example,
   [char:17] instead */
static FORMAT_PTR Backwards_Fixed_Array_Format(Format_Parse_Ptr parser, 
					       BOOLEAN *error)
{ 
  FORMAT_PTR Form, next_format;
  TokenPtr tmp, arraySizeToken;
  
  arraySizeToken = NextToken(parser);
  if (INT_TOK != arraySizeToken->Type) {
    ParserError(arraySizeToken, parser, "an integer value");
    return NULL;
  }
  tmp = NextToken(parser);
  if (COLON_TOK != tmp->Type) {
    ParserError(tmp, parser, "':'");
    return NULL;
  }
  next_format = Parse(parser, FALSE, error); /* Formatter */
  tmp = NextToken(parser);
  if (RBRACK_TOK != tmp->Type) {
    ParserError(tmp, parser, "']'");
    return NULL;
  }

  Form = new_a_formatter(FixedArrayFMT, 3);
  Form->formatter.a[1].f = next_format;
  Form->formatter.a[2].i = arraySizeToken->value.num;
  
  return Form;
}
开发者ID:acekiller,项目名称:MasterThesis,代码行数:33,代码来源:parseFmttrs.c


示例4: assert

  //-----------------------------------------------------------------------------------------------
  void OprtSubCmplx::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int num)
  { 
    assert(num==2);
    
    const IValue *arg1 = a_pArg[0].Get();
    const IValue *arg2 = a_pArg[1].Get();
    if ( a_pArg[0]->IsNonComplexScalar() && a_pArg[1]->IsNonComplexScalar())
    {
      *ret = arg1->GetFloat() - arg2->GetFloat(); 
    }
    else if (a_pArg[0]->GetType()=='m' && a_pArg[1]->GetType()=='m')
    {
      // Matrix + Matrix
      *ret = arg1->GetArray() - arg2->GetArray();
    }
    else
    {
      if (!a_pArg[0]->IsScalar())
        throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, GetExprPos(), GetIdent(), a_pArg[0]->GetType(), 'c', 1)); 

      if (!a_pArg[1]->IsScalar())
        throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, GetExprPos(), GetIdent(), a_pArg[1]->GetType(), 'c', 2)); 
      
      *ret = cmplx_type(a_pArg[0]->GetFloat() - a_pArg[1]->GetFloat(),
                        a_pArg[0]->GetImag() - a_pArg[1]->GetImag()); 
    }
  }
开发者ID:boussaffawalid,项目名称:OTB,代码行数:28,代码来源:mpOprtCmplx.cpp


示例5: indices

  /** \brief Index operator implementation
      \param ret A reference to the return value
      \param a_pArg Pointer to an array with the indices as ptr_val_type
      \param a_iArgc Number of indices (=dimension) actully used in the expression found. This must 
             be 1 or 2 since three dimensional data structures are not supported by muParserX.
  */
  void OprtIndex::At(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
  {
    try
    {
      // The index is -1, thats the actual variable reference
      if (a_iArgc!=a_pArg[-1]->GetDim())
      {
        throw ParserError(ErrorContext(ecINDEX_DIMENSION, -1, GetIdent()));
      }

      switch(a_iArgc)
      {
      case 1:
          ret.Reset(new Variable( &(ret->At(*a_pArg[0], Value(0))) ) );
          break;

      case 2:
          ret.Reset(new Variable( &(ret->At(*a_pArg[0], *a_pArg[1])) ) );
          break;

      default:
          throw ParserError(ErrorContext(ecINDEX_DIMENSION, -1, GetIdent()));
      }
    }
    catch(ParserError &exc)
    {
      exc.GetContext().Pos = GetExprPos();
      throw exc;
    }
  }
开发者ID:QAndot,项目名称:muparser,代码行数:36,代码来源:mpOprtIndex.cpp


示例6: Enum_Format

static FORMAT_PTR Enum_Format(Format_Parse_Ptr parser, BOOLEAN *error)
{ 
  TokenPtr Token;
  FORMAT_PTR Form, subform;
  LIST_PTR format_list;
  int num_formats, i, maxVal;
  
  num_formats = 0;
  Token = NextToken(parser);
  if (Token->Type == COLON_TOK) {
    Token = NextToken(parser);
    if (Token->Type != INT_TOK) {
      *error = TRUE;
      ParserError(Token, parser, "an integer");
      return NULL;
    } else {
      maxVal = Token->value.num;
    }
  } else {
    format_list = x_ipc_listCreate();
    do {
      if (num_formats > 0) Token = NextToken(parser);
      if (Token->Type != STR_TOK) {
	*error = TRUE;
	ParserError(Token, parser, "a string");
	return NULL;
      } else {
	Form = new_n_formatter(Token->value.str);
	/* More efficient for Lisp if all enum format names are upper case */
	LOCK_M_MUTEX;
	if (IS_LISP_MODULE()) {
	  upcase(Form->formatter.name);
	}
	UNLOCK_M_MUTEX;
	x_ipc_listInsertItem((char *)Form, format_list);
	num_formats++;
      }
      Token = NextToken(parser);
    } while (Token->Type == COMMA_TOK);
    UngetToken(parser, Token);
    maxVal = num_formats - 1;
  }
  
  Form = new_a_formatter(EnumFMT, num_formats+2);
  Form->formatter.a[1].i = maxVal;
  if (num_formats > 0) {
    /* Index from high to low since "format_list" 
       has formatters in reverse order */
    subform = (FORMAT_PTR)x_ipc_listFirst(format_list);
    for(i=num_formats;i>0;i--) {
      Form->formatter.a[i+1].f = subform;
      subform = (FORMAT_PTR)x_ipc_listNext(format_list);
    }
    x_ipc_listFree(&format_list);
  }
  return Form;
}
开发者ID:acekiller,项目名称:MasterThesis,代码行数:57,代码来源:parseFmttrs.c


示例7: Fixed_Array_Format

static FORMAT_PTR Fixed_Array_Format(Format_Parse_Ptr parser, BOOLEAN *error)
{ 
  FORMAT_PTR Form, next_format;
  TokenPtr Token, tmp;
  int NumberOfIndexes, Continue, array_index;
  
  tmp = parser->TokenList;
  if (INT_TOK == tmp->Type) {
    return Backwards_Fixed_Array_Format(parser, error);
  }
  next_format = Parse(parser, FALSE, error); /* Formatter */
  
  Token = NextToken(parser);
  if (Token->Type != COLON_TOK) {
    ParserError(Token, parser, "':'");
    return NULL;
  }
  
  tmp = parser->TokenList;
  NumberOfIndexes = 0;
  Continue = TRUE;
  do {
    if (tmp->Type != INT_TOK) {
      ParserError(tmp, parser, "an integer value");
      return NULL;
    }
    else {
      NumberOfIndexes++;
      tmp = tmp->next;
      if (tmp->Type == COMMA_TOK) {
	tmp = tmp->next;
	Continue = TRUE;
      } else if (tmp->Type == RBRACK_TOK) {
	Continue = FALSE;
      } else {
	ParserError(tmp, parser, "a ',' or ']'");
	return NULL;
      }
    }
  } while (Continue);
  
  Form = new_a_formatter(FixedArrayFMT, NumberOfIndexes+2);
  Form->formatter.a[1].f = next_format;
  
  /* this time munch tokens */
  
  NumberOfIndexes += 2;
  for (array_index=2; array_index < NumberOfIndexes; array_index++) {
    Token = NextToken(parser); /* This is an INT_TOK */
    Form->formatter.a[array_index].i = Token->value.num;
    
    Token = NextToken(parser); /* This is a COMMA_TOK or a RBRACK_TOK */
  }
  
  return Form;
}
开发者ID:acekiller,项目名称:MasterThesis,代码行数:56,代码来源:parseFmttrs.c


示例8: assert

  /** \brief Implements the Division operator. 
      \throw ParserError in case one of the arguments if 
             nonnumeric or an array.
  
  */
  void OprtDiv::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int num)
  { 
    assert(num==2);

    if (!a_pArg[0]->IsNonComplexScalar())
      throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, -1, GetIdent(), a_pArg[0]->GetType(), 'f', 1)); 

    if (!a_pArg[1]->IsNonComplexScalar())
      throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, -1, GetIdent(), a_pArg[1]->GetType(), 'f', 2)); 
    
    *ret = a_pArg[0]->GetFloat() / a_pArg[1]->GetFloat();
  }
开发者ID:QAndot,项目名称:muparser,代码行数:17,代码来源:mpOprtNonCmplx.cpp


示例9: ExtractToken

/** \brief Check wheter a token at a given position is an undefined variable.
    \param a_Tok [out] If a variable tom_pParser->m_vStringBufken has been found it will be placed here.
    \return true if a variable token has been found.
    \throw nothrow
    */
bool TokenReader::IsUndefVarTok(ptr_tok_type &a_Tok)
{
    string_type sTok;
    int iEnd = ExtractToken(m_pParser->ValidNameChars(), sTok, m_nPos);
    if (iEnd == m_nPos || (sTok.size() > 0 && sTok[0] >= _T('0') && sTok[0] <= _T('9')))
        return false;

    if (m_nSynFlags & noVAR)
    {
        ErrorContext err;
        err.Errc = ecUNEXPECTED_VAR;
        err.Ident = sTok;
        err.Expr = m_sExpr;
        err.Pos = m_nPos;
        throw ParserError(err);
    }

    // Create a variable token
    if (m_pParser->m_bAutoCreateVar)
    {
        ptr_val_type val(new Value);                   // Create new value token
        m_pDynVarShadowValues->push_back(val);         // push to the vector of shadow values 
        a_Tok = ptr_tok_type(new Variable(val.Get())); // bind variable to the new value item
        (*m_pVarDef)[sTok] = a_Tok;                    // add new variable to the variable list
    }
    else
        a_Tok = ptr_tok_type(new Variable(nullptr));      // bind variable to empty variable

    a_Tok->SetIdent(sTok);
    m_UsedVar[sTok] = a_Tok;     // add new variable to used-var-list

    m_nPos = iEnd;
    m_nSynFlags = noVAL | noVAR | noFUN | noBO | noIFX;
    return true;
}
开发者ID:MirkoFl,项目名称:math-parser-benchmark-project,代码行数:40,代码来源:mpTokenReader.cpp


示例10: MUP_ASSERT

  //------------------------------------------------------------------------------
  void OprtSign::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)  
  { 
    MUP_ASSERT(a_iArgc==1);

    if (a_pArg[0]->IsScalar())
    {
      *ret = -a_pArg[0]->GetFloat();
    }
    else if (a_pArg[0]->GetType()=='m')
    {
      Value v(a_pArg[0]->GetRows(), 0);
      for (int i=0; i<a_pArg[0]->GetRows(); ++i)
      {
        v.At(i) = -a_pArg[0]->At(i).GetFloat();
      }
      *ret = v;
    }
    else
    {
        ErrorContext err;
        err.Errc = ecINVALID_TYPE;
        err.Type1 = a_pArg[0]->GetType();
        err.Type2 = 's';
        throw ParserError(err);
    }
  }
开发者ID:QAndot,项目名称:muparser,代码行数:27,代码来源:mpOprtNonCmplx.cpp


示例11: min

  /** \brief Returns the minimum value of all values. 
      \param a_pArg Pointer to an array of Values
      \param a_iArgc Number of values stored in a_pArg
  */
  void FunMin::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
  {
    float_type min(1e30), val(min);

    for (int i=0; i<a_iArgc; ++i)
    {
      switch(a_pArg[i]->GetType())
      {
      case 'f': 
      case 'i': val = a_pArg[i]->GetFloat();   break;
      default:
        {
          ErrorContext err;
          err.Errc = ecTYPE_CONFLICT_FUN;
          err.Arg = i+1;
          err.Type1 = a_pArg[i]->GetType();
          err.Type2 = 'f';
          throw ParserError(err);
        }
      }
      min = std::min(min, val);    
    }
    
    *ret = min;
  }
开发者ID:CarlosManuelRodr,项目名称:QBill,代码行数:29,代码来源:mpFuncCommon.cpp


示例12: throw

void TypeParser::TypeDefineStatement(TokenStream *lexerStream, TypeSystem *__typeSystem)  throw(ParserError)
{
    // current is `LET
    // read next
    lexerStream->next();

    // 这里指向下一个token
    TypeSpecifier(lexerStream, __typeSystem);

    lexerStream->next();

    if(lexerStream->current().value() == "as") {
        lexerStream->next();

        if(__typeSystem->isRegisterType(lexerStream->current().value())) {
            __typeSystem->registerType(lexerStream->current().value(),
                                       __typeSystem->getHelper()->takeCurrentArgumentTypeMetaData());
            __typeSystem->mapTypeName(lexerStream->current().value(),
                                      __typeSystem->getHelper()->takeFullTypeName());

        } else {
            throw ParserError(-1, "Type "+lexerStream->current().value()+" Already exist.");
        }
        TypeName(lexerStream, __typeSystem);
        lexerStream->next();
    }
}
开发者ID:qyvlik,项目名称:LearnCompilers,代码行数:27,代码来源:typeparser.cpp


示例13: ParserError

 //---------------------------------------------------------------------------
 const SToken* ParserByteCode::GetBase() const
 {
   if (m_vRPN.size()==0)
     throw ParserError(ecINTERNAL_ERROR);
   else
     return &m_vRPN[0];
 }
开发者ID:AngeloTorelli,项目名称:CompuCell3D,代码行数:8,代码来源:muParserBytecode.cpp


示例14: GetIdent

  /** \brief Return the value as an integer. 
    
    This function should only be called if you really need an integer value and
    want to make sure your either get one or throw an exception if the value
    can not be implicitely converted into an integer.
  */
  int_type Value::GetInteger() const
  {
    float_type v = m_val.real();

    if (m_cType!='i') //!IsScalar() || (int_type)v-v!=0)
    {
      ErrorContext err;
      err.Errc  = ecTYPE_CONFLICT;
      err.Type1 = m_cType;
      err.Type2 = 'i';
      
      if (GetIdent().length())
      {
        err.Ident = GetIdent();
      }
      else
      {
        stringstream_type ss;
        ss << *this;
        err.Ident = ss.str();
      }

      throw ParserError(err);
    }

    return (int_type)v;
  }
开发者ID:boussaffawalid,项目名称:OTB,代码行数:33,代码来源:mpValue.cpp


示例15: ParserError

  //---------------------------------------------------------------------------
  IValue& Value::At(int nRow, int nCol)
  {
    if (IsMatrix())
    {
      if (nRow>=m_pvVal->GetRows() || nCol>=m_pvVal->GetCols() || nRow<0 || nCol<0)
        throw ParserError( ErrorContext(ecINDEX_OUT_OF_BOUNDS, -1, GetIdent()) ); 

      return m_pvVal->At(nRow, nCol);
    }
    else if (nRow==0 && nCol==0)
    {
      return *this;
    }
    else
      throw ParserError( ErrorContext(ecINDEX_OUT_OF_BOUNDS) ); 
  }
开发者ID:boussaffawalid,项目名称:OTB,代码行数:17,代码来源:mpValue.cpp


示例16: if

  //---------------------------------------------------------------------------
  IValue& Value::operator+=(const IValue &val)
  {
    if (IsScalar() && val.IsScalar())
    {
      // Scalar/Scalar addition
      m_val += val.GetComplex();
      m_cType = (m_val.imag()==0) ? ( (m_val.real()==(int)m_val.real()) ? 'i' : 'f' ) : 'c';
    }
    else if (IsMatrix() && val.IsMatrix())
    {
      // Matrix/Matrix addition
      assert(m_pvVal);
      *m_pvVal += val.GetArray();
    }
    else if (IsString() && val.IsString())
    {
      // string/string addition
      assert(m_psVal);
      *m_psVal += val.GetString();
    }
    else
    {
      // Type conflict
      throw ParserError(ErrorContext(ecTYPE_CONFLICT_FUN, -1, _T("+"), GetType(), val.GetType(), 2));
    }

    return *this;
  }
开发者ID:boussaffawalid,项目名称:OTB,代码行数:29,代码来源:mpValue.cpp


示例17: max

 //------------------------------------------------------------------------------
 void FunMax::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
 {
   float_type max(-1e30), val(0);
   for (int i=0; i<a_iArgc; ++i)
   {
     switch(a_pArg[i]->GetType())
     {
     case 'f': val = a_pArg[i]->GetFloat();   break;
     case 'i': val = a_pArg[i]->GetFloat(); break;
     case 'n': break; // ignore not in list entries (missing parameter)
     case 'c':
     default:
       {
         ErrorContext err;
         err.Errc = ecTYPE_CONFLICT_FUN;
         err.Arg = i+1;
         err.Type1 = a_pArg[i]->GetType();
         err.Type2 = 'f';
         throw ParserError(err);
       }
     }
     max = std::max(max, val);    
   }
   
   *ret = max;
 }
开发者ID:CarlosManuelRodr,项目名称:QBill,代码行数:27,代码来源:mpFuncCommon.cpp


示例18: ParserError

/** \brief Verify the operator prototype.

  Binary operators have the additional constraint that return type and the types
  of both arguments must be the same. So adding to floats can not produce a string
  and adding a number to a string is impossible.
*/
void IOprtBin::CheckPrototype(const string_type &a_sProt)
{
    if (a_sProt.length()!=4)
        throw ParserError( ErrorContext(ecAPI_INVALID_PROTOTYPE, -1, GetIdent() ) );

    //if (a_sProt[0]!=a_sProt[2] || a_sProt[0]!=a_sProt[3])
    //  throw ParserError( ErrorContext(ecAPI_INVALID_PROTOTYPE, -1, GetIdent() ) );
}
开发者ID:QAndot,项目名称:muparser,代码行数:14,代码来源:mpIOprt.cpp


示例19: ParserError

StorageClassSpecifierNode::StorageClassSpecifierNode(int storageSpecKind ) 
{
	if ( StorageSpecifierKindStart  <= storageSpecKind && storageSpecKind <= StorageSpecifierKindEnd ) {
		specifier = storageSpecKind;
	}
	else {
		throw ParserError(ParserError::Whatever, "StorageClassSpecifierNode");
	}
}
开发者ID:YutaMatsumoto,项目名称:MIPSc,代码行数:9,代码来源:StorageClassSpecifierNode.cpp


示例20: switch

//---------------------------------------------------------------------------
IValue& IValue::operator=(const IValue &ref)
{
    if (this == &ref)
        return *this;

    switch (ref.GetType())
    {
    case 'i':
    case 'f':
    case 'c': return *this = cmplx_type(ref.GetFloat(), ref.GetImag());
    case 's': return *this = ref.GetString();
    case 'm': return *this = ref.GetArray();
    case 'b': return *this = ref.GetBool();
    case 'v':
        throw ParserError(_T("Assignment from void type is not possible"));

    default:
        throw ParserError(_T("Internal error: unexpected data type identifier in IValue& operator=(const IValue &ref)"));
    }
}
开发者ID:cloudqiu1110,项目名称:math-parser-benchmark-project,代码行数:21,代码来源:mpIValue.cpp



注:本文中的ParserError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ParserException函数代码示例发布时间:2022-05-30
下一篇:
C++ Parse_String函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap