Interesting (and useful) exercise with the Ruby grammar by N

Nick S. just posted (well … I just found out about it) a graph of
the Ruby grammar on his blog. He also posted the same graphs for Java
and Javascript. While the pictures are interesting, impressive and
useful, what’s even more interesting, to me, anyhow, is that there
exists a tool set to do this sort of thing!

I haven’t had a chance to go tracking down the whole tool set yet, but
it’s definitely on my todo list at this point. Most of it appears to be
tied to Antlr, which leads me to wonder if it can/should be ported to
Ruby.

And yes, Pat, if I can find a grammar for Forth I might well generate
the picture for it. :slight_smile:

http://blog.nicksieger.com/articles/2006/10/27/visualization-of-rubys-grammar

Thanks, Nick!!

On 10/29/06, M. Edward (Ed) Borasky [email protected] wrote:

I haven’t had a chance to go tracking down the whole tool set yet, but
it’s definitely on my todo list at this point. Most of it appears to be
tied to Antlr, which leads me to wonder if it can/should be ported to
Ruby.

What’s interesting with ANTLR 3 is that Ruby is one of the target
languages. I haven’t tried it yet but plan to in the near future – it
would be great if ANTLR would allow a more understandable, maintainable
grammar that would allow Ruby to be able to parse itself.

Thanks, Nick!!

Most welcome! Also, if you’re interested, you may wish to come over to
the
ruby-grammarians list (http://rubyforge.org/mail/?group_id=1129) for
more
conversation.

Cheers,
/Nick

Nick S. wrote:

languages. I haven’t tried it yet but plan to in the near future – it
would be great if ANTLR would allow a more understandable, maintainable
grammar that would allow Ruby to be able to parse itself.

It wasn’t clear from my poking around the web site … is ANTLRWorks
included in ANTLR 3? It looked like a download of ANTLRWorks included
ANTLR 3. I haven’t attempted to get any of the magic up and running yet
– too busy getting my own project started up.

On 10/29/06, M. Edward (Ed) Borasky [email protected] wrote:

It wasn’t clear from my poking around the web site … is ANTLRWorks
included in ANTLR 3? It looked like a download of ANTLRWorks included
ANTLR 3. I haven’t attempted to get any of the magic up and running yet
– too busy getting my own project started up.

No, it’s not, you have to download it separately:

http://www.antlr.org/works/index.html

/Nick

On 10/30/06, Nick S. [email protected] wrote:

What’s interesting with ANTLR 3 is that Ruby is one of the target
languages. I haven’t tried it yet but plan to in the near future – it
would be great if ANTLR would allow a more understandable, maintainable
grammar that would allow Ruby to be able to parse itself.

If you need an example of ANTLR 3 for Ruby in action,
RLisp ( http://zabor.org/taw/rlisp/ ) uses it to parse Lisp.