instance Read Expr where
readPrec = lift pExpr
where
- pExpr = pVar +++ pLit +++ pBinOp
+ pExpr = (pLit <++ pVar) +++ pBinOp
pBrackets = between (char '(') (char ')')
pVar = Var <$> munch1 isLetter
pBinOp = do
-- TODO: figure out how to just use pExpr without getting
-- stuck recursively
- e1 <- pVar +++ pLit +++ pBrackets pBinOp
+ e1 <- (pLit <++ pVar) +++ pBrackets pBinOp
skipSpaces
op <- pOp
skipSpaces
- e2 <- pVar +++ pLit +++ pBrackets pBinOp
+ e2 <- (pLit <++ pVar) +++ pBrackets pBinOp
return (op e1 e2)
pOp = choice
| Seq Statement Statement
| Try Statement Statement
| Pass
- deriving (Eq, Show)
+ deriving (Eq, Show, Read)