From romain.francois at dbmail.com  Thu Jun 18 20:02:41 2009
From: romain.francois at dbmail.com (Romain Francois)
Date: Thu, 18 Jun 2009 20:02:41 +0200
Subject: [Rd] R_parseVector and syntax error [was: error messages while
 parsing with rniParse]
In-Reply-To: <63D1BDD5-D697-4F84-96A8-CD89AE8C4113@r-project.org>
References: <4A36715A.2020003@dbmail.com>
	<63D1BDD5-D697-4F84-96A8-CD89AE8C4113@r-project.org>
Message-ID: <4A3A8141.6080401@dbmail.com>

Hello,

[I'm redirecting this here from stats-rosuda-devel]

When parsing R code through R_parseVector and the code generates an 
error (syntax error), is there a way to grab the error.
It looks like yyerror populates the buffer "R_ParseErrorMsg", but then 
the variable is not part of the public api.

Would it be possible to add yet another entry point to the parser that 
would basically wrap R_parseVector so that it would have an extra char* 
argument that would bring back the error message if there is an error?

Romain

Simon Urbanek wrote:
> On Jun 15, 2009, at 12:05 , Romain Francois wrote:
>
>> Hello,
>>
>> In JRI, is there a way to get the error message that is generated by the
>> parser through rniParse
>> For example, if I have this :
>>
>> long y = re.rniParse( "rnorm( 10 ))", 1 ) ;
>>
>> this obviously generates a parse error, so y will be the same as
>> (R_NilValue) :
>>
>> long null_id = re.rniEval( re.rniParse( "NULL", 1 ), 0 ) ;
>>
>> I guess the underlying question is : "Is R_ParseErrorMsg exposed to
>> JRI".
>
> AFAICT R_ParseErrorMsg and friends are not exposed by the R API - they 
> are not accessible outside, so they cannot be use by JRI. It would be 
> nice if there was a way of accessing that info, but R doesn't 
> currently support that.
>
> Cheers,
> Simon
>
>> The reason is I would like to bring back the message as part of an
>> exception generated when the code does not parse.
>>
>> Romain


-- 
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr



[Rd] R_parseVector and syntax error [was: error messages while parsing with rniParse]
Romain Francois