diff options
Diffstat (limited to 'src/SPL/Syntax.hs')
-rw-r--r-- | src/SPL/Syntax.hs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/SPL/Syntax.hs b/src/SPL/Syntax.hs index 4b0f670..d274803 100644 --- a/src/SPL/Syntax.hs +++ b/src/SPL/Syntax.hs @@ -8,20 +8,32 @@ data Program = Program { funs :: [Function] , vars :: [Variable] } + deriving (Show) data Function = Function { fname :: Name - , ftype :: Type + , ftype :: Maybe Type + , fargs :: [Name] + , fvars :: [Variable] , fcode :: Statement } + deriving (Show) data Variable = Variable { vname :: Name - , vtype :: Type + , vtype :: Maybe Type + , vval :: Expression } + deriving (Show) data Type - = Type -- TODO + = TInt + | TBool + | TChar + | TList Type + | TTuple Type Type + | TArrow [Type] Type + deriving (Show) data Statement = If Expression Statement (Maybe Statement) @@ -30,6 +42,7 @@ data Statement | Eval Expression | Return (Maybe Expression) | Seq Statement Statement + deriving (Show) data Expression = Field Name Field @@ -38,12 +51,14 @@ data Expression | Literal Literal | FunCall Name [Expression] | Tuple Expression Expression + deriving (Show) data Field = Hd | Tl | Fst | Snd + deriving (Show) data Op2 = Add @@ -60,13 +75,16 @@ data Op2 | And | Or | Cons + deriving (Show) data Op1 = Not | Neg + deriving (Show) data Literal = LInt Int | LChar Char | LBool Bool | LNil + deriving (Show) |