Ruby lexer/parser package?


#1

a quick question: is there a lex/yacc package for ruby ? or actually
anything to implement a lexer/parser in ruby ?
for some reason I can’t seem to find anything like that out there…

thanks for your help.

-Didier


#2

Hi Didier,

Check out Racc. It comes with ruby in the standard library.

Cheers,
Dave


#3

On Nov 19, 2005, at 10:37 PM, David B. wrote:

Hi Didier,

Check out Racc. It comes with ruby in the standard library.

Tiny clarification, the Racc runtime is a standard library.

James Edward G. II


#4

David, James, Eric,

Thanks a lot guys.
Now, I didn’t see any obvious lexer package out there, but maybe I need
to spend more time looking at the examples.

-Didier


#5

On 11/19/05, removed_email_address@domain.invalid removed_email_address@domain.invalid
wrote:

a quick question: is there a lex/yacc package for ruby ? or actually
anything to implement a lexer/parser in ruby ?
for some reason I can’t seem to find anything like that out there…

Here are the general parser (and sometimes lexer) packages I found on
raa and rubyforge:

LR parsers:
http://raa.ruby-lang.org/project/racc/ (run-time extension in ruby 1.8)
http://raa.ruby-lang.org/project/rockit/ (doesn’t work on 1.8?)

LL parsers:
http://raa.ruby-lang.org/project/coco-rb/
http://rubyforge.org/projects/tdp4r/
http://rubyforge.org/projects/coco-ruby/
http://rubyforge.org/projects/grammar/

Of course I’m biased toward my package (grammar) and think it is the
best out there. You should take a look at all these if you are
interested in the topic.


#6

On 11/20/05, removed_email_address@domain.invalid removed_email_address@domain.invalid
wrote:

David, James, Eric,

Thanks a lot guys.
Now, I didn’t see any obvious lexer package out there, but maybe I need
to spend more time looking at the examples.

-Didier

For mine, a lexer and parser are made identically - one parses
characters and the other tokens. On one extreme, you can make a
lexer-free parser and on the other you could make multi-level (more
than just lexer/parser) language transformer/compiler.