module Transformations.Anf.Anf where

import Data.Int (Int64)
import Trees.Common

newtype Program = Program [GlobalDeclaration]
  deriving (Int -> Program -> ShowS
[Program] -> ShowS
Program -> String
(Int -> Program -> ShowS)
-> (Program -> String) -> ([Program] -> ShowS) -> Show Program
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Program -> ShowS
showsPrec :: Int -> Program -> ShowS
$cshow :: Program -> String
show :: Program -> String
$cshowList :: [Program] -> ShowS
showList :: [Program] -> ShowS
Show, Program -> Program -> Bool
(Program -> Program -> Bool)
-> (Program -> Program -> Bool) -> Eq Program
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Program -> Program -> Bool
== :: Program -> Program -> Bool
$c/= :: Program -> Program -> Bool
/= :: Program -> Program -> Bool
Eq)

data GlobalDeclaration
  = GlobVarDecl Identifier' Expression
  | GlobFunDecl Identifier' [Identifier'] Expression
  deriving (Int -> GlobalDeclaration -> ShowS
[GlobalDeclaration] -> ShowS
GlobalDeclaration -> String
(Int -> GlobalDeclaration -> ShowS)
-> (GlobalDeclaration -> String)
-> ([GlobalDeclaration] -> ShowS)
-> Show GlobalDeclaration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GlobalDeclaration -> ShowS
showsPrec :: Int -> GlobalDeclaration -> ShowS
$cshow :: GlobalDeclaration -> String
show :: GlobalDeclaration -> String
$cshowList :: [GlobalDeclaration] -> ShowS
showList :: [GlobalDeclaration] -> ShowS
Show, GlobalDeclaration -> GlobalDeclaration -> Bool
(GlobalDeclaration -> GlobalDeclaration -> Bool)
-> (GlobalDeclaration -> GlobalDeclaration -> Bool)
-> Eq GlobalDeclaration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GlobalDeclaration -> GlobalDeclaration -> Bool
== :: GlobalDeclaration -> GlobalDeclaration -> Bool
$c/= :: GlobalDeclaration -> GlobalDeclaration -> Bool
/= :: GlobalDeclaration -> GlobalDeclaration -> Bool
Eq)

data Expression
  = ExprAtom AtomicExpression
  | ExprComp ComplexExpression
  | ExprLetIn (Identifier', Expression) Expression
  deriving (Int -> Expression -> ShowS
[Expression] -> ShowS
Expression -> String
(Int -> Expression -> ShowS)
-> (Expression -> String)
-> ([Expression] -> ShowS)
-> Show Expression
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Expression -> ShowS
showsPrec :: Int -> Expression -> ShowS
$cshow :: Expression -> String
show :: Expression -> String
$cshowList :: [Expression] -> ShowS
showList :: [Expression] -> ShowS
Show, Expression -> Expression -> Bool
(Expression -> Expression -> Bool)
-> (Expression -> Expression -> Bool) -> Eq Expression
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Expression -> Expression -> Bool
== :: Expression -> Expression -> Bool
$c/= :: Expression -> Expression -> Bool
/= :: Expression -> Expression -> Bool
Eq)

data AtomicExpression
  = AtomId Identifier'
  | AtomUnit
  | AtomBool Bool
  | AtomInt Int64
  deriving (Int -> AtomicExpression -> ShowS
[AtomicExpression] -> ShowS
AtomicExpression -> String
(Int -> AtomicExpression -> ShowS)
-> (AtomicExpression -> String)
-> ([AtomicExpression] -> ShowS)
-> Show AtomicExpression
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AtomicExpression -> ShowS
showsPrec :: Int -> AtomicExpression -> ShowS
$cshow :: AtomicExpression -> String
show :: AtomicExpression -> String
$cshowList :: [AtomicExpression] -> ShowS
showList :: [AtomicExpression] -> ShowS
Show, AtomicExpression -> AtomicExpression -> Bool
(AtomicExpression -> AtomicExpression -> Bool)
-> (AtomicExpression -> AtomicExpression -> Bool)
-> Eq AtomicExpression
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AtomicExpression -> AtomicExpression -> Bool
== :: AtomicExpression -> AtomicExpression -> Bool
$c/= :: AtomicExpression -> AtomicExpression -> Bool
/= :: AtomicExpression -> AtomicExpression -> Bool
Eq)

data ComplexExpression
  = CompApp Identifier' AtomicExpression
  | CompIte AtomicExpression Expression Expression
  | CompBinOp BinaryOperator AtomicExpression AtomicExpression
  | CompUnOp UnaryOperator AtomicExpression
  deriving (Int -> ComplexExpression -> ShowS
[ComplexExpression] -> ShowS
ComplexExpression -> String
(Int -> ComplexExpression -> ShowS)
-> (ComplexExpression -> String)
-> ([ComplexExpression] -> ShowS)
-> Show ComplexExpression
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ComplexExpression -> ShowS
showsPrec :: Int -> ComplexExpression -> ShowS
$cshow :: ComplexExpression -> String
show :: ComplexExpression -> String
$cshowList :: [ComplexExpression] -> ShowS
showList :: [ComplexExpression] -> ShowS
Show, ComplexExpression -> ComplexExpression -> Bool
(ComplexExpression -> ComplexExpression -> Bool)
-> (ComplexExpression -> ComplexExpression -> Bool)
-> Eq ComplexExpression
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ComplexExpression -> ComplexExpression -> Bool
== :: ComplexExpression -> ComplexExpression -> Bool
$c/= :: ComplexExpression -> ComplexExpression -> Bool
/= :: ComplexExpression -> ComplexExpression -> Bool
Eq)