[Haskell-cafe] Frisby grammars that have context
Mark T.B. Carroll
Mark.Carroll at Aetion.com
Tue May 29 10:18:09 EDT 2007
I've been playing with Text.Parsers.Frisby to see how it stacks against
other options and, while it's been great so far, I am finding that I
can't encode a grammar where what's acceptable depends on what's already
been parsed in some nontrivial way. To take a simple example, imagine a
grammar where the only lower-case letters that are acceptable are those
where their upper-case equivalent occurred earlier in the text.
In Parsec I'd code this sort of thing as,
nextChar =
do allowed <- getState
char <- oneOf $ ['A'..'Z'] ++ allowed
updateState (union [toLower char])
return char
test = runParser (many1 nextChar) [] ""
Is this supposed to not be possible in Frisby, or (quite likely) am I
missing something that allows me to? I've thought about things like
trying to fmap further calls to apply runPeg to rest, but I've not
figured out a trick that will actually work.
-- Mark
More information about the Haskell-Cafe
mailing list