[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

EBNF for Ruby?

Sam Kong

10/13/2006 3:18:00 PM

Hi,

I heard from somebody that Ruby cannot be completely expressed in EBNF.
And he also said that there are some ad hoc cases.
Is it true?

Sam

--
Posted via http://www.ruby-....

3 Answers

Logan Capaldo

10/14/2006 6:50:00 PM

0

On Sat, Oct 14, 2006 at 12:17:48AM +0900, Sam Kong wrote:
> Hi,
>
> I heard from somebody that Ruby cannot be completely expressed in EBNF.
> And he also said that there are some ad hoc cases.
> Is it true?
Check out parse.y (the yacc grammar for ruby) and see for yourself.
However, yes there are ad-hoc cases, mostly invovlving parentheses that
probably can not be expressed as a CFG.
>
> Sam
>
> --
> Posted via http://www.ruby-....

Tomasz Wegrzanowski

10/15/2006 12:32:00 AM

0

On 10/13/06, Sam Kong <sam.s.kong@gmail.com> wrote:
> Hi,
>
> I heard from somebody that Ruby cannot be completely expressed in EBNF.
> And he also said that there are some ad hoc cases.
> Is it true?

If you want to parse Ruby, your best bet is probably ParseTree :-) [1]
[1] http://www.zenspider.com/ZSS/Products/...

Examples of difficult cases:
foo { } # calls foo with empty hash or with empty block ?

foo + # Newlines are ignored when the expression is "not complete"
bar

--
Tomasz Wegrzanowski [ http://t-a-w.blo... ]

Tom Copeland

10/15/2006 2:28:00 AM

0

On Sun, 2006-10-15 at 09:32 +0900, Tomasz Wegrzanowski wrote:
> Examples of difficult cases:
> foo { } # calls foo with empty hash or with empty block ?
>
> foo + # Newlines are ignored when the expression is "not complete"
> bar

There are also some interesting notes on lexing Ruby in Xue Yong Zhi's
blog:

http://seclib.blogspot.com/2005/11/more-on-leftshift-and-he...

Yours,

tom