diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2020-07-24 21:53:41 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2020-07-24 21:53:41 +0200 |
commit | b5b044ceb4c178a656c0ddc27adec4a719b35893 (patch) | |
tree | 17d8dfbd905b82cd325068a3353a31e999f75cf7 /ast/CC/Source.hs | |
parent | 50fe19860cf143de939671926118ba0cf8c9f35c (diff) |
Support tuples
Diffstat (limited to 'ast/CC/Source.hs')
-rw-r--r-- | ast/CC/Source.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ast/CC/Source.hs b/ast/CC/Source.hs index 080b850..c10f910 100644 --- a/ast/CC/Source.hs +++ b/ast/CC/Source.hs @@ -1,5 +1,7 @@ module CC.Source(module CC.Source, module CC.Types) where +import Data.List + import CC.Pretty import CC.Types @@ -18,11 +20,13 @@ data Def = Function (Maybe Type) data Type = TFun Type Type | TInt + | TTup [Type] deriving (Show, Read) data Expr = Lam SourceRange [(Name, SourceRange)] Expr | Call SourceRange Expr Expr | Int SourceRange Int + | Tup SourceRange [Expr] | Var SourceRange Name | Annot SourceRange Expr Type deriving (Show, Read) @@ -31,10 +35,13 @@ instance Pretty Type where prettyPrec _ TInt = "Int" prettyPrec p (TFun a b) = precParens p 2 (prettyPrec 3 a ++ " -> " ++ prettyPrec 2 b) + prettyPrec _ (TTup ts) = + "(" ++ intercalate ", " (map pretty ts) ++ ")" instance HasRange Expr where range (Lam sr _ _) = sr range (Call sr _ _) = sr range (Int sr _) = sr + range (Tup sr _) = sr range (Var sr _) = sr range (Annot sr _ _) = sr |