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

2007-08-20 Thread Ali -

 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$MTAB -- 
 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. 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? 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.
_


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2007-08-20 Thread Duncan Murdoch
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$MTAB -- 
 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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2007-08-20 Thread Gabor Grothendieck
On 8/17/07, Ali - [EMAIL PROTECTED] 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:
http://ryacas.googlecode.com

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2007-08-18 Thread Ali -
Hi,

Is there any parser generator like www.antlr.org?  Moreover, how does simple 
code assistance work currently in R? By 'simple code assistance' I meant 
things like:

Object$MTAB -- Object$Method

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2007-08-18 Thread Martin Maechler
 A- == Ali - [EMAIL PROTECTED]
 on Sat, 18 Aug 2007 00:40:52 +0100 writes:

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$MTAB -- 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  ;-)

Regards,
Martin

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.