
On Tue, 21 Oct 2003 13:47:51 +0100
Graham Klyne
At 04:17 21/10/03 -0400, ajb@spamcop.net wrote:
I think I might have mentioned this previously, but here's an interesting implementation of Knuth-Morris-Pratt substring searching (which is indeed a "little language") which illustrates something or other:
Nice. Do you know if anyone has done anything like this for regular expressions? I'm thinking in particular that a function that turned a regular expression into a Parsec parser function could be useful, as in:
regexp.compile :: String -> GenParser Char st [String]
where GenParser is defined by the Parsec library [1], and the parsed result is a list of substrings corresponding to the (...) parts of the regexp (if matched, of course). (The parser result type might warrant some refinement.)
This page is full of strange and wonderful things, http://www.haskell.org/libraries/ How 'bout the Haskell Dynamic Lexer Engine http://www.nondot.org/sabre/Projects/HaskellLexer/ It doesn't create a Parsec parser, but it would be very easy to make a function with it that did.