[Haskell-cafe] Ternary infix expression parser

Jeffrey Brown jeffbrown.the at gmail.com
Sat Aug 19 03:56:49 UTC 2017


I want to write a parser that lets someone write "(a #uses b) #because (c
#needs d)" and read it into a tree:

  data Tree = Tree String Tree Tree | Leaf String
  magic "(a #uses b) #because (c #needs d)"
    = Tree "because" (Tree "uses" (Leaf "a") (Leaf "b"))
                     (Tree "needs" (Leaf "c") (Leaf "d"))

I thought I could use Text.Megaparsec.Expr for it, but now I realize it
hadnles binary operations, and this is a ternary one.

Suggestions?


-- 
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/>   |   Facebook
<https://www.facebook.com/mejeff.younotjeff>   |   LinkedIn
<https://www.linkedin.com/in/jeffreybenjaminbrown>(spammy, so I often miss
messages here)   |   Github <https://github.com/jeffreybenjaminbrown>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170818/bebc6448/attachment.html>


More information about the Haskell-Cafe mailing list