I’m new to lex and yacc and trying to use one of their ruby derivatives
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
p.s. it’s my understanding that ruby-* requires flex and yacc, while
and racc are pure ruby (please correct me if I’m wrong). That being
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
entirely different parser generator for ruby that I should be looking to
given the nature of the grammar (
Appendix D: The grammar of CSS2) I’m looking to
parse (such as tdp4r http://rubyforge.org/projects/tdp4r/)?
On 11/7/06, Ryan H. [email protected] wrote:
between these two? Does anyone have a particular preference for one over
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:
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
I’ve got a simple Nagios parser in my project named naginator, and
a pretty complicated one in Puppet. 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
1 - http://reductivelabs.com/cgi-bin/naginator.cgi/browser/trunk/lib/
2 - http://reductivelabs.com/cgi-bin/puppet.cgi/browser/trunk/lib/