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.
### Namespace declarations
A namespace declaration consists of the namespace's name, a sort name, and
optionally additional comma separated sort names (the environment of the
namespace).
A namespace declaration consists of the namespace's name and the associated sort
name.
```
namespace NAMESPACENAME: SORTNAME[, SORTNAME]*
namespace NAMESPACENAME: SORTNAME
```
Example:
```
namespace TermVar: Term, Type
namespace TypeVar: Type
namespace TermVar: Term
```
### Sort declarations
......
import (Operations)
namespace TermVar: Value, ValueType
namespace TermVar: Value
namespace SkelTypeVar: SkeletonType
namespace DirtVar: Dirt
namespace TypeVar: ValueType, SkeletonType
namespace CoVar: Coercion, SimpleCoercionType
namespace TypeVar: ValueType
namespace CoVar: Coercion
sort Value
inh ctx TermVar
......
namespace TermVar: Term, Type
namespace TermVar: Term
namespace TypeVar: Type
sort Term
......
namespace TermVar: FiTerm, FiType
namespace TypeVar: FiType, FiType
namespace TermVar: FiTerm
namespace TypeVar: FiType
sort FiTerm
inh ctx TermVar
......
namespace TermVar: Term, Type
namespace TermVar: Term
namespace TypeVar: Type
sort Term
......
......@@ -7,7 +7,6 @@ import GeneralTerms
-- variable representation
data ConvertFunctions = VF {
variableType :: Language -> (Type, [Constructor]),
envType :: Language -> (Type, [Constructor]),
userTypes :: Language -> [(Type, [Constructor])],
variableInstances :: (Type, [Constructor]) -> [(Type, Type, [Function])],
variableFunctions :: Language -> (Type, [Constructor]) -> [Function],
......@@ -19,10 +18,9 @@ data ConvertFunctions = VF {
convert :: Language -> ConvertFunctions -> Program
convert lan@(nsd, sd, imp, cd) vf =
let var = (variableType vf) lan
env = (envType vf) lan
in P {
imports = imp,
types = var : env : (userTypes vf) lan,
types = var : (userTypes vf) lan,
instances = (variableInstances vf) var,
functions = (variableFunctions vf) lan var ++
(envFunctions vf) lan,
......
......@@ -42,8 +42,7 @@ type AttributeDef = (LeftExpr, RightExpr)
data NamespaceDef
= MkNameSpace {
nname :: NamespaceName,
nsort :: SortName,
nenv :: [String]
nsort :: SortName
}
deriving (Show, Eq)
......
......@@ -100,8 +100,7 @@ pImportChoose = try (pParens $ many pIdentifier) <|> return []
pNameSpaceDecl :: Parser NamespaceDef
pNameSpaceDecl =
MkNameSpace <$ pReserved "namespace" <*> pNameSpaceName <* pReservedOp ":" <*>
pSortName <*>
pEnvAdd
pSortName
-- | Parse a namespace's name
pNameSpaceName :: Parser NamespaceName
......@@ -111,13 +110,6 @@ pNameSpaceName = pIdentifier
pSortName :: Parser SortName
pSortName = pIdentifier
pEnvAdd :: Parser [String]
pEnvAdd =
many $ do
pReservedOp ","
pIdentifier
-- * Sort declarations
-- ----------------------------------------------------------------------------
......
{-# 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.Maybe
......@@ -19,15 +19,6 @@ data ExternalFunctions = EF {
-- * 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 (nsd, sd, _, _)
......
......@@ -13,7 +13,6 @@ getFunctions :: ConvertFunctions
getFunctions
= VF {
variableType = getVariableType,
envType = getEnvType,
userTypes = getTypes,
variableInstances = getVariableInstances,
variableFunctions = getVariableFunctions,
......
......@@ -14,7 +14,6 @@ getFunctions :: ConvertFunctions
getFunctions
= VF {
variableType = getVariableType,
envType = getEnvType,
userTypes = getTypes,
variableInstances = getVariableInstances,
variableFunctions = getVariableFunctions,
......
Supports Markdown
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