[Rd] Question on parsing R code from C

KR krunal.rao78 at gmail.com
Wed Nov 16 20:48:28 CET 2011

Simon Urbanek <simon.urbanek <at> r-project.org> writes:
> Not without seeing the actual code. (And details such as which platform you're 
> Note that setup_Rmainloop() is the last to set the SETJMP context target so 
you should make sure the stack is
> still present after it finished (i.e. you can't call it from a sub-function - 
which Rf_initEmbeddedR
> does) otherwise error without an enclosing context will crash. Or to put it 
other way round, create a
> context around your parse/eval code (probably the easiest way to do that is to 
use R_ToplevelExec).

I will try to produce the exact code I am using (at the moment it embedded in
other code you would not be interested in), platforms are Windows XP and
Windows7-64. Some points:

1. Actually R_tryEvalSilent (and R_tryEval) calls R_ToplevelExec. Moreover if 
the problem is linked to the SETJMP (which I do not know much about 
unfortunately, my background is C++) it's my understanding that it should 
manifest itself even for other parse and evaluation errors. Instead the problem
arise if and only if I pass a wrongly escaped string. I.e. rnorm(10a10) does not 
result in a crash.
Is the R code doing something differently in this specific case?

2. My code is almost exactly the same as:
skipping the EXAMPLE 1 part and passing the capture.output(eval(parse(text="
<code>"))) string to R_tryEval in EXAMPLE 2.


More information about the R-devel mailing list