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

**URL:** <https://www.ruby-forum.com/t/interesting-and-useful-exercise-with-the-ruby-grammar-by-n/74073>\
**Category:** Ruby\
**Created:** [October 29, 2006, 7:23pm UTC](https://www.ruby-forum.com/t/interesting-and-useful-exercise-with-the-ruby-grammar-by-n/74073 "2006-10-29T19:23:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/u/MSEdward_SEdS_Bora)\
**Post date:** [October 29, 2006, 7:23pm UTC](https://www.ruby-forum.com/t/interesting-and-useful-exercise-with-the-ruby-grammar-by-n/74073/1 "2006-10-29T19:23:32Z")

</div>

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. 🙂

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

Thanks, Nick!!

---

<div class="post-metadata">

**Author:** ![MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/u/MSEdward_SEdS_Bora)\
**Post date:** [November 7, 2006, 10:44am UTC](https://www.ruby-forum.com/t/interesting-and-useful-exercise-with-the-ruby-grammar-by-n/74073/2 "2006-11-07T10:44:22Z")

</div>

On 10/29/06, M. Edward (Ed) Borasky [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://rubyforge.org/mail/?group_id=1129)) for  
more  
conversation.

Cheers,  
/Nick

---

<div class="post-metadata">

**Author:** ![MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/u/MSEdward_SEdS_Bora)\
**Post date:** [November 7, 2006, 10:44am UTC](https://www.ruby-forum.com/t/interesting-and-useful-exercise-with-the-ruby-grammar-by-n/74073/3 "2006-11-07T10:44:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/u/MSEdward_SEdS_Bora)\
**Post date:** [November 7, 2006, 10:45am UTC](https://www.ruby-forum.com/t/interesting-and-useful-exercise-with-the-ruby-grammar-by-n/74073/4 "2006-11-07T10:45:37Z")

</div>

On 10/29/06, M. Edward (Ed) Borasky [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://www.antlr.org/works/index.html)

/Nick

---

<div class="post-metadata">

**Author:** ![MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@MSEdward\_SEdS\_Bora](https://www.ruby-forum.com/u/MSEdward_SEdS_Bora)\
**Post date:** [November 7, 2006, 10:59am UTC](https://www.ruby-forum.com/t/interesting-and-useful-exercise-with-the-ruby-grammar-by-n/74073/5 "2006-11-07T10:59:02Z")

</div>

On 10/30/06, Nick S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/](http://zabor.org/taw/rlisp/) ) uses it to parse Lisp.
