wren ng thornton wrote: > Regexes are powerful and concise for recognizing regular languages. They > are not, however, very good for *parsing* regular languages; nor can > they handle non-regular languages (unless you're relying on the badness > of pcre). In other languages people press regexes into service for > parsing because the alternative is using an external DSL like lex/yacc, > javaCC, etc. Whereas, in Haskell, we have powerful and concise tools for > parsing context-free languages and beyond (e.g., parsec, attoparsec).
This cannot be emphasized heavily enough. Once you have learnt how to use one or more of these parsec libraries they will become your main tool for parsing everything from complex input languages like haskell itself, all the way down to relatively simple config files. Parsec style parsers are built up out of small composable (and more importantly reusable) combinators, that are easier to read and easier to maintain than anything other than the most trivial regex. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe