From: "Rob ." Date: 2005-03-01T00:13:15+09:00 Subject: Re: Parsers vs. Homemade "Parsing" via REs My implementation of an "auto-indent and insert end" feature in a jEdit Ruby Plugin[1] uses regular expressions to determine if an end is required. I also use regex's to identify classes and methods for a "file structure popup" feature. In my experience it was easy to implement with regex's early on, but the maintanance and enhancement has proved troublesome as I've come across more obscure syntax situations. I'm now investigating using a version of JRuby[2] that has been modified by the Eclipse Ruby Development Tool[2] team. Rob [1]http://community.jedit.org/cgi-bin/TWiki/view/Main/RubyPlugin [2]http://jruby.sourceforge.net/ [3]http://rubyeclipse.sourceforge.net/ On Sun, 27 Feb 2005 23:54:02 +0900, Randy Kramer wrote: > I have the need to translate several megabytes of TWiki marked up text to > HTML. In fact, it may not even be a one time thing--I'm planning to build a > wiki like thing, and will probably keep TWiki markup as the native language > for storage. Over time, I may extend the TWiki markup syntax. > > (Aside: I'm aware that Ruby has two other markup languages sometimes used for > wikis (Red Cloth (?) and Text ?)--I may someday support those as > well, but I'm not immediately interested in converting the megabytes of data > I have and learning a different markup language.) > > My impression is that some or many wikis (this is my impression of TWiki) > don't use a "real parser" (like YACC or whatever), but instead simply search > and replace in the text using (many) Regular Expressions. Conceptually, that > seems an easy approach (less learning on my part, but probably tedious > creation of many REs (or borrowing from TWiki's Perl). > > I've never used a parser, and am not really that familiar with them, but I'm > wondering what the tradeoffs might be. I've heard that a parser may be > easier to modify to extend the syntax. (But, I have a feeling that the TWiki > markup language might not be "regular" enough to be parsed by something like > YACC.): > > * 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 (??). > > * Anybody know the approach followed by existing Ruby wikis like Instiki, > Ruwiki, etc.? > > Other comments, hints, suggestions? > > Randy Kramer > >