[Baypiggies] More dramatic material?

K. Richard Pixley rich at noir.com
Wed Feb 24 18:13:45 CET 2010


I concur with Aahz's reasons for using regular expressions.  I also 
concur that they tend to be write only.

However, witty quote aside, I don't agree about them being distinct from 
a "full-blown parser" - more like "full-blown parser lite".

I did some work in ICON, 
(http://en.wikipedia.org/wiki/Icon_(programming_language)), for a while, 
which is a fascinating language.  It includes goal oriented expressions, 
which have a feel much like functional programming languages like ML, 
PROLOG, or Mercury; innate string handling like it's predecessor, 
snobol, (both are by Ralph Griswold); and generators, which are built 
almost identically to python's 'yield' statement and essentially create 
closures, a la CLU.  All this over 30 years ago in 1977.

In any case, the goal oriented expressions combined with string handling 
functions of ICON are a lot like writing regular expressions, with side 
effects.  And the side effects tend to Do The Right Thing, which is more 
direct and more useful than the repeating terminology of regular 
expressions.  From my perspective, the biggest reason to use regular 
expressions is when you need to pull out the matched portion in order to 
further process it, (as Aahz mentioned, and hence my repeating 
examples).  But IMO, this /is/ a form of parser generation, although 
I'll admit that it's extremely dense code that tends to be unfamiliar to 
most programmers.  (But, then, it's possible to write some /very/ dense 
code in python too).

I keep looking for an opportunity to learn ANTLR, 
(http://www.antlr.org), which is capable of generating parsers in 
python, but the majority of problems I run into can be solved with a 
"reduction in strength" of the tools involved.  I can't imagine that the 
learning curve for antlr is much less than the learning curve for 
regular expressions.

I haven't even read through the regular expression library in python and 
frankly, I probably never will.  If it comes to that, I'll probably use 
other tools.  I /do/ use regular expressions in sed fairly regularly.

--rich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20100224/46397c22/attachment.html>


More information about the Baypiggies mailing list