[Rd] Wish: C-API to get parse error messages (PR#9466)

From: <thomas.friedrichsmeier_at_ruhr-uni-bochum.de>
Date: Thu 25 Jan 2007 - 16:05:34 GMT


Full_Name: Thomas Friedrichsmeier
Version: 2.4.1
OS: Linux
Submission from: (NULL) (84.61.205.78)

Currently, the C-API provides for parsing vectors (R_ParseVector()), but there does not seem to be a way to get at the detailed parse error message from C. Only a status code is returned, no error message.

In the internal code, the function parseError() is responsible for producing such an error message. It would be very helpful, if this function could be made available - directly or indirectly - in the public API. Some more background information is available at
https://stat.ethz.ch/pipermail/r-devel/2007-January/044336.html.

Below are several alternative suggestions on different ways to add this:

  1. Simply make parseError(SEXP call, int linenum) public API (currently not in the public headers, and not visible in the library).
  2. To hide the details of parseError(), instead a wrapper could be created and made available like e.g.: void Rf_parseErrorDefault()
    {
    parseError(R_NilValue, 0); }
  3. It might be desirable to make parsing and producing the error an atomic operation to embedding code, in order to guard against race conditions, if there might be concurrent parses in the future. E.g. provide and export the following: SEXP R_ParseVectorWithError(SEXP exp, int num, ParseStatus *status, SEXP file)
    {
    SEXP pr; pr = R_ParseVector(exp, num, status, file); if(status == PARSE_ERROR) parseError(R_NilValue, 0); return pr; }
  4. Finally, if this wish has any chance of being fulfilled until R 2.5.0, production of a parse error could be made an additional parameter of R_ParseVector() (since R_ParseVector() has already gained a new parameter since 2.4, so there would be no additional API breakage): SEXP R_ParseVector(SEXP exp, int num, ParseStatus *status, SEXP file, Rboolean doerror);

Regards
Thomas Friedrichsmeier



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Jan 26 03:14:53 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 25 Jan 2007 - 16:31:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.