<div dir="auto">You can cheaply reduce the cost of some of it by combining operators with the same precedence and associativity. For instance, instead of doing as the example says and having separate table entries for "+" and "-", have one entry that parses a "+" or "-" and returns the appropriate operator.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, May 2, 2020, 10:44 Johannes Waldmann <<a href="mailto:johannes.waldmann@htwk-leipzig.de">johannes.waldmann@htwk-leipzig.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Cafe,<br>
<br>
I useĀ  `buildExpressionParser`<br>
<a href="https://hackage.haskell.org/package/parsec-3.1.14.0/docs/Text-Parsec-Expr.html#v:buildExpressionParser" rel="noreferrer noreferrer" target="_blank">https://hackage.haskell.org/package/parsec-3.1.14.0/docs/Text-Parsec-Expr.html#v:buildExpressionParser</a><br>
<br>
with a table similar to<br>
<a href="https://hackage.haskell.org/package/haskell-src-exts-1.23.0/docs/Language-Haskell-Exts-Fixity.html#v:preludeFixities" rel="noreferrer noreferrer" target="_blank">https://hackage.haskell.org/package/haskell-src-exts-1.23.0/docs/Language-Haskell-Exts-Fixity.html#v:preludeFixities</a><br>
<br>
and I find it's somewhat expensive. I think the algorithm<br>
makes me pay for each operator that is in the table<br>
even when just a few of them are actually in the input.<br>
(I removed from the table those that don't appear in my test cases,<br>
and it got faster.)<br>
<br>
Certainly this is known? What could be done about it?<br>
What does Megaparsec do? It seems that Text.Megaparsec.Expr<br>
vanished from version 6 to versionĀ  7.<br>
<br>
A classical shift/reduce algorithm would help (?)<br>
but not with the given type of table, which does not allow<br>
to parse an operator just once, and then look up its precedence.<br>
<br>
- J.W.<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>