aboutsummaryrefslogblamecommitdiff
path: root/src/Syntax.hs
blob: 18949d27cb7132965745b21c80913a67275b7e27 (plain) (tree)
1
2
3
4
5
6
7
8
9




                  

                            

                            
                            



                                 
                                 



                          
                                                                         
                           
                          






                             
                              
                         
                                          
                                                                             

                            
                                                                                                                               
                            


                                  


                                             
module Syntax
  where

type Idnt = String
data Typ = TInt
         | TRecord  TypeDict
         | TVariant TypeDict
         | TPtr Typ
           deriving(Eq,Show)
type TypeDict = [(Idnt,Typ)]

data Expr = Var Idnt
          | IntLit Int
          | Record [(Idnt, Expr)]
          | Variant Typ Idnt Expr
          | Add Expr Expr
          | Mult Expr Expr
          | Neg Expr
          | Deref Expr
          | Match Expr [(Idnt, Idnt, Expr)] -- Variant,Binder, Expression
          | Proj Idnt Expr 
          | Annot Expr Typ
           deriving(Eq,Show)
data Com = Skip
         | Seq Com Com
         | If Expr Com Com
         | While Expr Com
         | Asgn Idnt Expr
         | Decl Idnt Expr Com
         | Alloc Idnt Expr Com
         | Save Idnt Expr
         | SMatch Expr [(Idnt, Idnt, Com)]
         | FunctionCall Idnt Idnt [Expr] -- variable function_name parameters
           deriving(Eq,Show)
         
data FuncDecl = Func Idnt [(Idnt, Typ)] [(Idnt,Expr)] Com Expr -- function_name [parameters]  [local variables] body return_val
           deriving(Eq,Show)
data FuncSign = FuncSign [Typ] Typ
                deriving(Eq,Show)
type FuncEnv = [(Idnt,FuncSign)]
data Program = P [FuncDecl] [(Idnt, Int)] Com
           deriving(Eq,Show)