fortran-src-0.15.1: Parsers and analyses for Fortran standards 66, 77, 90, 95 and 2003 (partial).
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Fortran.Analysis.Types

Synopsis

Documentation

analyseTypes :: Data a => ProgramFile (Analysis a) -> (ProgramFile (Analysis a), TypeEnv) Source #

Annotate AST nodes with type information and also return a type environment mapping names to type information.

analyseTypesWithEnv :: Data a => TypeEnv -> ProgramFile (Analysis a) -> (ProgramFile (Analysis a), TypeEnv) Source #

Annotate AST nodes with type information and also return a type environment mapping names to type information; provided with a starting type environment.

analyseAndCheckTypesWithEnv :: Data a => TypeEnv -> ProgramFile (Analysis a) -> (ProgramFile (Analysis a), TypeEnv, [TypeError]) Source #

Annotate AST nodes with type information, return a type environment mapping names to type information and return any type errors found; provided with a starting type environment.

type TypeEnv = Map Name IDType Source #

Mapping of names to type information.

type TypeError = (String, SrcSpan) Source #

Information about a detected type error.

deriveSemTypeFromDeclaration :: (MonadState InferState m, MonadReader InferConfig m) => SrcSpan -> SrcSpan -> TypeSpec a -> Maybe (Expression a) -> m SemType Source #

Attempt to derive the SemType of a variable from the relevant parts of its surrounding StDeclaration.

This is an example of a simple declaration:

INTEGER(8) :: var_name

A declaration holds a TypeSpec (left of the double colon; LHS) and a list of Declarators (right of the double colon; RHS). However, CHARACTER variable are allowed to specify their length via special syntax on the RHS:

CHARACTER :: string*10

so to handle that, this function takes that length as a Maybe Expression (as provided in StDeclaration).

If a length was defined on both sides, the declaration length (RHS) is used. This matches gfortran's behaviour, though even with -Wall they don't warn on this rather confusing syntax usage. We report a (soft) type error.

deriveSemTypeFromTypeSpec :: MonadState InferState m => TypeSpec a -> m SemType Source #

Attempt to derive a SemType from a TypeSpec.

deriveSemTypeFromBaseType :: BaseType -> SemType Source #

Derive SemType directly from BaseType, using relevant default kinds.

runInfer :: FortranVersion -> TypeEnv -> Infer a -> (a, InferState) Source #