diff options
author | Camil Staps | 2018-02-07 12:12:41 +0100 |
---|---|---|
committer | Camil Staps | 2018-02-07 12:12:41 +0100 |
commit | b7b2eb59e73260854b1648b6de6475ff1f26ad32 (patch) | |
tree | 66dcf736f6e0f38486ab44c3baa4d5447397bdca /src/SPL/Syntax.hs | |
parent | Rename Parse.hs to Lex.hs, to serpate lexing and parsing (diff) |
Minor changes to Lex and Syntax
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) |