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

···

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

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

Sam

--
Posted via http://www.ruby-forum.com/\.

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 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?

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

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

···

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