From krunal.rao78 at gmail.com  Wed Nov 16 20:48:28 2011
From: krunal.rao78 at gmail.com (KR)
Date: Wed, 16 Nov 2011 19:48:28 +0000
Subject: [Rd] Question on parsing R code from C
References: <loom.20111108T203022-872@post.gmane.org>
	<9465BE63-EA88-4BE2-8D1C-9E33BE8AA45D@r-project.org>
	<loom.20111108T224700-655@post.gmane.org>
	<3D4F776D-4D5D-4C39-90B3-12DF09C5C6BA@r-project.org>
	<loom.20111109T001139-68@post.gmane.org>
	<AF0744B1-C119-4BF1-99D0-9DBA31E734F9@r-project.org>
	<loom.20111111T000844-348@post.gmane.org>
	<84A85DE6-2914-4C8D-834A-07DE5820B5AD@r-project.org>
	<loom.20111115T225950-180@post.gmane.org>
	<F4E5DACB-DBAC-46AE-B647-6A93CAA8FAB2@r-project.org>
Message-ID: <loom.20111116T203740-838@post.gmane.org>

Simon Urbanek <simon.urbanek <at> r-project.org> writes:
> Not without seeing the actual code. (And details such as which platform you're 
on).
> 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:
http://stackoverflow.com/questions/2463437/r-from-c-simplest-possible-
helloworld/2464479#2464479
skipping the EXAMPLE 1 part and passing the capture.output(eval(parse(text="
<code>"))) string to R_tryEval in EXAMPLE 2.

Cheers,



[Rd] Question on parsing R code from C
KR