[clean-list] questions
Jenda Krynicky
Jenda@Krynicky.cz
Thu, 20 Nov 2003 17:26:36 +0100
From: fzuurbie@inter.nl.net
> > There's nothing better than regexps for string handling
>
> Until you found out about combinator parsing (type this in in Google
> or CiteSeer). I have a library based on Koopman's and Rojemo's work
> (continuation passing style), extended with elaborated error messages.
If you need to PARSE a more complex expression than definitely the
combinator parsing or some other kind of parser is in order. If you
just want to extract something from a string or test whether it
conforms to some not-too-complex format, then parsers (whether
combinator based or any other) are overkill.
If e.g. I want to make sure that the stuff entered by the user is a
date in YYYY-MM-DD format I definitely do not want to spend twenty
cryptic lines writing a parser where
/^(\d{4})-(\d{1,2})-(\d{1,2})$/
suffices. (I know you need to make sure the month is between 1 and 12
and the day is reasonable, but you'd do that outside the parser as
well.)
For certain type of tasks there is not anything better than regexs.
For other tasks you need a parser. We should not ignore hacks just
because by chainsaw you can cut down a tree quicker. Sometimes all
you need is to chop a few logs.
Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery