projects
/
timetravel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Project-ify
[timetravel.git]
/
AST.hs
diff --git
a/AST.hs
b/AST.hs
index cf1fc409c70e16b5754a9f4d1d2274ca51e8f92f..4aac7689685a883b0be2db62f32a9163423fedad 100644
(file)
--- a/
AST.hs
+++ b/
AST.hs
@@
-40,7
+40,7
@@
instance Show Expr where
instance Read Expr where
readPrec = lift pExpr
where
instance Read Expr where
readPrec = lift pExpr
where
- pExpr =
pVar +++ pLit
+++ pBinOp
+ pExpr =
(pLit <++ pVar)
+++ pBinOp
pBrackets = between (char '(') (char ')')
pVar = Var <$> munch1 isLetter
pBrackets = between (char '(') (char ')')
pVar = Var <$> munch1 isLetter
@@
-50,11
+50,11
@@
instance Read Expr where
pBinOp = do
-- TODO: figure out how to just use pExpr without getting
-- stuck recursively
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
skipSpaces
op <- pOp
skipSpaces
- e2 <-
pVar +++ pLit
+++ pBrackets pBinOp
+ e2 <-
(pLit <++ pVar)
+++ pBrackets pBinOp
return (op e1 e2)
pOp = choice
return (op e1 e2)
pOp = choice
@@
-80,5
+80,5
@@
data Statement = Assign String Expr
| Seq Statement Statement
| Try Statement Statement
| Pass
| Seq Statement Statement
| Try Statement Statement
| Pass
- deriving (Eq, Show)
+ deriving (Eq, Show
, Read
)