fortran-src 0.16.3 → 0.16.5
raw patch · 15 files changed
+149/−46 lines, 15 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Language.Fortran.AST: ($dmgetAnnotation) :: (Annotated f, FirstParameter (f a) a) => f a -> a
+ Language.Fortran.AST: ($dmsetAnnotation) :: (Annotated f, FirstParameter (f a) a) => a -> f a -> f a
+ Language.Fortran.AST.Annotated: ($dmgetAnnotation) :: (Annotated f, FirstParameter (f a) a) => f a -> a
+ Language.Fortran.AST.Annotated: ($dmsetAnnotation) :: (Annotated f, FirstParameter (f a) a) => a -> f a -> f a
+ Language.Fortran.Analysis.Types: extractTypeEnvExtended :: Data a => ProgramFile (Analysis a) -> TypeEnvExtended
+ Language.Fortran.Analysis.Types: stripExtended :: TypeEnvExtended -> TypeEnv
+ Language.Fortran.Analysis.Types: type TypeEnvExtended = Map Name (Name, SrcSpan, IDType)
+ Language.Fortran.Parser.LexerUtils: unescapeSpecialChars :: String -> String
+ Language.Fortran.Util.FirstParameter: ($dmgetFirstParameter) :: (FirstParameter a e, Generic a, GFirstParameter (Rep a) e) => a -> e
+ Language.Fortran.Util.FirstParameter: ($dmsetFirstParameter) :: (FirstParameter a e, Generic a, GFirstParameter (Rep a) e) => e -> a -> a
+ Language.Fortran.Util.Position: ($dmgetSpan) :: (Spanned a, SecondParameter a SrcSpan) => a -> SrcSpan
+ Language.Fortran.Util.Position: ($dmsetSpan) :: (Spanned a, SecondParameter a SrcSpan) => SrcSpan -> a -> a
+ Language.Fortran.Util.SecondParameter: ($dmgetSecondParameter) :: (SecondParameter a e, Generic a, GSecondParameter (Rep a) e) => a -> e
+ Language.Fortran.Util.SecondParameter: ($dmsetSecondParameter) :: (SecondParameter a e, Generic a, GSecondParameter (Rep a) e) => e -> a -> a
- Language.Fortran.AST: Comment :: String -> Comment a
+ Language.Fortran.AST: Comment :: String -> Comment (a :: k)
- Language.Fortran.AST: class Annotated f
+ Language.Fortran.AST: class Annotated (f :: Type -> Type)
- Language.Fortran.AST: class Labeled f
+ Language.Fortran.AST: class Labeled (f :: Type -> Type)
- Language.Fortran.AST: getAnnotation :: (Annotated f, FirstParameter (f a) a) => f a -> a
+ Language.Fortran.AST: getAnnotation :: Annotated f => f a -> a
- Language.Fortran.AST: newtype Comment a
+ Language.Fortran.AST: newtype Comment (a :: k)
- Language.Fortran.AST: setAnnotation :: (Annotated f, FirstParameter (f a) a) => a -> f a -> f a
+ Language.Fortran.AST: setAnnotation :: Annotated f => a -> f a -> f a
- Language.Fortran.AST: type Prefixes a = Maybe (AList Prefix a)
+ Language.Fortran.AST: type Prefixes a = Maybe AList Prefix a
- Language.Fortran.AST: type Suffixes a = Maybe (AList Suffix a)
+ Language.Fortran.AST: type Suffixes a = Maybe AList Suffix a
- Language.Fortran.AST.AList: AList :: a -> SrcSpan -> [t a] -> AList t a
+ Language.Fortran.AST.AList: AList :: a -> SrcSpan -> [t a] -> AList (t :: Type -> Type) a
- Language.Fortran.AST.AList: ATuple :: a -> SrcSpan -> t1 a -> t2 a -> ATuple t1 t2 a
+ Language.Fortran.AST.AList: ATuple :: a -> SrcSpan -> t1 a -> t2 a -> ATuple (t1 :: Type -> Type) (t2 :: Type -> Type) a
- Language.Fortran.AST.AList: [alistAnno] :: AList t a -> a
+ Language.Fortran.AST.AList: [alistAnno] :: AList (t :: Type -> Type) a -> a
- Language.Fortran.AST.AList: [alistList] :: AList t a -> [t a]
+ Language.Fortran.AST.AList: [alistList] :: AList (t :: Type -> Type) a -> [t a]
- Language.Fortran.AST.AList: [alistSpan] :: AList t a -> SrcSpan
+ Language.Fortran.AST.AList: [alistSpan] :: AList (t :: Type -> Type) a -> SrcSpan
- Language.Fortran.AST.AList: [atupleAnno] :: ATuple t1 t2 a -> a
+ Language.Fortran.AST.AList: [atupleAnno] :: ATuple (t1 :: Type -> Type) (t2 :: Type -> Type) a -> a
- Language.Fortran.AST.AList: [atupleFst] :: ATuple t1 t2 a -> t1 a
+ Language.Fortran.AST.AList: [atupleFst] :: ATuple (t1 :: Type -> Type) (t2 :: Type -> Type) a -> t1 a
- Language.Fortran.AST.AList: [atupleSnd] :: ATuple t1 t2 a -> t2 a
+ Language.Fortran.AST.AList: [atupleSnd] :: ATuple (t1 :: Type -> Type) (t2 :: Type -> Type) a -> t2 a
- Language.Fortran.AST.AList: [atupleSpan] :: ATuple t1 t2 a -> SrcSpan
+ Language.Fortran.AST.AList: [atupleSpan] :: ATuple (t1 :: Type -> Type) (t2 :: Type -> Type) a -> SrcSpan
- Language.Fortran.AST.AList: aEmpty :: a -> SrcSpan -> AList t a
+ Language.Fortran.AST.AList: aEmpty :: forall a (t :: Type -> Type). a -> SrcSpan -> AList t a
- Language.Fortran.AST.AList: aReverse :: AList t a -> AList t a
+ Language.Fortran.AST.AList: aReverse :: forall (t :: Type -> Type) a. AList t a -> AList t a
- Language.Fortran.AST.AList: data AList t a
+ Language.Fortran.AST.AList: data AList (t :: Type -> Type) a
- Language.Fortran.AST.AList: data ATuple t1 t2 a
+ Language.Fortran.AST.AList: data ATuple (t1 :: Type -> Type) (t2 :: Type -> Type) a
- Language.Fortran.AST.Annotated: class Annotated f
+ Language.Fortran.AST.Annotated: class Annotated (f :: Type -> Type)
- Language.Fortran.AST.Annotated: getAnnotation :: (Annotated f, FirstParameter (f a) a) => f a -> a
+ Language.Fortran.AST.Annotated: getAnnotation :: Annotated f => f a -> a
- Language.Fortran.AST.Annotated: setAnnotation :: (Annotated f, FirstParameter (f a) a) => a -> f a -> f a
+ Language.Fortran.AST.Annotated: setAnnotation :: Annotated f => a -> f a -> f a
- Language.Fortran.Analysis: allVars :: forall a b. (Data a, Data (b (Analysis a))) => b (Analysis a) -> [Name]
+ Language.Fortran.Analysis: allVars :: (Data a, Data (b (Analysis a))) => b (Analysis a) -> [Name]
- Language.Fortran.Analysis: analyseAllLhsVars :: forall a. Data a => ProgramFile (Analysis a) -> ProgramFile (Analysis a)
+ Language.Fortran.Analysis: analyseAllLhsVars :: Data a => ProgramFile (Analysis a) -> ProgramFile (Analysis a)
- Language.Fortran.Analysis: blockVarUses :: forall a. Data a => Block (Analysis a) -> [Name]
+ Language.Fortran.Analysis: blockVarUses :: Data a => Block (Analysis a) -> [Name]
- Language.Fortran.Analysis: lhsExprs :: forall a b. (Data a, Data (b a)) => b a -> [Expression a]
+ Language.Fortran.Analysis: lhsExprs :: (Data a, Data (b a)) => b a -> [Expression a]
- Language.Fortran.Analysis: type TransFunc f g a = (f (Analysis a) -> f (Analysis a)) -> g (Analysis a) -> g (Analysis a)
+ Language.Fortran.Analysis: type TransFunc (f :: Type -> Type) (g :: Type -> Type) a = f Analysis a -> f Analysis a -> g Analysis a -> g Analysis a
- Language.Fortran.Analysis: type TransFuncM m f g a = (f (Analysis a) -> m (f (Analysis a))) -> g (Analysis a) -> m (g (Analysis a))
+ Language.Fortran.Analysis: type TransFuncM (m :: Type -> Type) (f :: Type -> Type) (g :: Type -> Type) a = f Analysis a -> m f Analysis a -> g Analysis a -> m g Analysis a
- Language.Fortran.Analysis.BBlocks: genSuperBBGr :: forall a. Data a => BBlockMap (Analysis a) -> SuperBBGr (Analysis a)
+ Language.Fortran.Analysis.BBlocks: genSuperBBGr :: Data a => BBlockMap (Analysis a) -> SuperBBGr (Analysis a)
- Language.Fortran.Analysis.BBlocks: type BBlockMap a = Map ProgramUnitName (BBGr a)
+ Language.Fortran.Analysis.BBlocks: type BBlockMap a = Map ProgramUnitName BBGr a
- Language.Fortran.Analysis.DataFlow: analyseConstExps :: forall a. Data a => ProgramFile (Analysis a) -> ProgramFile (Analysis a)
+ Language.Fortran.Analysis.DataFlow: analyseConstExps :: Data a => ProgramFile (Analysis a) -> ProgramFile (Analysis a)
- Language.Fortran.Analysis.DataFlow: analyseParameterVars :: forall a. Data a => ParameterVarMap -> ProgramFile (Analysis a) -> ProgramFile (Analysis a)
+ Language.Fortran.Analysis.DataFlow: analyseParameterVars :: Data a => ParameterVarMap -> ProgramFile (Analysis a) -> ProgramFile (Analysis a)
- Language.Fortran.Analysis.DataFlow: genConstExpMap :: forall a. Data a => ProgramFile (Analysis a) -> ConstExpMap
+ Language.Fortran.Analysis.DataFlow: genConstExpMap :: Data a => ProgramFile (Analysis a) -> ConstExpMap
- Language.Fortran.Analysis.DataFlow: genDerivedInductionMap :: forall a. Data a => BackEdgeMap -> BBGr (Analysis a) -> DerivedInductionMap
+ Language.Fortran.Analysis.DataFlow: genDerivedInductionMap :: Data a => BackEdgeMap -> BBGr (Analysis a) -> DerivedInductionMap
- Language.Fortran.Analysis.DataFlow: genInductionVarMapByASTBlock :: forall a. Data a => BackEdgeMap -> BBGr (Analysis a) -> InductionVarMapByASTBlock
+ Language.Fortran.Analysis.DataFlow: genInductionVarMapByASTBlock :: Data a => BackEdgeMap -> BBGr (Analysis a) -> InductionVarMapByASTBlock
- Language.Fortran.Analysis.DataFlow: type BlockMap a = ASTBlockNodeMap (Block (Analysis a))
+ Language.Fortran.Analysis.DataFlow: type BlockMap a = ASTBlockNodeMap Block Analysis a
- Language.Fortran.Analysis.DataFlow: type CallMap = Map ProgramUnitName (Set Name)
+ Language.Fortran.Analysis.DataFlow: type CallMap = Map ProgramUnitName Set Name
- Language.Fortran.Analysis.DataFlow: type ConstExpMap = ASTExprNodeMap (Maybe FValue)
+ Language.Fortran.Analysis.DataFlow: type ConstExpMap = ASTExprNodeMap Maybe FValue
- Language.Fortran.Analysis.DataFlow: type FlowsGraph a = Gr (Block (Analysis a)) ()
+ Language.Fortran.Analysis.DataFlow: type FlowsGraph a = Gr Block Analysis a ()
- Language.Fortran.Analysis.DataFlow: type InOutMap t = BBNodeMap (InOut t)
+ Language.Fortran.Analysis.DataFlow: type InOutMap t = BBNodeMap InOut t
- Language.Fortran.Analysis.DataFlow: type InductionVarMap = BBNodeMap (Set Name)
+ Language.Fortran.Analysis.DataFlow: type InductionVarMap = BBNodeMap Set Name
- Language.Fortran.Analysis.DataFlow: type InductionVarMapByASTBlock = ASTBlockNodeMap (Set Name)
+ Language.Fortran.Analysis.DataFlow: type InductionVarMapByASTBlock = ASTBlockNodeMap Set Name
- Language.Fortran.Analysis.DataFlow: type VarFlowsMap = Map Name (Set Name)
+ Language.Fortran.Analysis.DataFlow: type VarFlowsMap = Map Name Set Name
- Language.Fortran.Analysis.SemanticTypes: recoverSemTypeTypeSpec :: forall a. a -> SrcSpan -> FortranVersion -> SemType -> TypeSpec a
+ Language.Fortran.Analysis.SemanticTypes: recoverSemTypeTypeSpec :: a -> SrcSpan -> FortranVersion -> SemType -> TypeSpec a
- Language.Fortran.Analysis.SemanticTypes: type Dimensions = Dims NonEmpty (Maybe Int)
+ Language.Fortran.Analysis.SemanticTypes: type Dimensions = Dims NonEmpty Maybe Int
- Language.Fortran.Analysis.Types: extractTypeEnv :: forall a. Data a => ProgramFile (Analysis a) -> TypeEnv
+ Language.Fortran.Analysis.Types: extractTypeEnv :: Data a => ProgramFile (Analysis a) -> TypeEnv
- Language.Fortran.Common.Array: DimsAssumedShape :: t a -> Dims t a
+ Language.Fortran.Common.Array: DimsAssumedShape :: t a -> Dims (t :: Type -> Type) a
- Language.Fortran.Common.Array: DimsAssumedSize :: Maybe (t (Dim a)) -> a -> Dims t a
+ Language.Fortran.Common.Array: DimsAssumedSize :: Maybe (t (Dim a)) -> a -> Dims (t :: Type -> Type) a
- Language.Fortran.Common.Array: DimsExplicitShape :: t (Dim a) -> Dims t a
+ Language.Fortran.Common.Array: DimsExplicitShape :: t (Dim a) -> Dims (t :: Type -> Type) a
- Language.Fortran.Common.Array: data Dims t a
+ Language.Fortran.Common.Array: data Dims (t :: Type -> Type) a
- Language.Fortran.Common.Array: dimsLength :: Foldable t => Dims t a -> Int
+ Language.Fortran.Common.Array: dimsLength :: forall (t :: Type -> Type) a. Foldable t => Dims t a -> Int
- Language.Fortran.Common.Array: dimsTraverse :: (Traversable t, Applicative f) => Dims t (f a) -> f (Dims t a)
+ Language.Fortran.Common.Array: dimsTraverse :: forall (t :: Type -> Type) f a. (Traversable t, Applicative f) => Dims t (f a) -> f (Dims t a)
- Language.Fortran.Parser.Monad: ParseError :: Position -> Maybe b -> String -> String -> ParseError a b
+ Language.Fortran.Parser.Monad: ParseError :: Position -> Maybe b -> String -> String -> ParseError (a :: k) b
- Language.Fortran.Parser.Monad: [errFilename] :: ParseError a b -> String
+ Language.Fortran.Parser.Monad: [errFilename] :: ParseError (a :: k) b -> String
- Language.Fortran.Parser.Monad: [errLastToken] :: ParseError a b -> Maybe b
+ Language.Fortran.Parser.Monad: [errLastToken] :: ParseError (a :: k) b -> Maybe b
- Language.Fortran.Parser.Monad: [errMsg] :: ParseError a b -> String
+ Language.Fortran.Parser.Monad: [errMsg] :: ParseError (a :: k) b -> String
- Language.Fortran.Parser.Monad: [errPos] :: ParseError a b -> Position
+ Language.Fortran.Parser.Monad: [errPos] :: ParseError (a :: k) b -> Position
- Language.Fortran.Parser.Monad: data ParseError a b
+ Language.Fortran.Parser.Monad: data ParseError (a :: k) b
- Language.Fortran.Parser.Monad: getLastToken :: (LastToken a b, Show b) => a -> Maybe b
+ Language.Fortran.Parser.Monad: getLastToken :: LastToken a b => a -> Maybe b
- Language.Fortran.Repr.Eval.Common: class Monad m => MonadFEval m where {
+ Language.Fortran.Repr.Eval.Common: class Monad m => MonadFEval (m :: Type -> Type) where {
- Language.Fortran.Repr.Eval.Common: type EvalTo m;
+ Language.Fortran.Repr.Eval.Common: type EvalTo (m :: Type -> Type);
- Language.Fortran.Repr.Eval.Type: fromExpression :: forall m a. (MonadFEval m, EvalTo m ~ FType) => Expression a -> m (Either String FType)
+ Language.Fortran.Repr.Eval.Type: fromExpression :: (MonadFEval m, EvalTo m ~ FType) => Expression a -> m (Either String FType)
- Language.Fortran.Repr.Eval.Value: type FEvalValuePureT = WriterT [String] (ExceptT Error (Reader (Map Name FValue)))
+ Language.Fortran.Repr.Eval.Value: type FEvalValuePureT = WriterT [String] ExceptT Error Reader Map Name FValue
- Language.Fortran.Repr.Eval.Value: type MonadFEvalValue m = (MonadFEval m, EvalTo m ~ FValue, MonadError Error m)
+ Language.Fortran.Repr.Eval.Value: type MonadFEvalValue (m :: Type -> Type) = (MonadFEval m, EvalTo m ~ FValue, MonadError Error m)
- Language.Fortran.Repr.Type.Scalar.Int: type family FTIntCombine k1 k2
+ Language.Fortran.Repr.Type.Scalar.Int: type family FTIntCombine (k1 :: FTInt) (k2 :: FTInt) :: FTInt
- Language.Fortran.Repr.Value.Scalar.Common: [SomeFKinded] :: forall {k} ft (fk :: k). (SingKind k, SingI fk, Data (ft fk)) => ft fk -> SomeFKinded k ft
+ Language.Fortran.Repr.Value.Scalar.Common: [SomeFKinded] :: forall {k} (ft :: k -> Type) (fk :: k). (SingKind k, SingI fk, Data (ft fk)) => ft fk -> SomeFKinded k ft
- Language.Fortran.Repr.Value.Scalar.Common: data SomeFKinded k ft
+ Language.Fortran.Repr.Value.Scalar.Common: data SomeFKinded k1 (ft :: k -> Type)
- Language.Fortran.Repr.Value.Scalar.Common: someFKindedKind :: SomeFKinded k ft -> Demote k
+ Language.Fortran.Repr.Value.Scalar.Common: someFKindedKind :: forall {k1} k2 (ft :: k1 -> Type). SomeFKinded k2 ft -> Demote k2
- Language.Fortran.Repr.Value.Scalar.Common: type FKindedC a b :: Constraint;
+ Language.Fortran.Repr.Value.Scalar.Common: type FKindedC a b;
- Language.Fortran.Repr.Value.Scalar.Int.Idealized: fIntICheckBounds :: forall k rep. (rep ~ FIntMRep k, Bounded rep, Integral rep) => FIntI k -> Maybe String
+ Language.Fortran.Repr.Value.Scalar.Int.Idealized: fIntICheckBounds :: forall (k :: FTInt) rep. (rep ~ FIntMRep k, Bounded rep, Integral rep) => FIntI k -> Maybe String
- Language.Fortran.Repr.Value.Scalar.Int.Idealized: type family FIntMRep k = r | r -> k
+ Language.Fortran.Repr.Value.Scalar.Int.Idealized: type family FIntMRep (k :: FTInt) = (r :: Type) | r -> k
- Language.Fortran.Repr.Value.Scalar.String: concatFString :: forall ll lr. (KnownNat ll, KnownNat lr) => FString ll -> FString lr -> FString (ll + lr)
+ Language.Fortran.Repr.Value.Scalar.String: concatFString :: forall (ll :: Nat) (lr :: Nat). (KnownNat ll, KnownNat lr) => FString ll -> FString lr -> FString (ll + lr)
- Language.Fortran.Repr.Value.Scalar.String: eqFString :: FString l -> FString r -> Bool
+ Language.Fortran.Repr.Value.Scalar.String: eqFString :: forall (l :: NaturalK) (r :: NaturalK). FString l -> FString r -> Bool
- Language.Fortran.Repr.Value.Scalar.String: fString :: forall l. KnownNat l => Text -> Maybe (FString l)
+ Language.Fortran.Repr.Value.Scalar.String: fString :: forall (l :: Nat). KnownNat l => Text -> Maybe (FString l)
- Language.Fortran.Repr.Value.Scalar.String: fStringBOp :: (Text -> Text -> r) -> FString ll -> FString lr -> r
+ Language.Fortran.Repr.Value.Scalar.String: fStringBOp :: forall r (ll :: NaturalK) (lr :: NaturalK). (Text -> Text -> r) -> FString ll -> FString lr -> r
- Language.Fortran.Repr.Value.Scalar.String: fStringLen :: forall l. KnownNat l => FString l -> Natural
+ Language.Fortran.Repr.Value.Scalar.String: fStringLen :: forall (l :: Nat). KnownNat l => FString l -> Natural
- Language.Fortran.Transformation.Monad: runTransform :: Data a => TypeEnv -> ModuleMap -> Transform a () -> ProgramFile a -> ProgramFile a
+ Language.Fortran.Transformation.Monad: runTransform :: Data a => TypeEnvExtended -> ModuleMap -> Transform a () -> ProgramFile a -> ProgramFile a
- Language.Fortran.Transformation.Monad: type Transform a = State (TransformationState a)
+ Language.Fortran.Transformation.Monad: type Transform a = State TransformationState a
- Language.Fortran.Util.FirstParameter: class GFirstParameter f e
+ Language.Fortran.Util.FirstParameter: class GFirstParameter (f :: k -> Type) e
- Language.Fortran.Util.FirstParameter: getFirstParameter :: (FirstParameter a e, Generic a, GFirstParameter (Rep a) e) => a -> e
+ Language.Fortran.Util.FirstParameter: getFirstParameter :: FirstParameter a e => a -> e
- Language.Fortran.Util.FirstParameter: getFirstParameter' :: GFirstParameter f e => f a -> e
+ Language.Fortran.Util.FirstParameter: getFirstParameter' :: forall (a :: k). GFirstParameter f e => f a -> e
- Language.Fortran.Util.FirstParameter: setFirstParameter :: (FirstParameter a e, Generic a, GFirstParameter (Rep a) e) => e -> a -> a
+ Language.Fortran.Util.FirstParameter: setFirstParameter :: FirstParameter a e => e -> a -> a
- Language.Fortran.Util.FirstParameter: setFirstParameter' :: GFirstParameter f e => e -> f a -> f a
+ Language.Fortran.Util.FirstParameter: setFirstParameter' :: forall (a :: k). GFirstParameter f e => e -> f a -> f a
- Language.Fortran.Util.ModFile: combinedTypeEnv :: ModFiles -> TypeEnv
+ Language.Fortran.Util.ModFile: combinedTypeEnv :: ModFiles -> TypeEnvExtended
- Language.Fortran.Util.ModFile: extractDeclMap :: forall a. Data a => ProgramFile (Analysis a) -> DeclMap
+ Language.Fortran.Util.ModFile: extractDeclMap :: Data a => ProgramFile (Analysis a) -> DeclMap
- Language.Fortran.Util.ModFile: extractModuleMap :: forall a. Data a => ProgramFile (Analysis a) -> ModuleMap
+ Language.Fortran.Util.ModFile: extractModuleMap :: Data a => ProgramFile (Analysis a) -> ModuleMap
- Language.Fortran.Util.ModFile: extractParamVarMap :: forall a. Data a => ProgramFile (Analysis a) -> ParamVarMap
+ Language.Fortran.Util.ModFile: extractParamVarMap :: Data a => ProgramFile (Analysis a) -> ParamVarMap
- Language.Fortran.Util.ModFile: genModFile :: forall a. Data a => ProgramFile (Analysis a) -> ModFile
+ Language.Fortran.Util.ModFile: genModFile :: Data a => ProgramFile (Analysis a) -> ModFile
- Language.Fortran.Util.ModFile: regenModFile :: forall a. Data a => ProgramFile (Analysis a) -> ModFile -> ModFile
+ Language.Fortran.Util.ModFile: regenModFile :: Data a => ProgramFile (Analysis a) -> ModFile -> ModFile
- Language.Fortran.Util.Position: getSpan :: (Spanned a, SecondParameter a SrcSpan) => a -> SrcSpan
+ Language.Fortran.Util.Position: getSpan :: Spanned a => a -> SrcSpan
- Language.Fortran.Util.Position: setSpan :: (Spanned a, SecondParameter a SrcSpan) => SrcSpan -> a -> a
+ Language.Fortran.Util.Position: setSpan :: Spanned a => SrcSpan -> a -> a
- Language.Fortran.Util.SecondParameter: getSecondParameter :: (SecondParameter a e, Generic a, GSecondParameter (Rep a) e) => a -> e
+ Language.Fortran.Util.SecondParameter: getSecondParameter :: SecondParameter a e => a -> e
- Language.Fortran.Util.SecondParameter: setSecondParameter :: (SecondParameter a e, Generic a, GSecondParameter (Rep a) e) => e -> a -> a
+ Language.Fortran.Util.SecondParameter: setSecondParameter :: SecondParameter a e => e -> a -> a
Files
- CHANGELOG.md +7/−0
- LICENSE +0/−2
- README.md +34/−5
- app/Main.hs +11/−9
- fortran-src.cabal +3/−4
- src/Language/Fortran/AST/Literal/Boz.hs +1/−1
- src/Language/Fortran/Analysis/Types.hs +26/−0
- src/Language/Fortran/Parser/Fixed/Lexer.x +2/−2
- src/Language/Fortran/Parser/Free/Fortran2003.y +10/−2
- src/Language/Fortran/Parser/Free/Lexer.x +22/−14
- src/Language/Fortran/Parser/LexerUtils.hs +15/−1
- src/Language/Fortran/Transformation/Monad.hs +4/−2
- src/Language/Fortran/Util/ModFile.hs +3/−3
- src/Language/Fortran/Util/Position.hs +4/−1
- test/Language/Fortran/Parser/Free/Fortran2003Spec.hs +7/−0
CHANGELOG.md view
@@ -1,3 +1,10 @@+### 0.16.5 [in preparation]+ * Small fix to Fortran 2003 parsing around `procedure` statements.++### 0.16.4 (Feb 07, 2025)+ * Small fix around parsing of BOZ constants.+ * This version was reviewed for JOSS.+ ### 0.16.3 (Sep 30, 2024) * Store source names for local declarations in .fsmod files. * Constant evaluator now handles real-integer exponent and real-real exponent expression
LICENSE view
@@ -1,7 +1,5 @@ Copyright (c) 2015-2021: Mistral Contrastin, Matthew Danish, Dominic Orchard and Andrew Rice -Additional thanks for contributions from: Anthony Burzillo, Azeem Bande-Ali, Ben Moon, Bradley Hardy, Eric Seidel, Harry Clarke, Jason Xu, Lukasz Kolodziejczyk, Raoul Charman, TravelTissues, Vaibhav Yenamandra and Ben Orchard- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
README.md view
@@ -1,7 +1,9 @@ # fortran-src +[](https://doi.org/10.21105/joss.07571) -Provides lexing/parsing and early static analyses of Fortran code. The following++fortran-src is an open-source Haskell library and command-line application for the lexing, parsing, and static analysis of Fortran source code. It provides an interface to build other tools, e.g., for static analysis, automated refactoring, verification, and compilation. The following Fortran standards are covered: * FORTRAN 66 (ANSI X3.9-1966)@@ -13,13 +15,30 @@ Parsing is configurable, and you can select the Fortran standard to target, including special extended modes for nonstandard FORTRAN 77. -Includes data flow and basic block analysis, a renamer, and type analysis.+Various static analyses are provided including: +* Control-flow analysis (building a super graph) (Language.Fortran.Analysis.BBlocks);+* General data flow analyses (Language.Fortran.Analysis.DataFlow), including:+* Reaching definitions;+* Def-use/use-def;+* Constant evaluation;+* Constant propagation;+* Live variable analysis;+* Induction variable analysis.+* Type analysis (Language.Fortran.Analysis.Types);+* Module graph analysis (Language.Fortran.Analysis.ModGraph);+ This package primarily exports a Haskell library, but also builds an executable-that can be used for testing and debugging. For example usage, see the-[CamFort](https://github.com/camfort/camfort) project, which uses fortran-src as-its front end.+that can be used for testing and debugging. +The library is the basis of the [CamFort verification tool](https://github.com/camfort/camfort).++## Statement of Need++Fortran remains a popular language in the international scientific community. It is not only a mainstay of legacy software, but is also used to write new software. Fortran is particularly notable for its prevalence in earth sciences, e.g., for implementing climate models that inform international policy decisions. In 2024, Fortran re-entered the Top 10 programming languages in the TIOBE Index, showing its enduring popularity. The continued use of Fortran, particularly in scientific contexts, was the catalyst for this software package. A challenge in writing language tools for Fortran is its long history. There have been several major language standards (FORTRAN I-IV, FORTRAN 66 and 77, Fortran 90, 95, 2003, 2008, etc.) Newer standards often deprecate features that are known to be a ready source of errors, or difficult to specify or understand. However, compilers often support an amalgam of features across standards, enabling developers to use deprecated features and mix language standards. This complicates the development of new tools for manipulating Fortran source code; one must tame the weight of decades of language evolution.++Our package, `fortran-src`, provides an open-source unified core for statically analysing Fortran code across language standards, with a focus on legacy code over cutting-edge modern Fortran. It is both a standalone tool and a library, providing a suite of standard static analyses as a basis for further programming language tools and systems.+ ## Obtaining We provide [prebuilt binaries](https://github.com/camfort/fortran-src/releases) for Windows, Mac and Linux.@@ -122,6 +141,16 @@ ``` cabal build+```++You can leverage cabal to initialize a ghci session, and call the main function like such:++```shell+cabal repl++:load app/Main.hs++:main --version ``` ### Testing
app/Main.hs view
@@ -51,7 +51,7 @@ programName = "fortran-src" showVersion :: String-showVersion = "0.16.3"+showVersion = "0.16.5" main :: IO () main = do@@ -118,7 +118,7 @@ Right a -> a outfmt = outputFormat opts mmap = combinedModuleMap mods- tenv = combinedTypeEnv mods+ tenv = stripExtended $ combinedTypeEnv mods pvm = combinedParamVarMap mods let runTypes = analyseAndCheckTypesWithEnv tenv . analyseRenamesWithModuleMap mmap . initAnalysis@@ -143,7 +143,7 @@ Lex -> ioError $ userError $ usageInfo programName options Parse -> pp parsedPF Typecheck -> let (pf, _, errs) = runTypes parsedPF in- printTypeErrors errs >> printTypes (extractTypeEnv pf)+ printTypeErrors errs >> printTypes (extractTypeEnvExtended pf) Rename -> pp $ runRenamer parsedPF BBlocks -> putStrLn $ runBBlocks parsedPF SuperGraph -> putStrLn $ runSuperGraph parsedPF@@ -220,7 +220,7 @@ contents <- flexReadFile path let version = fromMaybe (deduceFortranVersion path) mvers mmap = combinedModuleMap mods- tenv = combinedTypeEnv mods+ tenv = stripExtended $ combinedTypeEnv mods runCompile = genModFile . fst . analyseTypesWithEnv tenv . analyseRenamesWithModuleMap mmap . initAnalysis parsedPF <- case (Parser.byVerWithMods mods version) path contents of@@ -295,12 +295,14 @@ showStringMap = showGenericMap showModuleMap :: ModuleMap -> String showModuleMap = concatMap (\ (n, m) -> show n ++ ":\n" ++ (unlines . map (" "++) . lines . showGenericMap $ m)) . M.toList-showTypes :: TypeEnv -> String+showTypes :: TypeEnvExtended -> String showTypes tenv =- flip concatMap (M.toList tenv) $- \ (name, IDType { idVType = vt, idCType = ct }) ->- printf "%s\t\t%s %s\n" name (drop 1 $ maybe " -" show vt) (drop 2 $ maybe " " show ct)-printTypes :: TypeEnv -> IO ()+ let sortedInfo = sortBy (\(_, (_, sp1, _)) (_, (_, sp2, _)) -> compare sp1 sp2) $ M.toList tenv+ in+ flip concatMap sortedInfo $+ \ (_, (name, sp, IDType { idVType = vt, idCType = ct })) ->+ printf "%s\t %s\t\t%s %s\n" (show $ ssFrom sp) name (drop 1 $ maybe " -" show vt) (drop 2 $ maybe " " show ct)+printTypes :: TypeEnvExtended -> IO () printTypes = putStrLn . showTypes showTypeErrors :: [TypeError] -> String showTypeErrors errs = unlines [ show ss ++ ": " ++ msg | (msg, ss) <- sortBy (comparing snd) errs ]
fortran-src.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.2.+-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack name: fortran-src-version: 0.16.3+version: 0.16.5 synopsis: Parsers and analyses for Fortran standards 66, 77, 90, 95 and 2003 (partial). description: Provides lexing, parsing, and basic analyses of Fortran code covering standards: FORTRAN 66, FORTRAN 77, Fortran 90, Fortran 95, Fortran 2003 (partial) and some legacy extensions. Includes data flow and basic block analysis, a renamer, and type analysis. For example usage, see the @<https://hackage.haskell.org/package/camfort CamFort>@ project, which uses fortran-src as its front end. category: Language@@ -15,8 +15,7 @@ Matthew Danish, Dominic Orchard, Andrew Rice-maintainer: me@madgen.net,- Ben Orchard+maintainer: Dominic Orchard license: Apache-2.0 license-file: LICENSE build-type: Simple
src/Language/Fortran/AST/Literal/Boz.hs view
@@ -95,7 +95,7 @@ | p' == 'x' = Just $ BozPrefixZ Nonconforming | otherwise = Nothing where p' = Char.toLower p- errInvalid = error "Language.Fortran.AST.BOZ.parseBoz: invalid BOZ string"+ errInvalid = error ("Language.Fortran.AST.BOZ.parseBoz: invalid BOZ string: " <> show s) -- | Remove the first and last elements in a list. shave = tail . init
src/Language/Fortran/Analysis/Types.hs view
@@ -2,8 +2,11 @@ ( analyseTypes , analyseTypesWithEnv , analyseAndCheckTypesWithEnv+ , stripExtended , extractTypeEnv+ , extractTypeEnvExtended , TypeEnv+ , TypeEnvExtended , TypeError , deriveSemTypeFromDeclaration , deriveSemTypeFromTypeSpec@@ -36,7 +39,12 @@ -- | Mapping of names to type information. type TypeEnv = M.Map Name IDType+-- | Mapping of names to type information with more information about the source+type TypeEnvExtended = M.Map Name (Name, SrcSpan, IDType) +stripExtended :: TypeEnvExtended -> TypeEnv+stripExtended = M.map (\(_, _, t) -> t)+ -- | Information about a detected type error. type TypeError = (String, SrcSpan) @@ -120,6 +128,24 @@ expEnv = M.fromList [ (n, ty) | e@(ExpValue _ _ ValVariable{}) <- universeBi pf :: [Expression (Analysis a)] , let n = varName e , ty <- maybeToList (idType (getAnnotation e)) ]++extractTypeEnvExtended :: forall a. Data a => ProgramFile (Analysis a) -> TypeEnvExtended+extractTypeEnvExtended pf = M.union puEnv expEnv+ where+ puEnv = M.fromList [ (n, (srcName, getSpan pu, ty)) | pu <- universeBi pf :: [ProgramUnit (Analysis a)]+ , Named n <- [puName pu]+ , Named srcName <- [puSrcName pu]+ , ty <- maybeToList (idType (getAnnotation pu)) ]+ expEnv = M.fromList [ (n, (srcName e, sp, ty)) | e@(ExpValue _ _ ValVariable{}) <- universeBi pf :: [Expression (Analysis a)]+ , let n = varName e+ , sp <- getDeclarator n+ , ty <- maybeToList (idType (getAnnotation e)) ]+ getDeclarator v' =+ [ sp | d@(Declarator _ sp ev _ _ _) <- universeBi pf :: [Declarator (Analysis a)]+ , varName ev == v' ]+++ type TransType f g a = (f (Analysis a) -> Infer (f (Analysis a))) -> g (Analysis a) -> Infer (g (Analysis a)) annotateTypes :: Data a => ProgramFile (Analysis a) -> Infer (ProgramFile (Analysis a))
src/Language/Fortran/Parser/Fixed/Lexer.x view
@@ -30,7 +30,7 @@ import Language.Fortran.Version import Language.Fortran.Util.FirstParameter import Language.Fortran.Util.Position-import Language.Fortran.Parser.LexerUtils ( readIntOrBoz )+import Language.Fortran.Parser.LexerUtils ( readIntOrBoz, unescapeSpecialChars ) import Language.Fortran.AST.Literal.Boz }@@ -1128,7 +1128,7 @@ AlexEOF -> return $ TEOF $ SrcSpan (getPos alexInput) (getPos alexInput) AlexError _ -> do parseState <- get- fail $ psFilename parseState ++ " - lexing failed: " ++ show (psAlexInput parseState)+ fail $ psFilename parseState ++ " - lexing failed: " ++ (unescapeSpecialChars $ show (psAlexInput parseState)) AlexSkip newAlex _ -> putAlex newAlex >> lexer' AlexToken newAlex _ action -> do putAlex newAlex
src/Language/Fortran/Parser/Free/Fortran2003.y view
@@ -583,9 +583,9 @@ | save { StSave () (getSpan $1) Nothing } -- according to IBM F2003 docs, dcolon is always required-| procedure '(' MAYBE_PROC_INTERFACE ')' ATTRIBUTE_LIST '::' PROC_DECLS+| procedure '(' MAYBE_PROC_INTERFACE ')' MAYBE_ATTRIBUTE_LIST '::' PROC_DECLS { let declAList = fromReverseList $7- in StProcedure () (getTransSpan $1 $7) $3 (Just (fromReverseList $5)) declAList }+ in StProcedure () (getTransSpan $1 $7) $3 $5 declAList } | dimension MAYBE_DCOLON INITIALIZED_DECLARATOR_LIST { let declAList = fromReverseList $3@@ -1037,6 +1037,14 @@ | TYPE_SPEC INITIALIZED_DECLARATOR_LIST { let { declAList = fromReverseList $2 } in StDeclaration () (getTransSpan $1 declAList) $1 Nothing declAList }++MAYBE_ATTRIBUTE_LIST :: { Maybe (AList Attribute A0) }+: ',' NE_ATTRIBUTE_LIST { Just $ fromReverseList $2 }+| {- EMPTY -} { Nothing }++NE_ATTRIBUTE_LIST :: { [ Attribute A0 ] }+: NE_ATTRIBUTE_LIST ',' ATTRIBUTE_SPEC { $3 : $1 }+| ATTRIBUTE_SPEC { [ $1 ] } ATTRIBUTE_LIST :: { [ Attribute A0 ] } : ATTRIBUTE_LIST ',' ATTRIBUTE_SPEC { $3 : $1 }
src/Language/Fortran/Parser/Free/Lexer.x view
@@ -1105,20 +1105,28 @@ processLinePragma :: String -> AlexInput -> AlexInput processLinePragma m ai =- case dropWhile ((`elem` ["#", "line", "#line"]) . map toLower) (words m) of- -- 'line' pragma - rewrite the current line and filename- lineStr:otherWords- | line <- readIntOrBoz lineStr -> do- let revdropWNQ = reverse . drop 1 . dropWhile (flip notElem "'\"")- let file = revdropWNQ . revdropWNQ $ unwords otherWords- -- if a newline is present, then the aiPosition is already on the next line- let maybe1 | elem '\n' m = 0 | otherwise = 1- -- lineOffs is the difference between the given line and the current next line- let lineOffs = fromIntegral line - (posLine (aiPosition ai) + maybe1)- let newP = (aiPosition ai) { posPragmaOffset = Just (lineOffs, file)- , posColumn = 1 }- ai { aiPosition = newP }- _ -> ai+ let wordsm = words m+ isLinePragma x = x `elem` ["#", "line", "#line"]+ in -- If this is a line pragma then process this+ if length wordsm > 0 && isLinePragma (head wordsm)+ || (length wordsm > 1 && isLinePragma (head (tail wordsm)))+ then+ case dropWhile ((`elem` ["#", "line", "#line"]) . map toLower) wordsm of+ -- 'line' pragma - rewrite the current line and filename+ lineStr:otherWords+ | line <- readIntOrBoz lineStr -> do+ let revdropWNQ = reverse . drop 1 . dropWhile (flip notElem "'\"")+ let file = revdropWNQ . revdropWNQ $ unwords otherWords+ -- if a newline is present, then the aiPosition is already on the next line+ let maybe1 | elem '\n' m = 0 | otherwise = 1+ -- lineOffs is the difference between the given line and the current next line+ let lineOffs = fromIntegral line - (posLine (aiPosition ai) + maybe1)+ let newP = (aiPosition ai) { posPragmaOffset = Just (lineOffs, file)+ , posColumn = 1 }+ ai { aiPosition = newP }+ _ -> ai+ -- Otherwise this is probably a CPP directive or some other pragma so ignore+ else ai -- Handle pragmas that begin with # lexHash :: LexAction (Maybe Token)
src/Language/Fortran/Parser/LexerUtils.hs view
@@ -1,5 +1,5 @@ {-| Utils for both lexers. -}-module Language.Fortran.Parser.LexerUtils ( readIntOrBoz ) where+module Language.Fortran.Parser.LexerUtils ( readIntOrBoz, unescapeSpecialChars) where import Language.Fortran.AST.Literal.Boz import Numeric@@ -16,3 +16,17 @@ readSToMaybe :: [(a, b)] -> Maybe a readSToMaybe = \case (x, _):_ -> Just x _ -> Nothing+++-- | Pretty prints exception message that contains things like carriage return, indents, etc.+unescapeSpecialChars :: String -> String+unescapeSpecialChars [] = []+unescapeSpecialChars ('\\' : c : rest) =+ case c of+ 'n' -> '\n' : unescapeSpecialChars rest+ 't' -> '\t' : unescapeSpecialChars rest+ 'r' -> '\r' : unescapeSpecialChars rest+ '\\' -> '\\' : unescapeSpecialChars rest+ _ -> '\\' : c : unescapeSpecialChars rest+unescapeSpecialChars (c : rest) =+ c : unescapeSpecialChars rest
src/Language/Fortran/Transformation/Monad.hs view
@@ -9,6 +9,7 @@ import Prelude hiding (lookup) import Control.Monad.State.Lazy hiding (state) import Data.Data+import qualified Data.Map as M import Language.Fortran.Analysis import Language.Fortran.Analysis.Types@@ -22,13 +23,14 @@ runTransform :: Data a- => TypeEnv -> ModuleMap -> Transform a () -> ProgramFile a -> ProgramFile a+ => TypeEnvExtended -> ModuleMap -> Transform a () -> ProgramFile a -> ProgramFile a runTransform env mmap trans pf = stripAnalysis . transProgramFile . execState trans $ initState where- (pf', _) = analyseTypesWithEnv env . analyseRenamesWithModuleMap mmap . initAnalysis $ pf+ (pf', _) = analyseTypesWithEnv (removeExtendedInfo env) . analyseRenamesWithModuleMap mmap . initAnalysis $ pf initState = TransformationState { transProgramFile = pf' }+ removeExtendedInfo = M.map (\(_, _, t) -> t) getProgramFile :: Transform a (ProgramFile (Analysis a)) getProgramFile = gets transProgramFile
src/Language/Fortran/Util/ModFile.hs view
@@ -120,7 +120,7 @@ , mfStringMap :: StringMap , mfModuleMap :: FAR.ModuleMap , mfDeclMap :: DeclMap- , mfTypeEnv :: FAT.TypeEnv+ , mfTypeEnv :: FAT.TypeEnvExtended , mfParamVarMap :: ParamVarMap , mfOtherData :: M.Map String LB.ByteString }@@ -145,7 +145,7 @@ regenModFile :: forall a. (Data a) => F.ProgramFile (FA.Analysis a) -> ModFile -> ModFile regenModFile pf mf = mf { mfModuleMap = extractModuleMap pf , mfDeclMap = extractDeclMap pf- , mfTypeEnv = FAT.extractTypeEnv pf+ , mfTypeEnv = FAT.extractTypeEnvExtended pf , mfParamVarMap = extractParamVarMap pf , mfFilename = F.pfGetFilename pf } @@ -227,7 +227,7 @@ -- | Extract the combined module map from a set of ModFiles. Useful -- for parsing a Fortran file in a large context of other modules.-combinedTypeEnv :: ModFiles -> FAT.TypeEnv+combinedTypeEnv :: ModFiles -> FAT.TypeEnvExtended combinedTypeEnv = M.unions . map mfTypeEnv -- | Extract the combined declaration map from a set of
src/Language/Fortran/Util/Position.hs view
@@ -26,7 +26,10 @@ instance NFData Position instance Show Position where- show (Position _ c l _ _) = show l ++ ':' : show c+ -- Column number decrement by 1 as the lexer generates column numbers+ -- starting at position 1+ -- See PR https://github.com/camfort/fortran-src/pull/292+ show (Position _ c l _ _) = show l ++ ':' : show (c - 1) initPosition :: Position initPosition = Position
test/Language/Fortran/Parser/Free/Fortran2003Spec.hs view
@@ -56,6 +56,13 @@ st = StUse () u (varGen "mod") Nothing Permissive (Just renames) sParser "use :: mod, sprod => prod, a => b" `shouldBe'` st + it "parses simple procedure with no args" $ do+ let st = StProcedure () u (Just (ProcInterfaceName () u (varGen "name")))+ Nothing+ (AList () u [ProcDecl () u (varGen "other_name") Nothing] )+ sParser "procedure(name) :: other_name" `shouldBe'` st++ it "parses procedure (interface-name, attribute, proc-decl)" $ do let call = ExpFunctionCall () u (varGen "c") (aEmpty () u) st = StProcedure () u (Just (ProcInterfaceName () u (varGen "a")))