Commit 8332a83d authored by marton bognar's avatar marton bognar
Browse files

Remove environments from namespace declarations

parent ee201fd6
...@@ -96,18 +96,16 @@ generated functions use its functions. ...@@ -96,18 +96,16 @@ generated functions use its functions.
### Namespace declarations ### Namespace declarations
A namespace declaration consists of the namespace's name, a sort name, and A namespace declaration consists of the namespace's name and the associated sort
optionally additional comma separated sort names (the environment of the name.
namespace).
``` ```
namespace NAMESPACENAME: SORTNAME[, SORTNAME]* namespace NAMESPACENAME: SORTNAME
``` ```
Example: Example:
``` ```
namespace TermVar: Term, Type namespace TermVar: Term
namespace TypeVar: Type
``` ```
### Sort declarations ### Sort declarations
......
import (Operations) import (Operations)
namespace TermVar: Value, ValueType namespace TermVar: Value
namespace SkelTypeVar: SkeletonType namespace SkelTypeVar: SkeletonType
namespace DirtVar: Dirt namespace DirtVar: Dirt
namespace TypeVar: ValueType, SkeletonType namespace TypeVar: ValueType
namespace CoVar: Coercion, SimpleCoercionType namespace CoVar: Coercion
sort Value sort Value
inh ctx TermVar inh ctx TermVar
......
namespace TermVar: Term, Type namespace TermVar: Term
namespace TypeVar: Type namespace TypeVar: Type
sort Term sort Term
......
namespace TermVar: FiTerm, FiType namespace TermVar: FiTerm
namespace TypeVar: FiType, FiType namespace TypeVar: FiType
sort FiTerm sort FiTerm
inh ctx TermVar inh ctx TermVar
......
namespace TermVar: Term, Type namespace TermVar: Term
namespace TypeVar: Type namespace TypeVar: Type
sort Term sort Term
......
...@@ -7,7 +7,6 @@ import GeneralTerms ...@@ -7,7 +7,6 @@ import GeneralTerms
-- variable representation -- variable representation
data ConvertFunctions = VF { data ConvertFunctions = VF {
variableType :: Language -> (Type, [Constructor]), variableType :: Language -> (Type, [Constructor]),
envType :: Language -> (Type, [Constructor]),
userTypes :: Language -> [(Type, [Constructor])], userTypes :: Language -> [(Type, [Constructor])],
variableInstances :: (Type, [Constructor]) -> [(Type, Type, [Function])], variableInstances :: (Type, [Constructor]) -> [(Type, Type, [Function])],
variableFunctions :: Language -> (Type, [Constructor]) -> [Function], variableFunctions :: Language -> (Type, [Constructor]) -> [Function],
...@@ -19,10 +18,9 @@ data ConvertFunctions = VF { ...@@ -19,10 +18,9 @@ data ConvertFunctions = VF {
convert :: Language -> ConvertFunctions -> Program convert :: Language -> ConvertFunctions -> Program
convert lan@(nsd, sd, imp, cd) vf = convert lan@(nsd, sd, imp, cd) vf =
let var = (variableType vf) lan let var = (variableType vf) lan
env = (envType vf) lan
in P { in P {
imports = imp, imports = imp,
types = var : env : (userTypes vf) lan, types = var : (userTypes vf) lan,
instances = (variableInstances vf) var, instances = (variableInstances vf) var,
functions = (variableFunctions vf) lan var ++ functions = (variableFunctions vf) lan var ++
(envFunctions vf) lan, (envFunctions vf) lan,
......
...@@ -42,8 +42,7 @@ type AttributeDef = (LeftExpr, RightExpr) ...@@ -42,8 +42,7 @@ type AttributeDef = (LeftExpr, RightExpr)
data NamespaceDef data NamespaceDef
= MkNameSpace { = MkNameSpace {
nname :: NamespaceName, nname :: NamespaceName,
nsort :: SortName, nsort :: SortName
nenv :: [String]
} }
deriving (Show, Eq) deriving (Show, Eq)
......
...@@ -100,8 +100,7 @@ pImportChoose = try (pParens $ many pIdentifier) <|> return [] ...@@ -100,8 +100,7 @@ pImportChoose = try (pParens $ many pIdentifier) <|> return []
pNameSpaceDecl :: Parser NamespaceDef pNameSpaceDecl :: Parser NamespaceDef
pNameSpaceDecl = pNameSpaceDecl =
MkNameSpace <$ pReserved "namespace" <*> pNameSpaceName <* pReservedOp ":" <*> MkNameSpace <$ pReserved "namespace" <*> pNameSpaceName <* pReservedOp ":" <*>
pSortName <*> pSortName
pEnvAdd
-- | Parse a namespace's name -- | Parse a namespace's name
pNameSpaceName :: Parser NamespaceName pNameSpaceName :: Parser NamespaceName
...@@ -111,13 +110,6 @@ pNameSpaceName = pIdentifier ...@@ -111,13 +110,6 @@ pNameSpaceName = pIdentifier
pSortName :: Parser SortName pSortName :: Parser SortName
pSortName = pIdentifier pSortName = pIdentifier
pEnvAdd :: Parser [String]
pEnvAdd =
many $ do
pReservedOp ","
pIdentifier
-- * Sort declarations -- * Sort declarations
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
......
{-# OPTIONS_GHC -Wall #-} {-# OPTIONS_GHC -Wall #-}
module Variable.Common (getEnvType, getEnvFunctions, freeVarFunctions, mappingFunctions, sortNameForIden, firstToVarParams, dropFold, ExternalFunctions(..), applyInhCtxsToAttrs, inhCtxsForSortName) where module Variable.Common (getEnvFunctions, freeVarFunctions, mappingFunctions, sortNameForIden, firstToVarParams, dropFold, ExternalFunctions(..), applyInhCtxsToAttrs, inhCtxsForSortName) where
import Data.List import Data.List
import Data.Maybe import Data.Maybe
...@@ -19,15 +19,6 @@ data ExternalFunctions = EF { ...@@ -19,15 +19,6 @@ data ExternalFunctions = EF {
-- * Types -- * Types
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
-- | Generate the data type definition for Env
getEnvType :: Language -> (Type, [Constructor])
getEnvType (nsd, _, _, _) =
("Env",
Constr "Nil" []
: map (
\(MkNameSpace name _ env) -> Constr ('E' : name) (env ++ ["Env"])
) nsd)
-- | ?? -- | ??
getEnvFunctions :: Language -> [Function] getEnvFunctions :: Language -> [Function]
getEnvFunctions (nsd, sd, _, _) getEnvFunctions (nsd, sd, _, _)
......
...@@ -13,7 +13,6 @@ getFunctions :: ConvertFunctions ...@@ -13,7 +13,6 @@ getFunctions :: ConvertFunctions
getFunctions getFunctions
= VF { = VF {
variableType = getVariableType, variableType = getVariableType,
envType = getEnvType,
userTypes = getTypes, userTypes = getTypes,
variableInstances = getVariableInstances, variableInstances = getVariableInstances,
variableFunctions = getVariableFunctions, variableFunctions = getVariableFunctions,
......
...@@ -14,7 +14,6 @@ getFunctions :: ConvertFunctions ...@@ -14,7 +14,6 @@ getFunctions :: ConvertFunctions
getFunctions getFunctions
= VF { = VF {
variableType = getVariableType, variableType = getVariableType,
envType = getEnvType,
userTypes = getTypes, userTypes = getTypes,
variableInstances = getVariableInstances, variableInstances = getVariableInstances,
variableFunctions = getVariableFunctions, variableFunctions = getVariableFunctions,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment