EBNF for Ruby?

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

On Sat, Oct 14, 2006 at 12:17:48AM +0900, Sam K. 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.

On 10/13/06, Sam K. [email protected] 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 :slight_smile: [1]
[1] zenspider projects | software projects | by ryan davis

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

On Sun, 2006-10-15 at 09:32 +0900, Tomasz W. 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-heredoc.html

Yours,

tom