language-eiffel-0.1.2: Parser and pretty printer for the Eiffel language.

Safe HaskellNone

Language.Eiffel.Util

Contents

Synopsis

Documentation

class Feature a expr | a -> expr whereSource

A Feature can provide its name, arguments, contract, etc.

Methods

featureName :: a -> TextSource

The name of the feature.

featureArgs :: a -> [Decl]Source

Argument declarations.

featureResult :: a -> TypSource

Result type.

featurePre :: a -> [Clause expr]Source

Precondition.

featurePost :: a -> [Clause expr]Source

Postconditions.

featureIsFrozen :: a -> BoolSource

Whether the feature is frozen (can't be redefined).

featureRename :: a -> RenameClause -> aSource

Transform the feature given a renaming clause.

Instances

Feature (Constant expr) expr 
Feature (Attribute expr) expr 
Feature (FeatureEx expr) expr 
Feature (AbsRoutine body expr) expr 
Feature (SomeFeature body expr) expr 

data FeatureEx expr Source

An existential type to aggregate all features (routines, attributes, constants) together.

Constructors

forall a . Feature a expr => FeatureEx a

Wrap the Feature in the existential type.

Instances

Feature (FeatureEx expr) expr 
ClassFeature (FeatureEx expr) body expr 

wrapSomeFeature :: (forall f. Feature f expr => f -> b) -> SomeFeature body expr -> bSource

Wrap up SomeFeature

class Feature a expr => ClassFeature a body expr | a -> expr, a -> body whereSource

A way to extract each type of feature from a class.

Methods

allFeatures :: AbsClas body expr -> [a]Source

A list of all this class' features of the given type.

findFeature :: AbsClas body expr -> Text -> Maybe aSource

Find this kind of feature in a class

Instances

ClassFeature (Constant expr) body expr 
ClassFeature (Attribute expr) body expr 
ClassFeature (FeatureEx expr) body expr 
ClassFeature (AbsRoutine body expr) body expr 

findFeature' :: (SomeFeature body expr -> Maybe a) -> AbsClas body expr -> Text -> Maybe aSource

constToAttr :: Constant exp -> Attribute ExprSource

Convert a constant into an attribute.

Extracting data from a class.

allAttributes :: AbsClas body exp -> [Attribute exp]Source

Fetch attributes from all feature clauses.

allRoutines :: AbsClas body exp -> [AbsRoutine body exp]Source

Fetch routines from all feature clauses.

allConstants :: AbsClas body exp -> [Constant exp]Source

Fetch contants from all feature clauses.

allHelper :: Getting (HashMap k (ExportedFeature a)) (FeatureMap body exp) t (HashMap k (ExportedFeature a)) b -> AbsClas body exp -> [a]Source

allCreates :: AbsClas body exp -> [Text]Source

Fetch creation routines from all feature clauses.

allAttributeDecls :: AbsClas body exp -> [Decl]Source

Fetch attribute declarations from all feature clauses.

allConstantDecls :: AbsClas body exp -> [Decl]Source

Fetch constant declarations from all feature clauses.

allInherited :: AbsClas body exp -> [InheritClause]Source

All inheritance clauses.

allInheritedTypes :: AbsClas body exp -> [Typ]Source

All inherited classes, as types.

isCreateName :: Text -> AbsClas body exp -> BoolSource

Determine if a name is in the creation clause of a class.

SomeFeature predicates, extractors.

Class modification

Setting members of a class.

updFeatureMap :: AbsClas body exp -> FeatureMap body exp -> AbsClas body expSource

Set the feature clause of a class.

updFeatBody :: RoutineBody a -> PosAbsStmt b -> RoutineBody bSource

Update a routine body.

Mapping features of a class

mapRoutinesM :: (Applicative m, Monad m) => (AbsRoutine body exp -> m (AbsRoutine body exp)) -> FeatureMap body exp -> m (FeatureMap body exp)Source

These functions will update a class or feature clause with a transformation function.

Map a transformation function over the routines in a class, replacing the old routines with the transformed versions within a feature clause. mapRoutines f = Map.map (over exportFeat (onlyRoutine f))

Monadic version of mapRoutines.

mapAttributes :: (Attribute exp -> Attribute exp) -> FeatureMap body exp -> FeatureMap body expSource

Map a transformation function over the attributes in a class, replacing the old attributes with the transformed versions within a feature clause.

mapAttributesM :: (Monad m, Applicative m) => (Attribute exp -> m (Attribute exp)) -> FeatureMap body exp -> m (FeatureMap body exp)Source

Monadic version of mapAttributes.

mapContract :: (Clause exp1 -> Clause exp) -> Contract exp1 -> Contract expSource

Map a transformation function over the constants in a class, replacing the old constants with the transformed versions within a feature clause. mapConstants f = Map.map (over exportFeat (onlyConst f))

Map a transformation function over the contracts in a class, replacing the old contracts with the transformed versions within a feature clause.

mapExprs :: (AbsRoutine body exp -> AbsRoutine body' exp') -> (Constant exp -> Constant exp') -> (Clause exp -> Clause exp') -> FeatureMap body exp -> FeatureMap body' exp'Source

Map a transformation function over all expressions in a class. A transformation for features, constants, and attributes must be given as if the type of expressions changes (ie, with a typecheck) then all expressions types must change together.

classMapAttributes :: (Attribute exp -> Attribute exp) -> AbsClas body exp -> AbsClas body expSource

Map a transformation function over the attributes in a class, replacing the old attributes with the transformed versions within a class.

classMapAttributesM :: (Applicative m, Monad m) => (Attribute exp -> m (Attribute exp)) -> AbsClas body exp -> m (AbsClas body exp)Source

Monadic version of classMapAttributes.

classMapRoutines :: (AbsRoutine body exp -> AbsRoutine body exp) -> AbsClas body exp -> AbsClas body expSource

Map a transformation function over the routines in a class, replacing the old routines with the transformed versions within a class.

classMapRoutinesM :: (Applicative m, Monad m) => (AbsRoutine body exp -> m (AbsRoutine body exp)) -> AbsClas body exp -> m (AbsClas body exp)Source

Monadic version of classMapRoutines.

classMapConstants :: (Constant exp -> Constant exp) -> AbsClas body exp -> AbsClas body expSource

Map a transformation function over the constants in a class, replacing the old constants with the transformed versions within a class.

classMapExprs :: (AbsRoutine body exp -> AbsRoutine body' exp') -> (Clause exp -> Clause exp') -> (Constant exp -> Constant exp') -> AbsClas body exp -> AbsClas body' exp'Source

Map a transformation function over all expressions in a class. A transformation for features, constants, and attributes must be given as if the type of expressions changes (ie, with a typecheck) then all expressions types must change together. This is performed on every feature clause in a class.

Interface construction

makeRoutineIs :: SomeFeature body Expr -> SomeFeature EmptyBody ExprSource

Strip the body from a routine.

makeAttributeI :: Attribute exp -> Attribute ExprSource

Strip the contracts from an attribute.

clasInterface :: AbsClas body Expr -> ClasInterfaceSource

Strip the bodies from all features.

makeRoutineI :: AbsRoutine body Expr -> RoutineISource

Strip the bodies and rescue clause from a routine.

Map construction

clasMap :: [AbsClas body exp] -> Map ClassName (AbsClas body exp)Source

Turn a list of classes into a map indexed by the class names.

attrMap :: AbsClas body exp -> Map Text TypSource

Extract a map of attribute names to types given a class.

Search

findRoutine :: Clas -> Text -> Maybe RoutineSource

Find a routine in a class.

findOperator :: AbsClas body Expr -> Text -> Int -> Maybe (AbsRoutine body Expr)Source

Find an operator (symbol sequence) in a class.

findSomeFeature :: AbsClas body expr -> Text -> Maybe (SomeFeature body expr)Source

Find the sum-type for all features.

findFeatureEx :: AbsClas body expr -> Text -> Maybe (FeatureEx expr)Source

Find an existential FeatureEx.

findRoutineInt :: ClasInterface -> Text -> Maybe RoutineISource

Find a routine by name.

findAttrInt :: AbsClas body expr -> Text -> Maybe (Attribute expr)Source

Find an attribute in a class by name.

findConstantInt :: AbsClas body Expr -> Text -> Maybe (Constant Expr)Source

Find a constant by name in a class.

fullName :: AbsClas body exp -> RoutineI -> TextSource

Given a class and a routine, given a unique name.

fullNameStr :: Text -> Text -> TextSource

Given to string construct a unique combination.

genericStubs :: AbsClas body exp -> [AbsClas body' exp']Source

Given a class, create a list of generic classes for the formal generic parameters of the class.

makeGenericStub :: Generic -> AbsClas body expSource

Given a generic, construct a class for the generic.

Inheritance utilities

renameDecl :: RenameClause -> Decl -> DeclSource

Rename a declaration.

renameType :: RenameClause -> Typ -> TypSource

Rename a type, in the case of a like-type.

renameAll :: [RenameClause] -> AbsClas body exp -> AbsClas body expSource

Rename everything in a class.

undefineName :: Text -> AbsClas body exp -> AbsClas body expSource

Undefine a single feature in a class.

undefineAll :: InheritClause -> AbsClas body exp -> AbsClas body expSource

Undefine every specified name for a class.

mergeableClass :: AbsClas body exp -> BoolSource

Specifies whether a class can be merged with another.

mergeClass :: AbsClas body exp -> AbsClas body exp -> AbsClas body expSource

Merge two classes, combining invariants and feature clauses.

mergeClasses :: [AbsClas body exp] -> AbsClas body expSource

Merge a list of classes.

Feature Map functions

fmMapKeys :: (Text -> Text) -> FeatureMap body exp -> FeatureMap body expSource

fmKeyFilter :: (Text -> Bool) -> FeatureMap body exp -> FeatureMap body expSource

fmUnion :: FeatureMap body exp -> FeatureMap body exp -> FeatureMap body expSource

fmUnions :: [FeatureMap body exp] -> FeatureMap body expSource

Routine level utilities

argMap :: RoutineWithBody a -> Map Text TypSource

Construct a map from a routine's arguments.

localMap :: RoutineWithBody a -> Map Text TypSource

Construct a map from a routine's declarations.

routineDecls :: AbsRoutine (RoutineBody exp1) exp -> [Decl]Source

Give the declarations of a routine's locals.

opAlias :: BinOp -> TextSource

Operator aliases for user-level operators, ie, not including =, =, ~, and ~

equalityOp :: BinOp -> BoolSource

Test if the binary operator is an equality operator.

unOpAlias :: IsString a => UnOp -> aSource

Unary operator aliases for everything except old.

Type utilities

classToType :: AbsClas body exp -> TypSource

Convert a class into its type.

isBasic :: Typ -> BoolSource

Whether a type is basic (where basic meaning its an integer, natural, real or boolean).

intBits :: [Integer]Source

A list of the number of integer bits (8, 16, ...)

typeBounds :: Typ -> (Integer, Integer)Source

The bounds on the range of values a integer or natural type can take.

isBooleanType :: Typ -> BoolSource

Boolean type test.

isIntegerType :: Typ -> BoolSource

Integer type test.

isNaturalType :: Typ -> BoolSource

Natural number type test.

isRealType :: Typ -> BoolSource

Real number type test.

isCharType :: Typ -> BoolSource

Character type test.

integerTypeNames :: [Text]Source

List of integer type names (ie, INTEGER_32).

naturalTypeNames :: [Text]Source

List of integer type names (ie, NATURAL_32).

realTypeNames :: [Text]Source

List of integer type names (ie, REAL_64).

charTypeNames :: [Text]Source

List of integer type names (ie, CHARACTER_8).

classNameType :: Typ -> TextSource

Given a type give the name of the class as a string.

intType :: TypSource

The default integer type.

boolType :: TypSource

The default boolean type.

realType :: TypSource

The default real number type.

charType :: TypSource

The default character type.

stringType :: TypSource

The default string type.

anyType :: TypSource

The top type, ANY.

namedType :: ClassName -> TypSource

Construct a simple type from a classname.

Declaration

insertDecl :: Decl -> Map Text Typ -> Map Text TypSource

Insert a declaration into a string-type map.

declsToMap :: [Decl] -> Map Text TypSource

Turn a list of declarations into a string-type map.

SCOOP utilities

newVar :: ProcDecl -> ProcSource

Given a processor declaration, extract the processor.