The link above is an introduction to combinator parsers; there's also a broader introduction.
If you're used to yacc-like parser generators then these seem rather quaint at first - the idea is to build functions from the bottom up, with basic functions identifying tokens (say), and more complex functions constructing a parse tree. A good combinator parser framework separates this into elegant functional chunks with higher order functions to "compose" sub-functions and a neat separation between syntax and semantics (the <@ operator in the main link). Broadly, it's the same approach shown in many posts here (most recently the Prolog regexps).
This implementation (using streams rather than monads) looks pretty good and more are listed here.
Finally, an interesting extrapolation.
(Apologies to those that have seen some of these links on c.l.misc and a discussion post I made here recently).
Posted to "" by andrew cooke on 1/24/01; 12:52:30 AM
|