-- Populate environment by pre-scanning statment list

-- Populate environment by pre-scanning statment list

inheritEnvs t ve me

| subtypes == [ ] = me

otherwise

| otherwise = nextBranch newME subtypes

where

where subtypes = getAllSubTypes t ve

otherwise

| otherwise = ( tt, envlist )

newME = map ( addEnv ( lookupEnv t me ) ) me

getEnvStmt ( VarDecl t v ) ( ve,me ) = ( ( ( v,t ) : ve ) , me )

getEnvStmt ( VarInit t v e ) ( ve,me ) = ( ( ( v,t ) : ve ) , me )

= ( ( ( o, TypeType ) : ve ) , ( ( ( UserType o ) , memEnv ) : me ) )

where

where ( memEnv,_ ) = getEnvBlock slist ( ve,me )

= ( ( ( o, ( SubType t ) ) : ve ) , ( ( ( UserType o ) , memEnv ) : me ) )

where

where ( memEnv,_ ) = getEnvBlock slist ( ve,me )

where

where typify ( s,_ ) = UserType s

otherwise

| otherwise = ( stype == ( SubType tt ) )

-- Check top-level statements using pre-compiled environment

-- Check top-level statements using pre-compiled environment

" but found "

otherwise

| otherwise = m1 ++ [ "Expected " ++ show ( t ) ++ " but found " ++ show ( eType ) ]

where

where ( eType, m1 ) = checkExp e env msg

otherwise

| otherwise

" but found "

= m1 ++ [ "Expected " ++ show ( vType ) ++ " but found " ++ show ( eType ) ]

where

where vType = lookupType v ve

otherwise

| otherwise = lookupEnv t xs

-- Operators grouped appropriately by types

-- Operators grouped appropriately by types

-- Evaluate expression types using environment

-- Evaluate expression types using environment