MichaelChirico / r-bugs

A ⚠️read-only⚠️mirror of https://bugs.r-project.org/
20 stars 0 forks source link

[BUGZILLA #15265] Added support for display of parseError while using libR #4853

Closed MichaelChirico closed 4 years ago

MichaelChirico commented 4 years ago

Hi ,

I have developed a project which utilizes R from C . We are calling libR and follow the instruction :

PROTECT(tmp = mkString(prog)); PROTECT(e = R_ParseVector(tmp, -1, &status,R_NilValue)); if (status != PARSE_OK) {

  PrintValue(mkString("Parsing error :=>"));
  sprintf(cmd,"syntax error on line %d ",R_ParseError);
  PrintValue(e);
  if (TYPEOF(e) == EXPRSXP) {
    e = eval(VECTOR_ELT(e, 0), R_GlobalEnv);
    PrintValue(e);
}

This function returns SEXP and status of parse. It does not return any parse Error messages .

I have modified the R code , added a new function R_throwError() which will return the private variable R_ParseErrorMsg for parsing error. I am wondering If this part can be added to R code .

It is useful for people who call libR from C. Some time the errors are hard to find in a big file.The error message will provide line number , position of error and error message.

Please let me know.

Thanks, Sandip


METADATA

MichaelChirico commented 4 years ago

You are much better off using parse() instead - it will give you errors and will work better on files.


METADATA

MichaelChirico commented 4 years ago

No more of the parse interface will be exposed: as Simon says, use what is provided in R.


METADATA