Rex & racc vs. ruby-lex & ruby-yacc

Hi,

I’m new to lex and yacc and trying to use one of their ruby derivatives
to
build a parser for level 2 cascading style-sheets (CSS2). I’m having
trouble deciding whether to use rex & racc or ruby-lex & ruby-yacc. Can
someone help me out by explaining to me the ramifications of choosing
between these two? Does anyone have a particular preference for one
over
the other?

Thanks,
Ryan H.

p.s. it’s my understanding that ruby-* requires flex and yacc, while
rex
and racc are pure ruby (please correct me if I’m wrong). That being
said,
I’m mostly interested in functionality and ease-of-implementation
differences between the two pairs of packages…

p.p.s. as I said, I’m looking to build a parser for CSS2. might there
be an
entirely different parser generator for ruby that I should be looking to
use
given the nature of the grammar (
http://www.w3.org/TR/1998/REC-CSS2-19980512/grammar.html) I’m looking to
parse (such as tdp4r http://rubyforge.org/projects/tdp4r/)?

Thanks again.

On 11/7/06, Ryan H. [email protected] wrote:

between these two? Does anyone have a particular preference for one over
the other?

Thanks,
Ryan H.

Maybe Antlr and/or ragel could be useful, though I don;t know anything
about them except that:

Ragel is used to create http parser in mongrel, Antlr was mentioned
here sometime ago. Unfortunately I don’t remember the topic - try
searching if it interests you.

On Nov 7, 2006, at 4:32 AM, Ryan H. wrote:

the other?
I made my decision a long time ago (at least 3+ years), and I don’t
remember my exact reasoning. However, I do have two racc parsers
available for your perusal if you’re interested, and one of them is
pretty complicated.

I’ve got a simple Nagios parser in my project named naginator[1], and
a pretty complicated one in Puppet[2]. For Puppet, I used StrScan to
make a lexer, which has so far worked pretty well; for Nagios, I just
wrote a moderately crappy token() method that did the lexing for me.

I know this doesn’t help you specifically decide between any of them,
but at least it’s some code you can look at, which is more than I had
when I made my decision (I wrote Naginator about 2 years before I
wrote Puppet’s parser, and when I went to write Puppet’s parser,
Naginator’s was the only example I could find).

I’d be glad to answer any follow-on questions about them.

I did look at Antlr and Rockit or whatever they’re called, but again,
I don’t remember why I chose against them. I’m sure it was at least
partially because I was already pretty familiar with Lex/Yacc-style
grammars.

1 - http://reductivelabs.com/cgi-bin/naginator.cgi/browser/trunk/lib/
nagios/grammar.ry
2 - http://reductivelabs.com/cgi-bin/puppet.cgi/browser/trunk/lib/
puppet/parser/grammar.ra

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs