[Haskell-cafe] cost of Text.Parsec.Expr

Johannes Waldmann johannes.waldmann at htwk-leipzig.de
Sat May 2 15:43:40 UTC 2020

Dear Cafe,

I use  `buildExpressionParser`

with a table similar to

and I find it's somewhat expensive. I think the algorithm
makes me pay for each operator that is in the table
even when just a few of them are actually in the input.
(I removed from the table those that don't appear in my test cases,
and it got faster.)

Certainly this is known? What could be done about it?
What does Megaparsec do? It seems that Text.Megaparsec.Expr
vanished from version 6 to version  7.

A classical shift/reduce algorithm would help (?)
but not with the given type of table, which does not allow
to parse an operator just once, and then look up its precedence.

- J.W.

More information about the Haskell-Cafe mailing list