X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=Abssyntax.hs;h=881c1723bcc4fa5021eb17ef6d9503edfc6ffd3c;hp=d8ef904d06766fd3ccab71ee41d1ed9e9ceb319b;hb=HEAD;hpb=9d0e3c89b286456549c68a816d0729f193498f6a diff --git a/Abssyntax.hs b/Abssyntax.hs index d8ef904..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,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) -