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