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)
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 =
| Div
deriving (Eq,Ord,Show)
-data Type =
- TInt
- | TBool
- | NoType
- deriving (Eq,Ord,Show)
-