-- Haskel data types for the abstract syntax. -- Generated by the BNF converter. {-# LANGUAGE GeneralizedNewtypeDeriving #-} -- | The abstract syntax of language Cpp. module AbsCpp where import qualified Prelude as T (Double, Integer, String) import qualified Prelude as C (Eq, Ord, Show, Read) import Data.String data Program = PDefs [Def] -- ^ Program ::= Def deriving (C.Eq, C.Ord, C.Show, C.Read) data Def = DFun Type Id [Arg] [Stm] -- ^ Def ::= Type Id "(" Arg ")" "{" Stm "}" deriving (C.Eq, C.Ord, C.Show, C.Read) data Arg = ADecl Type Id -- ^ Arg ::= Type Id deriving (C.Eq, C.Ord, C.Show, C.Read) data Stm = SBlock [Stm] -- ^ Stm ::= "{" Stm "}" | SDecls Type [Id] -- ^ Stm ::= Type Id ";" | SExp Exp -- ^ Stm ::= Exp ";" | SIfElse Exp Stm Stm -- ^ Stm ::= "if" "(" Exp ")" Stm "else" Stm | SInit Type Id Exp -- ^ Stm ::= Type Id "=" Exp ";" | SReturn Exp -- ^ Stm ::= "return" Exp ";" | SReturnVoid -- ^ Stm ::= "return" ";" | SWhile Exp Stm -- ^ Stm ::= "while" "(" Exp ")" Stm deriving (C.Eq, C.Ord, C.Show, C.Read) data Exp = EAnd Exp Exp -- ^ Exp ::= Exp4 "&&" Exp5 | EApp Id [Exp] -- ^ Exp ::= Id "(" Exp ")" | EAss Exp Exp -- ^ Exp ::= Exp3 "=" Exp2 | EDecr Exp -- ^ Exp ::= "--" Exp14 | EDiv Exp Exp -- ^ Exp ::= Exp12 "/" Exp13 | EDouble T.Double -- ^ Exp ::= Double | EEq Exp Exp -- ^ Exp ::= Exp8 "==" Exp9 | EFalse -- ^ Exp ::= "false" | EGt Exp Exp -- ^ Exp ::= Exp9 ">" Exp10 | EGtEq Exp Exp -- ^ Exp ::= Exp9 ">=" Exp10 | EId Id -- ^ Exp ::= Id | EIncr Exp -- ^ Exp ::= "++" Exp14 | EInt T.Integer -- ^ Exp ::= Integer | ELt Exp Exp -- ^ Exp ::= Exp9 "<" Exp10 | ELtEq Exp Exp -- ^ Exp ::= Exp9 "<=" Exp10 | EMinus Exp Exp -- ^ Exp ::= Exp11 "-" Exp12 | ENEq Exp Exp -- ^ Exp ::= Exp8 "!=" Exp9 | EOr Exp Exp -- ^ Exp ::= Exp3 "||" Exp4 | EPDecr Exp -- ^ Exp ::= Exp15 "--" | EPIncr Exp -- ^ Exp ::= Exp15 "++" | EPlus Exp Exp -- ^ Exp ::= Exp11 "+" Exp12 | EString T.String -- ^ Exp ::= String | ETimes Exp Exp -- ^ Exp ::= Exp12 "*" Exp13 | ETrue -- ^ Exp ::= "true" | ETyped Exp Type -- ^ Exp ::= "(" Exp ":" Type ")" deriving (C.Eq, C.Ord, C.Show, C.Read) data Type = Type_bool -- ^ Type ::= "bool" | Type_double -- ^ Type ::= "double" | Type_int -- ^ Type ::= "int" | Type_string -- ^ Type ::= "string" | Type_void -- ^ Type ::= "void" deriving (C.Eq, C.Ord, C.Show, C.Read) newtype Id = Id T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString)