This adds nothing to your previous post: please don't be annoying and post
almost identical messages.
I strongly suspect you mean 'parse error' and 'how can I parse R
code',
but we don't know what the example was and what the error message was.
Nor do we know what you are doing with this fragement of C code (and
returnng an unprotected SEXP via a (void *) cast is a recipe for tears).
parse(text=) uses R_ParseVector, and that works for 'code that includes
comments and newlines', so please check out the internal code used (in
src/main/gram.c).
If you study the posting guide you should be able to formulate a posting
that people can actually help you with.
On Mon, 4 Aug 2008, Peter Jaeger wrote:
> Dear List,
>
> When I try to parse code containing newline characters with R_ParseVector,
I
> get a compilation error. How can I compile code that includes comments and
> newlines?
>
> I am using the following:
>
> void* my_compile(char *code)
> {
> SEXP cmdSexp, cmdExpr = R_NilValue;
> ParseStatus status;
>
> PROTECT (cmdSexp = allocVector (STRSXP, 1));
> SET_STRING_ELT (cmdSexp, 0, mkChar (code));
> PROTECT (cmdExpr = R_ParseVector (cmdSexp,-1,&status,
> R_NilValue));
> UNPROTECT_PTR (cmdSexp);
>
> if (status != PARSE_OK) {
> return (void*)0;
> } else {
> return (void*)cmdExpr;
> }
> }
>
> Regards,
> Peter
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595