From: why the lucky stiff Date: 2005-02-28T03:50:06+09:00 Subject: Re: Parsers vs. Homemade "Parsing" via REs Randy Kramer wrote: > * If I did create the proper grammar rules, would parsing using something > like YACC be faster than a bunch of RE replacements? > > * Any recommendations for a parser in Ruby? I think there are a couple, > I've been doing some Googling / reading and have come across references to > parse.rb and (iirc) something called Coco (??). I've written probably twenty different parsing libraries -- including six complete revisions of the YAML parser -- and I personally favor writing the parser in C (with Bison and Re2c). I find the two as easy to use as any Ruby equivalents and re2c's lexer lets me control the buffer better -- in case I need to turn a token into multiple events or backtrack. I hope no one is using RedCloth's parser as an example. It's awful. It's like when Ron Popeil injects garlic into a turkey using that freaky flavor syringe and you're like, "Grrrosss, he killed the turkey, polished it up and forced it to be a junkie." RedCloth is all the regexps from textile.php and markdown.pl forced into a hot, enclosed area -- It's a breeding ground for moth and ringworm. I have two evil Bad Luke hands afterwards, which first try to strangle me and, failing that, then go after people on the street with Ron Popeil's patented rib cage shears. _why