]> ruin.nu Git - proglang.git/blobdiff - Abssyntax.hs
minor change
[proglang.git] / Abssyntax.hs
index d8ef904d06766fd3ccab71ee41d1ed9e9ceb319b..881c1723bcc4fa5021eb17ef6d9503edfc6ffd3c 100644 (file)
@@ -4,13 +4,24 @@ module Abssyntax where
 
 newtype Ident = Ident String deriving (Eq,Ord,Show)
 
+data Type =
+   TInt
+ | TBool
+  deriving (Eq,Ord,Show)
+
+data Program =
+   Program [FuncStm]
+  deriving (Eq,Ord,Show)
+
 data Stm =
-   SDecl Type Ident Exp
- | SExp Exp
+   SExp Exp
  | SBlock [Stm]
- | SIf Exp Stm Stm
+ | SDecl Type Ident Exp
+ | SDeclD Type Ident
  | SWhile Exp Stm
+ | SIf Exp Stm Stm
  | SPrint Exp
+ | SReturn Exp
  | SNoop
   deriving (Eq,Ord,Show)
 
@@ -18,19 +29,27 @@ data Exp =
    EAss Ident Exp
  | EVar Ident
  | EInt Integer
+ | EBool Bool
  | ENeg Exp
  | ENot Exp
- | EBool Bool
  | EReadI
  | EReadB
- | ExpT Type Exp
- | EDefault
+ | EFunc Ident [Exp]
  | BiOpExp Exp Op Exp
  | EPost Ident Op
   deriving (Eq,Ord,Show)
 
-data Stms =
-   Program [Stm]
+data Decl =
+   Decl Type Ident
+  deriving (Eq,Ord,Show)
+
+data Func =
+   Func Type Ident [Decl] [Stm]
+  deriving (Eq,Ord,Show)
+
+data FuncStm =
+   S Stm
+ | F Func
   deriving (Eq,Ord,Show)
 
 data Op =
@@ -46,9 +65,3 @@ data Op =
  | Div
   deriving (Eq,Ord,Show)
 
-data Type =
-   TInt
- | TBool
- | NoType
-  deriving (Eq,Ord,Show)
-