From: Luke Kanies Date: 2006-11-17T05:18:22+09:00 Subject: Re: rex & racc vs. ruby-lex & ruby-yacc On Nov 7, 2006, at 4:32 AM, Ryan Hanks wrote: > 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? 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 -- Luke Kanies http://madstop.com | http://reductivelabs.com | 615-594-8199