about summary refs log tree commit diff
path: root/src/Syntax.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Syntax.hs')
-rw-r--r--src/Syntax.hs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Syntax.hs b/src/Syntax.hs
new file mode 100644
index 0000000..1c888b5
--- /dev/null
+++ b/src/Syntax.hs
@@ -0,0 +1,34 @@
+module Syntax
+  where
+
+type Idnt = String
+data Typ = TInt
+         | TRecord  [(Idnt, Typ)]
+         | TVariant [(Idnt, Typ)]
+         | TPtr Typ
+           deriving(Eq,Show)
+
+data Expr = Var Idnt
+          | IntLit Int
+          | Record [(Idnt, Expr)]
+          | Variant Typ [(Idnt, Expr)]
+          | Add Expr Expr
+          | Mult Expr Expr
+          | Neg Expr
+          | Deref 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
+         | Save Idnt Expr
+           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)
+