Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > How to write a ruby compiler using Java???

Reply
Thread Tools

How to write a ruby compiler using Java???

 
 
shiwei zhang
Guest
Posts: n/a
 
      07-27-2007
Hi,

I am using Java to write a Ruby compiler. I build up the editor by
Java SWing.
Now the tough task for me is syntax parser. Does someone have some
suggestions about how to check the validity of ruby codes in the editor
and how to mark the grammar-incompliant points? Are there some plugins I
can make use of, or do I need to parse the grammar by myself? If I want
to parse the grammar by myself, where is the complete grammar definition
for ruby lang? E.G., like C99(ISO 9899:1999) for C lang. Seems there is
not a complete grammar definition for ruby lang at http://www.ruby-lang.org.
Many Thanks.

Best Rgds,
Shiwei

 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      07-27-2007
2007/7/27, shiwei zhang <>:
> I am using Java to write a Ruby compiler. I build up the editor by
> Java SWing.
> Now the tough task for me is syntax parser. Does someone have some
> suggestions about how to check the validity of ruby codes in the editor
> and how to mark the grammar-incompliant points? Are there some plugins I
> can make use of, or do I need to parse the grammar by myself? If I want
> to parse the grammar by myself, where is the complete grammar definition
> for ruby lang? E.G., like C99(ISO 9899:1999) for C lang. Seems there is
> not a complete grammar definition for ruby lang at http://www.ruby-lang.org.


Why not join http://jruby.codehaus.org/? There you might also find
answers to your questions.

Kind regards

robert

 
Reply With Quote
 
 
 
 
Charles Oliver Nutter
Guest
Posts: n/a
 
      07-27-2007
shiwei zhang wrote:
> Hi,
>
> I am using Java to write a Ruby compiler. I build up the editor by
> Java SWing.
> Now the tough task for me is syntax parser. Does someone have some
> suggestions about how to check the validity of ruby codes in the editor
> and how to mark the grammar-incompliant points? Are there some plugins I
> can make use of, or do I need to parse the grammar by myself? If I want
> to parse the grammar by myself, where is the complete grammar definition
> for ruby lang? E.G., like C99(ISO 9899:1999) for C lang. Seems there is
> not a complete grammar definition for ruby lang at
> http://www.ruby-lang.org.
> Many Thanks.


There are basically two known good grammars for Ruby. One is the
original Ruby 1.8 YACC-based parser grammar and variations of it (JRuby,
Rubinius, and Ruby.NET/IronRuby all use variations or ports of that
grammar). The other is an ANTLR grammar used by the XRuby project. Only
the YACC grammars are known to be "compatible" at present, but XRuby's
ANTLR grammar seems to be very close.

If you are looking for a grammar/AST to use for an editor, your best bet
is probably JRuby's. Not only do we have the most popular grammar and
AST for Java-based editors, but we have an additional set of utility
code to allow inspecting, reversing, and manipulating the AST. NetBeans,
Eclipse, and JEdit-based Ruby editors are based on our parser and AST,
as is (I believe) the IntelliJ Ruby editor. We also have been building
the JRuby Ruby-to-bytecode compiler based on that AST.

- Charlie

 
Reply With Quote
 
M. Edward (Ed) Borasky
Guest
Posts: n/a
 
      07-27-2007
Charles Oliver Nutter wrote:
> shiwei zhang wrote:
>> Hi,
>>
>> I am using Java to write a Ruby compiler. I build up the editor by
>> Java SWing.
>> Now the tough task for me is syntax parser. Does someone have some
>> suggestions about how to check the validity of ruby codes in the
>> editor and how to mark the grammar-incompliant points? Are there some
>> plugins I can make use of, or do I need to parse the grammar by
>> myself? If I want to parse the grammar by myself, where is the
>> complete grammar definition for ruby lang? E.G., like C99(ISO
>> 9899:1999) for C lang. Seems there is not a complete grammar
>> definition for ruby lang at http://www.ruby-lang.org.
>> Many Thanks.

>
> There are basically two known good grammars for Ruby. One is the
> original Ruby 1.8 YACC-based parser grammar and variations of it (JRuby,
> Rubinius, and Ruby.NET/IronRuby all use variations or ports of that
> grammar). The other is an ANTLR grammar used by the XRuby project. Only
> the YACC grammars are known to be "compatible" at present, but XRuby's
> ANTLR grammar seems to be very close.
>
> If you are looking for a grammar/AST to use for an editor, your best bet
> is probably JRuby's. Not only do we have the most popular grammar and
> AST for Java-based editors, but we have an additional set of utility
> code to allow inspecting, reversing, and manipulating the AST. NetBeans,
> Eclipse, and JEdit-based Ruby editors are based on our parser and AST,
> as is (I believe) the IntelliJ Ruby editor. We also have been building
> the JRuby Ruby-to-bytecode compiler based on that AST.
>
> - Charlie
>
>

Just out of curiosity, where do the "Zen" tools (ParseTree, Ruby2Ruby,
etc.) fit into this scheme of things?

Also, is there such a thing as Test Driven/Behavior Driven parser
development? Should there be?

 
Reply With Quote
 
Charles Oliver Nutter
Guest
Posts: n/a
 
      07-27-2007
M. Edward (Ed) Borasky wrote:
> Just out of curiosity, where do the "Zen" tools (ParseTree, Ruby2Ruby,
> etc.) fit into this scheme of things?


Most of the tools you're thinking of depend on C code that can access or
expose the Ruby 1.8 AST. There is a port of ParseTree for JRuby called
JParseTree, and it's mostly complete but not being used for anything.
Several of the other libraries, like Ruby2Ruby, depend mostly? only? on
ParseTree.

RubyInline depends on both C code/compilers and the Ruby 1.8 APIs, and
as yet there is no port.

I believe others in the zen family would qualify as "stock" extensions.
Of course Ryan can give a more specific overview; my perspective is
mostly that of an alternative implementer.

- Charlie

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net 2 07-29-2008 09:50 AM
Write to error log using redirect:write Petterson Mikael XML 1 09-11-2006 12:06 PM
Using write function within email Module to write get_payload to afile. Chuck Amadi Python 0 06-22-2004 12:13 PM
write a union object using write JasBascom C++ 1 02-24-2004 08:18 AM



Advertisments