[Haskell-cafe] Parsing, infixes and on-the-fly precedence
lambda.fairy at gmail.com
Mon Sep 28 07:58:50 UTC 2015
On Mon, Sep 28, 2015 at 8:28 PM, Jeffrey Brown <jeffbrown.the at gmail.com> wrote:
> I imagine a parser that operates on (String,[String]) pairs, for which the
> second element allows the user to define precedence on the fly.
> For instance, it would read the pair
> (x,y) = ("a , b : c", [":" , ","])
> "(a , (b : c))"
> because y informs the parser that in x the colon binds first, then the
> I know it is possible, because Haskell does it already! In Haskell we can
> define novel infix operators on the fly, including their precedence relative
> to each other.
> I don't know how, though, so that's my question.
You might like to look at Text.Parsec.Token, which does exactly
what you describe.
> Jeffrey Benjamin Brown
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Chris Wong (https://lambda.xyz)
"I fear that Haskell is doomed to succeed."
-- Tony Hoare
More information about the Haskell-Cafe