Ejemplo n.º 1
0
//---------------------------------------------------------------------------
// Callback function for parser errors
void OnError(muParserHandle_t hParser)
{
  printf("\nError:\n");
  printf("------\n");
  printf("Message:  \"%s\"\n", mupGetErrorMsg(hParser));
  printf("Token:    \"%s\"\n", mupGetErrorToken(hParser));
  printf("Position: %d\n", mupGetErrorPos(hParser));
  printf("Errc:     %d\n", mupGetErrorCode(hParser));
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
// Callback function for parser errors
void OnError()
{
  printf("\nError:\n");
  printf("------\n");
  printf("Message:  %s\n", mupGetErrorMsg());
  printf("Token:    %s\n", mupGetErrorToken());
  printf("Position: %s\n", mupGetErrorPos());
  printf("Errc:     %s\n", mupGetErrorCode());
}
Ejemplo n.º 3
0
// Callback function for parser errors
void OnError(muParserHandle_t hParser)
{
	char err[256];

	snprintf(err, 256, "Error:\n");
	snprintf(err, 256, "%s------\n", err);
	snprintf(err, 256, "%sMessage:  \"%s\"\n", err, mupGetErrorMsg(hParser));
	snprintf(err, 256, "%sToken:    \"%s\"\n", err, mupGetErrorToken(hParser));
	snprintf(err, 256, "%sPosition: %d\n", err, mupGetErrorPos(hParser));
	snprintf(err, 256, "%sErrc:     %d\n", err, mupGetErrorCode(hParser));

	error(err);
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------
void CalcBulk()
{
  int nBulkSize = 200, i;
  muFloat_t *x = (muFloat_t*)malloc(nBulkSize * sizeof(muFloat_t));
  muFloat_t *y = (muFloat_t*)malloc(nBulkSize * sizeof(muFloat_t));
  muFloat_t *r = (muFloat_t*)malloc(nBulkSize * sizeof(muFloat_t));

  muParserHandle_t hParser = mupCreate(muBASETYPE_FLOAT);              // initialize the parser
  
  for (i=0; i<nBulkSize; ++i)
  {
    x[i] = i;
    y[i] = i;
    r[i] = 0;
  }

  mupDefineVar(hParser, "x", x);  
  mupDefineVar(hParser, "y", y);
  mupDefineBulkFun1(hParser, "bulktest", BulkTest);
  mupSetExpr(hParser, "bulktest(x+y)");
  mupEvalBulk(hParser, r, nBulkSize);
  if (mupError(hParser))
  {
    printf("\nError:\n");
    printf("------\n");
    printf("Message:  %s\n", mupGetErrorMsg(hParser) );
    printf("Token:    %s\n", mupGetErrorToken(hParser) );
    printf("Position: %d\n", mupGetErrorPos(hParser) );
    printf("Errc:     %d\n", mupGetErrorCode(hParser) );
    return;
  }

  for (i=0; i<nBulkSize; ++i)
  {
    printf("%d: bulkfun(%2.2f + %2.2f) = %2.2f\n", i, x[i], y[i], r[i]);
    x[i] = i;
    y[i] = (muFloat_t)i/10;
  }

  free(x);
  free(y);
  free(r);
}