X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=Abssyntax.hs;h=881c1723bcc4fa5021eb17ef6d9503edfc6ffd3c;hp=7c95d5324e1a58ef1a8f32b099d16fb0babcac42;hb=HEAD;hpb=b33c4977fff6bad375551eaf4fed0aa06daf1c88 diff --git a/Abssyntax.hs b/Abssyntax.hs index 7c95d53..881c172 100644 --- a/Abssyntax.hs +++ b/Abssyntax.hs @@ -4,54 +4,64 @@ 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) data Exp = - BExp Exp BOp Exp + EAss Ident Exp | EVar Ident - | EAss Ident Exp | EInt Integer - | ENeg Exp | EBool Bool + | ENeg Exp + | ENot Exp | EReadI | EReadB - | ExpT Type Exp - | EDefault - | OpExp Exp Op Exp + | 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 BOp = +data Op = Lt | ELt | Gt | EGt | Eq | NEq - deriving (Eq,Ord,Show) - -data Op = - Plus + | Plus | Minus | Times | Div deriving (Eq,Ord,Show) -data Type = - TInt - | TBool - | NoType - deriving (Eq,Ord,Show) -