summaryrefslogtreecommitdiff
path: root/ast.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ast.hs')
-rw-r--r--ast.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/ast.hs b/ast.hs
index 480b133..64761bf 100644
--- a/ast.hs
+++ b/ast.hs
@@ -49,6 +49,7 @@ data BinaryOperator
= Plus | Minus | Times | Divide | Modulo
| Equal | Unequal | Greater | Less | GEqual | LEqual
| BoolAnd | BoolOr
+ | Index
deriving (Show, Eq)
data UnaryOperator
@@ -151,6 +152,7 @@ instance PShow BinaryOperator where
pshow LEqual = "<="
pshow BoolAnd = "&&"
pshow BoolOr = "||"
+ pshow Index = "[~]"
instance PShow UnaryOperator where
pshow Negate = "-"
@@ -163,6 +165,8 @@ instance PShow Expression where
pshow (ExLit lit Nothing) = pshow lit
pshow (ExLit lit (Just t)) = concat ["(", pshow lit, " :: ", pshow t, ")"]
pshow (ExCast t ex) = concat ["cast(", pshow t, ")(", pshow ex, ")"]
+ pshow (ExBinOp Index a b Nothing) = concat ["(", pshow a, ")[", pshow b, "]"]
+ pshow (ExBinOp Index a b (Just t)) = concat ["((", pshow a, ")[", pshow b, "] :: ", pshow t, ")"]
pshow (ExBinOp op a b Nothing) = concat ["(", pshow a, " ", pshow op, " ", pshow b, ")"]
pshow (ExBinOp op a b (Just t)) = concat ["(", pshow a, " ", pshow op, " ", pshow b, " :: ", pshow t, ")"]
pshow (ExUnOp op a Nothing) = concat [pshow op, pshow a]