-- vim: et ts=2 sw=2 ai: module SPL.Syntax where type Name = String data Program = Program { funs :: [Function] , vars :: [Variable] } deriving (Show) data Function = Function { fname :: Name , ftype :: Maybe Type , fargs :: [Name] , fvars :: [Variable] , fcode :: Statement } deriving (Show) data Variable = Variable { vname :: Name , vtype :: Maybe Type , vval :: Expression } deriving (Show) data Type = TInt | TBool | TChar | TList Type | TTuple Type Type | TArrow [Type] Type deriving (Show) data Statement = If Expression Statement (Maybe Statement) | While Expression Statement | Assign Name Expression | Eval Expression | Return (Maybe Expression) | Seq Statement Statement | Nop deriving (Show) data Expression = Field Name Field | Op2 Expression Op2 Expression | Op1 Op1 Expression | Literal Literal | FunCall Name [Expression] | Tuple Expression Expression deriving (Show) data Field = Hd | Tl | Fst | Snd deriving (Show) data Op2 = Add | Sub | Mul | Div | Mod | Eq | Lt | Gt | Le | Ge | Ne | And | Or | Cons deriving (Show) data Op1 = Not | Neg deriving (Show) data Literal = LInt Int | LChar Char | LBool Bool | LNil deriving (Show)