[R] Any parser generator / code assistance for R?

Duncan Murdoch murdoch at stats.uwo.ca
Mon Aug 20 19:47:34 CEST 2007


On 8/20/2007 1:27 PM, Ali - wrote:
>> A-> Hi,> A-> Is there any parser generator like www.antlr.org? Moreover, how does simple > A-> code assistance work currently in R? By 'simple code assistance' I meant > A-> things like:> > A-> Object$M<TAB> --> Object$Method> > If you really meant a list with components> or an S4 object with slots,> such code completion works at least since R 2.5.1, because of> the recent 'rcompletion' extensions of Deepayan Sarkar,> and of course in ESS (Emacs Speaks Statistics),> and I think in several other GUI/Environments as well.> > But if you are thinking OOP as in Java or C++ (and I think you> *are* thinking along that way), then rather learn> that S (and hence R) do OOP in a function-centric rather than class-centric> way; something which seems to be quite hard to grasp for many> who have been brought up in Java-like schools....> If you are still interested in R, look out for documents with> "S4" (or "formal methods and classes") and "R" in the title ;-)
> I am looking for an implemented parser generator of 'R', not only S4 classes or OOP style. By 'R', I mean 'R', it's that simple.
>  
> I am not a big fan of the inconsistency in R grammer for the price of freedom in bringing new inventions such as S4. 

What inconsistencies are you talking about?  There are plenty of 
semantic inconsistencies, but I can't think of any at the parser level. 
  In general the parser doesn't know anything about S3, S4, etc.

I understand this is a controversial subject and that many claim that in 
this way more options are brought to R. However, this makes R to look 
like a 'confused' language to me which is undecided between 
function-centric and object-oriented. We have the OOP package, the 
methods package and now the S4 classes which are very different to S3 
and my understanding is that the S3-based packages are not automatically 
upgradable to S4. What if in 7 years or so the authors decide to have a 
S5 class scheme which is very different to both S3 and S4?
>  
> In this way, it seems to me that there is no 'standard' in R. You may choose a flavour for R like R-S4 or R-S3 or R-this or R-that, and then develop your package based on that flavour. However, it looks like R-this and R-that flavours are actually different languages sharing some syntax.


> Here is a good demonstration for this problem: can we have one 'universal' parser for R?  Or do we need an R-this-parser and R-that-parser for each flavour?

There's currently only one parser for R, generated from src/main/gram.y.

  It seems that Martin said yes to the second question.
>  
> Moreover, my question is still somehow un-answered: Is there any existing ANTLR-based parser for R? I understand that in omegahat.org project, people used ANTLR for RSJava, but i am not sure if that had anything to do with an R-parser.

I doubt it.  The parser for R is written in yacc/bison, and since nobody 
has pointed to one based on ANTLR, it probably doesn't exist.

Duncan Murdoch



More information about the R-help mailing list