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

Gabor Grothendieck ggrothendieck at gmail.com
Tue Aug 21 04:56:36 CEST 2007

On 8/17/07, Ali - <saveez at hotmail.com> wrote:
> Hi,
> Is there any parser generator like www.antlr.org?  Moreover, how does simple

Given the response, it looks like no one has come up with an antlr
parser for R but there are some facilities within R itself.

showTree() in the R codetools package which can generate a
Lisp style expression for any R expression:

> library(codetools)
> showTree(quote(for(i in myvec[1:3]) print(i+88*2+3*4)))
(for i ([ myvec (: 1 3)) (print (+ (+ i (* 88 2)) (* 3 4))))

Looking at the source of showTree would show you how to walk
an R parse tree.

The Ryacas R package has a recursive descent R parser that is used to
process R code translating it to yacas and it also can translate OpenMath
XML code generated by yacas to R.  See:

More information about the R-help mailing list