about summary refs log tree commit diff
path: root/src/Syntax.hs
blob: f5d9c2df959d095cc054e9263ef4c1d536252197 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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 
           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)]
           deriving(Eq,Show)
         
data FuncDecl = Func Idnt [Idnt] [(Idnt,Expr)] Com Expr
           deriving(Eq,Show)
data Program = P [FuncDecl] [(Idnt, Int)] Com
           deriving(Eq,Show)