X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Abssyntax.hs;h=881c1723bcc4fa5021eb17ef6d9503edfc6ffd3c;hb=41bc48c79195f018687fef2ba64e4c87bb7a206b;hp=4cc8d19eb8e0dea898b8239177d6c32e73e7fee9;hpb=6103c0359b95557566aa9154efa5bcd4d9c996f6;p=proglang.git diff --git a/Abssyntax.hs b/Abssyntax.hs index 4cc8d19..881c172 100644 --- a/Abssyntax.hs +++ b/Abssyntax.hs @@ -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,18 +29,27 @@ data Exp = EAss Ident Exp | EVar Ident | EInt Integer - | ENeg Exp | EBool Bool + | ENeg Exp + | ENot Exp | 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 = @@ -45,9 +65,3 @@ data Op = | Div deriving (Eq,Ord,Show) -data Type = - TInt - | TBool - | NoType - deriving (Eq,Ord,Show) -