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

Duncan Murdoch murdoch at stats.uwo.ca
Thu Jun 18 23:02:05 CEST 2009


Romain Francois wrote:
> 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?
>
>   

I would oppose that.  Suggest ways to reduce the complexity of the 
parser interface and I'd be interested.  It's a nightmare to make any 
changes there.

You can always call the R function wrapped in try(), so it's not as 
though this would give you anything that you don't already have access to. 

Duncan Murdoch

> 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
>>>       
>
>
>



More information about the R-devel mailing list