Safe Haskell | None |
---|---|
Language | Haskell2010 |
Language.Fortran.AST
Description
This module holds the data types used to represent Fortran code of various versions.
fortran-src supports Fortran 66 through to Fortran 2003, and uses the same types to represent them. The Fortran standard was largely refined as it grew, often assimilating popular compiler extensions for the previous standard. We try to be as permissible as reasonable when parsing; similarly, this AST keeps close to the syntax, and includes statements, expressions, types etc. only applicable to certain (newer) versions of Fortran.
Useful Fortran standard references:
- Fortran 77 ANSI standard: ANSI X3.9-1978
- Fortran 90 ANSI standard: ANSI X3.198-1992 (also ISO/IEC 1539:1991)
- Fortran 90 Handbook (J. Adams)
(The Fortran 66 ANSI standard lacks detail, and isn't as useful as the later standards for implementing the language.)
Note: some comments aren't reflected in the Haddock documentation, so you may also wish to view this file's source.
Synopsis
- data ProgramFile a = ProgramFile MetaInfo [ProgramUnit a]
- data ProgramUnit a
- = PUMain a SrcSpan (Maybe Name) [Block a] (Maybe [ProgramUnit a])
- | PUModule a SrcSpan Name [Block a] (Maybe [ProgramUnit a])
- | PUSubroutine a SrcSpan (PrefixSuffix a) Name (Maybe (AList Expression a)) [Block a] (Maybe [ProgramUnit a])
- | PUFunction a SrcSpan (Maybe (TypeSpec a)) (PrefixSuffix a) Name (Maybe (AList Expression a)) (Maybe (Expression a)) [Block a] (Maybe [ProgramUnit a])
- | PUBlockData a SrcSpan (Maybe Name) [Block a]
- | PUComment a SrcSpan (Comment a)
- data Block a
- = BlStatement a SrcSpan (Maybe (Expression a)) (Statement a)
- | BlForall a SrcSpan (Maybe (Expression a)) (Maybe String) (ForallHeader a) [Block a] (Maybe (Expression a))
- | BlIf a SrcSpan (Maybe (Expression a)) (Maybe String) [Maybe (Expression a)] [[Block a]] (Maybe (Expression a))
- | BlCase a SrcSpan (Maybe (Expression a)) (Maybe String) (Expression a) [Maybe (AList Index a)] [[Block a]] (Maybe (Expression a))
- | BlDo a SrcSpan (Maybe (Expression a)) (Maybe String) (Maybe (Expression a)) (Maybe (DoSpecification a)) [Block a] (Maybe (Expression a))
- | BlDoWhile a SrcSpan (Maybe (Expression a)) (Maybe String) (Maybe (Expression a)) (Expression a) [Block a] (Maybe (Expression a))
- | BlAssociate a SrcSpan (Maybe (Expression a)) (Maybe String) (AList (ATuple Expression Expression) a) [Block a] (Maybe (Expression a))
- | BlInterface a SrcSpan (Maybe (Expression a)) Bool [ProgramUnit a] [Block a]
- | BlComment a SrcSpan (Comment a)
- data Statement a
- = StDeclaration a SrcSpan (TypeSpec a) (Maybe (AList Attribute a)) (AList Declarator a)
- | StStructure a SrcSpan (Maybe String) (AList StructureItem a)
- | StIntent a SrcSpan Intent (AList Expression a)
- | StOptional a SrcSpan (AList Expression a)
- | StPublic a SrcSpan (Maybe (AList Expression a))
- | StPrivate a SrcSpan (Maybe (AList Expression a))
- | StProtected a SrcSpan (Maybe (AList Expression a))
- | StSave a SrcSpan (Maybe (AList Expression a))
- | StDimension a SrcSpan (AList Declarator a)
- | StAllocatable a SrcSpan (AList Declarator a)
- | StAsynchronous a SrcSpan (AList Declarator a)
- | StPointer a SrcSpan (AList Declarator a)
- | StTarget a SrcSpan (AList Declarator a)
- | StValue a SrcSpan (AList Declarator a)
- | StVolatile a SrcSpan (AList Declarator a)
- | StData a SrcSpan (AList DataGroup a)
- | StAutomatic a SrcSpan (AList Declarator a)
- | StStatic a SrcSpan (AList Declarator a)
- | StNamelist a SrcSpan (AList Namelist a)
- | StParameter a SrcSpan (AList Declarator a)
- | StExternal a SrcSpan (AList Expression a)
- | StIntrinsic a SrcSpan (AList Expression a)
- | StCommon a SrcSpan (AList CommonGroup a)
- | StEquivalence a SrcSpan (AList (AList Expression) a)
- | StFormat a SrcSpan (AList FormatItem a)
- | StImplicit a SrcSpan (Maybe (AList ImpList a))
- | StEntry a SrcSpan (Expression a) (Maybe (AList Expression a)) (Maybe (Expression a))
- | StInclude a SrcSpan (Expression a) (Maybe [Block a])
- | StDo a SrcSpan (Maybe String) (Maybe (Expression a)) (Maybe (DoSpecification a))
- | StDoWhile a SrcSpan (Maybe String) (Maybe (Expression a)) (Expression a)
- | StEnddo a SrcSpan (Maybe String)
- | StCycle a SrcSpan (Maybe (Expression a))
- | StExit a SrcSpan (Maybe (Expression a))
- | StIfLogical a SrcSpan (Expression a) (Statement a)
- | StIfArithmetic a SrcSpan (Expression a) (Expression a) (Expression a) (Expression a)
- | StSelectCase a SrcSpan (Maybe String) (Expression a)
- | StCase a SrcSpan (Maybe String) (Maybe (AList Index a))
- | StEndcase a SrcSpan (Maybe String)
- | StFunction a SrcSpan (Expression a) (AList Expression a) (Expression a)
- | StExpressionAssign a SrcSpan (Expression a) (Expression a)
- | StPointerAssign a SrcSpan (Expression a) (Expression a)
- | StLabelAssign a SrcSpan (Expression a) (Expression a)
- | StGotoUnconditional a SrcSpan (Expression a)
- | StGotoAssigned a SrcSpan (Expression a) (Maybe (AList Expression a))
- | StGotoComputed a SrcSpan (AList Expression a) (Expression a)
- | StCall a SrcSpan (Expression a) (Maybe (AList Argument a))
- | StReturn a SrcSpan (Maybe (Expression a))
- | StContinue a SrcSpan
- | StStop a SrcSpan (Maybe (Expression a))
- | StPause a SrcSpan (Maybe (Expression a))
- | StRead a SrcSpan (AList ControlPair a) (Maybe (AList Expression a))
- | StRead2 a SrcSpan (Expression a) (Maybe (AList Expression a))
- | StWrite a SrcSpan (AList ControlPair a) (Maybe (AList Expression a))
- | StPrint a SrcSpan (Expression a) (Maybe (AList Expression a))
- | StTypePrint a SrcSpan (Expression a) (Maybe (AList Expression a))
- | StOpen a SrcSpan (AList ControlPair a)
- | StClose a SrcSpan (AList ControlPair a)
- | StFlush a SrcSpan (AList FlushSpec a)
- | StInquire a SrcSpan (AList ControlPair a)
- | StRewind a SrcSpan (AList ControlPair a)
- | StRewind2 a SrcSpan (Expression a)
- | StBackspace a SrcSpan (AList ControlPair a)
- | StBackspace2 a SrcSpan (Expression a)
- | StEndfile a SrcSpan (AList ControlPair a)
- | StEndfile2 a SrcSpan (Expression a)
- | StAllocate a SrcSpan (Maybe (TypeSpec a)) (AList Expression a) (Maybe (AList AllocOpt a))
- | StNullify a SrcSpan (AList Expression a)
- | StDeallocate a SrcSpan (AList Expression a) (Maybe (AList AllocOpt a))
- | StWhere a SrcSpan (Expression a) (Statement a)
- | StWhereConstruct a SrcSpan (Maybe String) (Expression a)
- | StElsewhere a SrcSpan (Maybe String) (Maybe (Expression a))
- | StEndWhere a SrcSpan (Maybe String)
- | StUse a SrcSpan (Expression a) (Maybe ModuleNature) Only (Maybe (AList Use a))
- | StModuleProcedure a SrcSpan (AList Expression a)
- | StProcedure a SrcSpan (Maybe (ProcInterface a)) (Maybe (Attribute a)) (AList ProcDecl a)
- | StType a SrcSpan (Maybe (AList Attribute a)) String
- | StEndType a SrcSpan (Maybe String)
- | StSequence a SrcSpan
- | StForall a SrcSpan (Maybe String) (ForallHeader a)
- | StForallStatement a SrcSpan (ForallHeader a) (Statement a)
- | StEndForall a SrcSpan (Maybe String)
- | StImport a SrcSpan (AList Expression a)
- | StEnum a SrcSpan
- | StEnumerator a SrcSpan (AList Declarator a)
- | StEndEnum a SrcSpan
- | StFormatBogus a SrcSpan String
- data Expression a
- = ExpValue a SrcSpan (Value a)
- | ExpBinary a SrcSpan BinaryOp (Expression a) (Expression a)
- | ExpUnary a SrcSpan UnaryOp (Expression a)
- | ExpSubscript a SrcSpan (Expression a) (AList Index a)
- | ExpDataRef a SrcSpan (Expression a) (Expression a)
- | ExpFunctionCall a SrcSpan (Expression a) (Maybe (AList Argument a))
- | ExpImpliedDo a SrcSpan (AList Expression a) (DoSpecification a)
- | ExpInitialisation a SrcSpan (AList Expression a)
- | ExpReturnSpec a SrcSpan (Expression a)
- data Index a
- = IxSingle a SrcSpan (Maybe String) (Expression a)
- | IxRange a SrcSpan (Maybe (Expression a)) (Maybe (Expression a)) (Maybe (Expression a))
- data Value a
- = ValInteger String (Maybe (Expression a))
- | ValReal RealLit (Maybe (Expression a))
- | ValComplex (Expression a) (Expression a)
- | ValString String
- | ValBoz Boz
- | ValHollerith String
- | ValVariable Name
- | ValIntrinsic Name
- | ValLogical Bool (Maybe (Expression a))
- | ValOperator String
- | ValAssignment
- | ValType String
- | ValStar
- | ValColon
- data UnaryOp
- data BinaryOp
- = Addition
- | Subtraction
- | Multiplication
- | Division
- | Exponentiation
- | Concatenation
- | GT
- | GTE
- | LT
- | LTE
- | EQ
- | NE
- | Or
- | XOr
- | And
- | Equivalent
- | NotEquivalent
- | BinCustom String
- type Name = String
- data BaseType
- data TypeSpec a = TypeSpec a SrcSpan BaseType (Maybe (Selector a))
- data Selector a = Selector a SrcSpan (Maybe (Expression a)) (Maybe (Expression a))
- data Declarator a = Declarator a SrcSpan (Expression a) (DeclaratorType a) (Maybe (Expression a)) (Maybe (Expression a))
- data DeclaratorType a
- declaratorType :: Declarator a -> DeclaratorType a
- data DimensionDeclarator a = DimensionDeclarator a SrcSpan (Maybe (Expression a)) (Maybe (Expression a))
- module Language.Fortran.AST.AList
- data Attribute a
- = AttrAllocatable a SrcSpan
- | AttrAsynchronous a SrcSpan
- | AttrDimension a SrcSpan (AList DimensionDeclarator a)
- | AttrExternal a SrcSpan
- | AttrIntent a SrcSpan Intent
- | AttrIntrinsic a SrcSpan
- | AttrOptional a SrcSpan
- | AttrParameter a SrcSpan
- | AttrPointer a SrcSpan
- | AttrPrivate a SrcSpan
- | AttrProtected a SrcSpan
- | AttrPublic a SrcSpan
- | AttrSave a SrcSpan
- | AttrSuffix a SrcSpan (Suffix a)
- | AttrTarget a SrcSpan
- | AttrValue a SrcSpan
- | AttrVolatile a SrcSpan
- data Prefix a
- = PfxRecursive a SrcSpan
- | PfxElemental a SrcSpan
- | PfxPure a SrcSpan
- data Suffix a = SfxBind a SrcSpan (Maybe (Expression a))
- data ProcDecl a = ProcDecl a SrcSpan (Expression a) (Maybe (Expression a))
- data ProcInterface a
- = ProcInterfaceName a SrcSpan (Expression a)
- | ProcInterfaceType a SrcSpan (TypeSpec a)
- newtype Comment a = Comment String
- data ForallHeader a = ForallHeader [(Name, Expression a, Expression a, Maybe (Expression a))] (Maybe (Expression a))
- data Only
- data MetaInfo = MetaInfo {}
- type Prefixes a = Maybe (AList Prefix a)
- type Suffixes a = Maybe (AList Suffix a)
- type PrefixSuffix a = (Prefixes a, Suffixes a)
- data ModuleNature
- data Use a
- = UseRename a SrcSpan (Expression a) (Expression a)
- | UseID a SrcSpan (Expression a)
- data Argument a = Argument a SrcSpan (Maybe String) (Expression a)
- data Intent
- data ControlPair a = ControlPair a SrcSpan (Maybe String) (Expression a)
- data AllocOpt a
- = AOStat a SrcSpan (Expression a)
- | AOErrMsg a SrcSpan (Expression a)
- | AOSource a SrcSpan (Expression a)
- data ImpList a = ImpList a SrcSpan (TypeSpec a) (AList ImpElement a)
- data ImpElement a
- data CommonGroup a = CommonGroup a SrcSpan (Maybe (Expression a)) (AList Declarator a)
- data Namelist a = Namelist a SrcSpan (Expression a) (AList Expression a)
- data DataGroup a = DataGroup a SrcSpan (AList Expression a) (AList Expression a)
- data StructureItem a
- = StructFields a SrcSpan (TypeSpec a) (Maybe (AList Attribute a)) (AList Declarator a)
- | StructUnion a SrcSpan (AList UnionMap a)
- | StructStructure a SrcSpan (Maybe String) String (AList StructureItem a)
- data UnionMap a = UnionMap a SrcSpan (AList StructureItem a)
- data FormatItem a
- = FIFormatList a SrcSpan (Maybe String) (AList FormatItem a)
- | FIHollerith a SrcSpan (Value a)
- | FIDelimiter a SrcSpan
- | FIFieldDescriptorDEFG a SrcSpan (Maybe Integer) Char Integer Integer
- | FIFieldDescriptorAIL a SrcSpan (Maybe Integer) Char Integer
- | FIBlankDescriptor a SrcSpan Integer
- | FIScaleFactor a SrcSpan Integer
- data FlushSpec a
- = FSUnit a SrcSpan (Expression a)
- | FSIOStat a SrcSpan (Expression a)
- | FSIOMsg a SrcSpan (Expression a)
- | FSErr a SrcSpan (Expression a)
- data DoSpecification a = DoSpecification a SrcSpan (Statement a) (Expression a) (Maybe (Expression a))
- data ProgramUnitName
- type Kind = Int
- type A0 = ()
- class Annotated f where
- getAnnotation :: f a -> a
- setAnnotation :: a -> f a -> f a
- modifyAnnotation :: (a -> a) -> f a -> f a
- class Labeled f where
- getLabel :: f a -> Maybe (Expression a)
- getLastLabel :: f a -> Maybe (Expression a)
- setLabel :: f a -> Expression a -> f a
- class Named a where
- getName :: a -> ProgramUnitName
- setName :: ProgramUnitName -> a -> a
- validPrefixSuffix :: PrefixSuffix a -> Bool
- emptyPrefixes :: Prefixes a
- emptySuffixes :: Suffixes a
- emptyPrefixSuffix :: PrefixSuffix a
- nonExecutableStatement :: FortranVersion -> Statement a -> Bool
- nonExecutableStatementBlock :: FortranVersion -> Block a -> Bool
- executableStatement :: FortranVersion -> Statement a -> Bool
- executableStatementBlock :: FortranVersion -> Block a -> Bool
- setInitialisation :: Declarator a -> Expression a -> Declarator a
- pfSetFilename :: String -> ProgramFile a -> ProgramFile a
- pfGetFilename :: ProgramFile a -> String
- programUnitBody :: ProgramUnit a -> [Block a]
- updateProgramUnitBody :: ProgramUnit a -> [Block a] -> ProgramUnit a
- programUnitSubprograms :: ProgramUnit a -> Maybe [ProgramUnit a]
AST nodes and types
Statements and expressions
data ProgramFile a Source #
Constructors
ProgramFile MetaInfo [ProgramUnit a] |
Instances
data ProgramUnit a Source #
Constructors
PUMain a SrcSpan (Maybe Name) [Block a] (Maybe [ProgramUnit a]) | |
PUModule a SrcSpan Name [Block a] (Maybe [ProgramUnit a]) | |
PUSubroutine a SrcSpan (PrefixSuffix a) Name (Maybe (AList Expression a)) [Block a] (Maybe [ProgramUnit a]) | |
PUFunction a SrcSpan (Maybe (TypeSpec a)) (PrefixSuffix a) Name (Maybe (AList Expression a)) (Maybe (Expression a)) [Block a] (Maybe [ProgramUnit a]) | |
PUBlockData a SrcSpan (Maybe Name) [Block a] | |
PUComment a SrcSpan (Comment a) |
Instances
Constructors
BlStatement | |
Fields
| |
BlForall | |
Fields
| |
BlIf | |
Fields
| |
BlCase | |
Fields
| |
BlDo | |
Fields
| |
BlDoWhile | |
Fields
| |
BlAssociate a SrcSpan (Maybe (Expression a)) (Maybe String) (AList (ATuple Expression Expression) a) [Block a] (Maybe (Expression a)) | The first |
BlInterface | |
Fields
| |
BlComment a SrcSpan (Comment a) |
Instances
Constructors
Instances
data Expression a Source #
Constructors
ExpValue a SrcSpan (Value a) | Use a value as an expression. |
ExpBinary a SrcSpan BinaryOp (Expression a) (Expression a) | A binary operator applied to two expressions. |
ExpUnary a SrcSpan UnaryOp (Expression a) | A unary operator applied to one expression. |
ExpSubscript a SrcSpan (Expression a) (AList Index a) | Array indexing |
ExpDataRef a SrcSpan (Expression a) (Expression a) |
|
ExpFunctionCall a SrcSpan (Expression a) (Maybe (AList Argument a)) | A function expression applied to a list of arguments. |
ExpImpliedDo a SrcSpan (AList Expression a) (DoSpecification a) | Implied do (i.e. one-liner do loops) |
ExpInitialisation a SrcSpan (AList Expression a) | Array initialisation |
ExpReturnSpec a SrcSpan (Expression a) | Function return value specification |
Instances
Constructors
IxSingle a SrcSpan (Maybe String) (Expression a) | |
IxRange | |
Fields
|
Instances
Constructors
ValInteger String (Maybe (Expression a)) | The string representation of an integer literal |
ValReal RealLit (Maybe (Expression a)) | The string representation of a real literal |
ValComplex (Expression a) (Expression a) | The real and imaginary parts of a complex value |
ValString String | A string literal |
ValBoz Boz | A BOZ literal constant |
ValHollerith String | A Hollerith literal |
ValVariable Name | The name of a variable |
ValIntrinsic Name | The name of a built-in function |
ValLogical Bool (Maybe (Expression a)) | A boolean value |
ValOperator String | User-defined operators in interfaces |
ValAssignment | Overloaded assignment in interfaces |
ValType String | |
ValStar | |
ValColon |
Instances
Instances
Eq UnaryOp Source # | |
Data UnaryOp Source # | |
Defined in Language.Fortran.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UnaryOp -> c UnaryOp # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UnaryOp # toConstr :: UnaryOp -> Constr # dataTypeOf :: UnaryOp -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UnaryOp) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnaryOp) # gmapT :: (forall b. Data b => b -> b) -> UnaryOp -> UnaryOp # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UnaryOp -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UnaryOp -> r # gmapQ :: (forall d. Data d => d -> u) -> UnaryOp -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UnaryOp -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp # | |
Ord UnaryOp Source # | |
Defined in Language.Fortran.AST | |
Show UnaryOp Source # | |
Generic UnaryOp Source # | |
Out UnaryOp Source # | |
Binary UnaryOp Source # | |
NFData UnaryOp Source # | |
Defined in Language.Fortran.AST | |
Pretty UnaryOp Source # | |
Defined in Language.Fortran.PrettyPrint | |
type Rep UnaryOp Source # | |
Defined in Language.Fortran.AST type Rep UnaryOp = D1 ('MetaData "UnaryOp" "Language.Fortran.AST" "fortran-src-0.8.0-inplace" 'False) ((C1 ('MetaCons "Plus" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Minus" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Not" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "UnCustom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))) |
Constructors
Addition | |
Subtraction | |
Multiplication | |
Division | |
Exponentiation | |
Concatenation | |
GT | |
GTE | |
LT | |
LTE | |
EQ | |
NE | |
Or | |
XOr | |
And | |
Equivalent | |
NotEquivalent | |
BinCustom String |
Instances
Eq BinaryOp Source # | |
Data BinaryOp Source # | |
Defined in Language.Fortran.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BinaryOp -> c BinaryOp # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BinaryOp # toConstr :: BinaryOp -> Constr # dataTypeOf :: BinaryOp -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BinaryOp) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinaryOp) # gmapT :: (forall b. Data b => b -> b) -> BinaryOp -> BinaryOp # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BinaryOp -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BinaryOp -> r # gmapQ :: (forall d. Data d => d -> u) -> BinaryOp -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BinaryOp -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp # | |
Ord BinaryOp Source # | |
Defined in Language.Fortran.AST | |
Show BinaryOp Source # | |
Generic BinaryOp Source # | |
Out BinaryOp Source # | |
Binary BinaryOp Source # | |
NFData BinaryOp Source # | |
Defined in Language.Fortran.AST | |
Pretty BinaryOp Source # | |
Defined in Language.Fortran.PrettyPrint | |
type Rep BinaryOp Source # | |
Defined in Language.Fortran.AST type Rep BinaryOp = D1 ('MetaData "BinaryOp" "Language.Fortran.AST" "fortran-src-0.8.0-inplace" 'False) ((((C1 ('MetaCons "Addition" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Subtraction" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Multiplication" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Division" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Exponentiation" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Concatenation" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "GT" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "GTE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LT" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "LTE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EQ" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Or" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "XOr" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "And" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Equivalent" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NotEquivalent" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BinCustom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))))))) |
Types and declarations
Type name referenced in syntax.
In many Fortran specs and compilers, certain types are actually "synonyms" for other types with specified kinds. The primary example is DOUBLE PRECISION being equivalent to REAL(8). Type kinds were introduced in Fortran 90, and it should be safe to replace all instances of DOUBLE PRECISION with REAL(8) in Fortran 90 code. However, type kinds weren't present in (standard) Fortran 77, so this equivalence was detached from the user.
In any case, it's unclear how strong the equivalence is and whether it can
be retroactively applied to previous standards. We choose to parse types
directly, and handle those transformations during type analysis, where we
assign most scalars a kind (see SemType
).
Constructors
TypeInteger | |
TypeReal | |
TypeDoublePrecision | |
TypeComplex | |
TypeDoubleComplex | |
TypeLogical | |
TypeCharacter | |
TypeCustom String | |
ClassStar | |
ClassCustom String | |
TypeByte |
Instances
Eq BaseType Source # | |
Data BaseType Source # | |
Defined in Language.Fortran.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BaseType -> c BaseType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BaseType # toConstr :: BaseType -> Constr # dataTypeOf :: BaseType -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BaseType) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BaseType) # gmapT :: (forall b. Data b => b -> b) -> BaseType -> BaseType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BaseType -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BaseType -> r # gmapQ :: (forall d. Data d => d -> u) -> BaseType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BaseType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BaseType -> m BaseType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BaseType -> m BaseType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BaseType -> m BaseType # | |
Ord BaseType Source # | |
Defined in Language.Fortran.AST | |
Show BaseType Source # | |
Generic BaseType Source # | |
Out BaseType Source # | |
Binary BaseType Source # | |
NFData BaseType Source # | |
Defined in Language.Fortran.AST | |
Pretty BaseType Source # | |
Defined in Language.Fortran.PrettyPrint | |
type Rep BaseType Source # | |
Defined in Language.Fortran.AST type Rep BaseType = D1 ('MetaData "BaseType" "Language.Fortran.AST" "fortran-src-0.8.0-inplace" 'False) (((C1 ('MetaCons "TypeInteger" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TypeReal" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TypeDoublePrecision" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TypeComplex" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TypeDoubleComplex" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "TypeLogical" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TypeCharacter" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TypeCustom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))) :+: (C1 ('MetaCons "ClassStar" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ClassCustom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "TypeByte" 'PrefixI 'False) (U1 :: Type -> Type))))) |
The type specification of a declaration statement, containing the syntactic type name and kind selector.
See HP's F90 spec pg.24.
Instances
The "kind selector" of a declaration statement.
HP's F90 spec (pg.24) actually differentiates between "kind selectors" and
"char selectors", where char selectors can specify a length (alongside kind),
and the default meaning of an unlabelled kind parameter (the 8 in INTEGER(8))
is length instead of kind. We handle this correctly in the parsers, but place
both into this Selector
type.
The upshot is, length is invalid for non-CHARACTER types, and the parser guarantees that it will be Nothing. For CHARACTER types, both maybe or may not be present.
Constructors
Selector | |
Fields
|
Instances
data Declarator a Source #
Declarators. R505 entity-decl from F90 ISO spec.
Declaration statements can have multiple variables on the right of the double
colon, separated by commas. A Declarator
identifies a single one of these.
In F90, they look like this:
VAR_NAME ( OPT_ARRAY_DIMS ) * CHAR_LENGTH_EXPR = INIT_EXPR
F77 doesn't standardize so nicely -- in particular, I'm not confident in initializing expression syntax. So no example.
Only CHARACTERs may specify a length. However, a nonstandard syntax feature uses non-CHARACTER lengths as a kind parameter. We parse regardless of type and warn during analysis.
Constructors
Declarator | |
Fields
|
Instances
data DeclaratorType a Source #
Constructors
ScalarDecl | |
ArrayDecl (AList DimensionDeclarator a) |
Instances
declaratorType :: Declarator a -> DeclaratorType a Source #
data DimensionDeclarator a Source #
Dimension declarator stored in dimension
attributes and Declarator
s.
Constructors
DimensionDeclarator a SrcSpan (Maybe (Expression a)) (Maybe (Expression a)) |
Instances
Annotated node list (re-export)
module Language.Fortran.AST.AList
Other
Constructors
Instances
Constructors
PfxRecursive a SrcSpan | |
PfxElemental a SrcSpan | |
PfxPure a SrcSpan |
Instances
Constructors
SfxBind a SrcSpan (Maybe (Expression a)) |
Instances
Functor Suffix Source # | |
Eq a => Eq (Suffix a) Source # | |
Data a => Data (Suffix a) Source # | |
Defined in Language.Fortran.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Suffix a -> c (Suffix a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Suffix a) # toConstr :: Suffix a -> Constr # dataTypeOf :: Suffix a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Suffix a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Suffix a)) # gmapT :: (forall b. Data b => b -> b) -> Suffix a -> Suffix a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Suffix a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Suffix a -> r # gmapQ :: (forall d. Data d => d -> u) -> Suffix a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Suffix a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Suffix a -> m (Suffix a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Suffix a -> m (Suffix a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Suffix a -> m (Suffix a) # | |
Show a => Show (Suffix a) Source # | |
Generic (Suffix a) Source # | |
Out a => Out (Suffix a) Source # | |
NFData a => NFData (Suffix a) Source # | |
Defined in Language.Fortran.AST | |
Spanned (Suffix a) Source # | |
Pretty (Suffix a) Source # | |
Defined in Language.Fortran.PrettyPrint | |
FirstParameter (Suffix a) a Source # | |
Defined in Language.Fortran.AST Methods getFirstParameter :: Suffix a -> a Source # setFirstParameter :: a -> Suffix a -> Suffix a Source # | |
SecondParameter (Suffix a) SrcSpan Source # | |
Defined in Language.Fortran.AST | |
type Rep (Suffix a) Source # | |
Defined in Language.Fortran.AST type Rep (Suffix a) = D1 ('MetaData "Suffix" "Language.Fortran.AST" "fortran-src-0.8.0-inplace" 'False) (C1 ('MetaCons "SfxBind" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SrcSpan) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Expression a)))))) |
Constructors
ProcDecl a SrcSpan (Expression a) (Maybe (Expression a)) |
Instances
data ProcInterface a Source #
Constructors
ProcInterfaceName a SrcSpan (Expression a) | |
ProcInterfaceType a SrcSpan (TypeSpec a) |
Instances
Instances
Functor Comment Source # | |
Eq (Comment a) Source # | |
Data a => Data (Comment a) Source # | |
Defined in Language.Fortran.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Comment a -> c (Comment a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Comment a) # toConstr :: Comment a -> Constr # dataTypeOf :: Comment a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Comment a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Comment a)) # gmapT :: (forall b. Data b => b -> b) -> Comment a -> Comment a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Comment a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Comment a -> r # gmapQ :: (forall d. Data d => d -> u) -> Comment a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Comment a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Comment a -> m (Comment a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment a -> m (Comment a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment a -> m (Comment a) # | |
Show (Comment a) Source # | |
Generic (Comment a) Source # | |
Out a => Out (Comment a) Source # | |
NFData a => NFData (Comment a) Source # | |
Defined in Language.Fortran.AST | |
type Rep (Comment a) Source # | |
Defined in Language.Fortran.AST |
data ForallHeader a Source #
Constructors
ForallHeader [(Name, Expression a, Expression a, Maybe (Expression a))] (Maybe (Expression a)) |
Instances
Constructors
Exclusive | |
Permissive |
Instances
Eq Only Source # | |
Data Only Source # | |
Defined in Language.Fortran.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Only -> c Only # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Only # dataTypeOf :: Only -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Only) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Only) # gmapT :: (forall b. Data b => b -> b) -> Only -> Only # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Only -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Only -> r # gmapQ :: (forall d. Data d => d -> u) -> Only -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Only -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Only -> m Only # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Only -> m Only # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Only -> m Only # | |
Show Only Source # | |
Generic Only Source # | |
Out Only Source # | |
NFData Only Source # | |
Defined in Language.Fortran.AST | |
Pretty Only Source # | |
Defined in Language.Fortran.PrettyPrint | |
type Rep Only Source # | |
Constructors
MetaInfo | |
Fields |
Instances
Eq MetaInfo Source # | |
Data MetaInfo Source # | |
Defined in Language.Fortran.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MetaInfo -> c MetaInfo # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MetaInfo # toConstr :: MetaInfo -> Constr # dataTypeOf :: MetaInfo -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MetaInfo) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MetaInfo) # gmapT :: (forall b. Data b => b -> b) -> MetaInfo -> MetaInfo # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MetaInfo -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MetaInfo -> r # gmapQ :: (forall d. Data d => d -> u) -> MetaInfo -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MetaInfo -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MetaInfo -> m MetaInfo # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MetaInfo -> m MetaInfo # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MetaInfo -> m MetaInfo # | |
Show MetaInfo Source # | |
Generic MetaInfo Source # | |
Out MetaInfo Source # | |
NFData MetaInfo Source # | |
Defined in Language.Fortran.AST | |
type Rep MetaInfo Source # | |
Defined in Language.Fortran.AST type Rep MetaInfo = D1 ('MetaData "MetaInfo" "Language.Fortran.AST" "fortran-src-0.8.0-inplace" 'False) (C1 ('MetaCons "MetaInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "miVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FortranVersion) :*: S1 ('MetaSel ('Just "miFilename") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))) |
type PrefixSuffix a = (Prefixes a, Suffixes a) Source #
data ModuleNature Source #
Constructors
ModIntrinsic | |
ModNonIntrinsic |
Instances
Constructors
UseRename a SrcSpan (Expression a) (Expression a) | |
UseID a SrcSpan (Expression a) |
Instances
Constructors
Argument a SrcSpan (Maybe String) (Expression a) |
Instances
Instances
Eq Intent Source # | |
Data Intent Source # | |
Defined in Language.Fortran.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Intent -> c Intent # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Intent # toConstr :: Intent -> Constr # dataTypeOf :: Intent -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Intent) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Intent) # gmapT :: (forall b. Data b => b -> b) -> Intent -> Intent # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Intent -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Intent -> r # gmapQ :: (forall d. Data d => d -> u) -> Intent -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Intent -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Intent -> m Intent # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Intent -> m Intent # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Intent -> m Intent # | |
Show Intent Source # | |
Generic Intent Source # | |
Out Intent Source # | |
NFData Intent Source # | |
Defined in Language.Fortran.AST | |
Pretty Intent Source # | |
Defined in Language.Fortran.PrettyPrint | |
type Rep Intent Source # | |
Defined in Language.Fortran.AST |
data ControlPair a Source #
Constructors
ControlPair a SrcSpan (Maybe String) (Expression a) |
Instances
Constructors
AOStat a SrcSpan (Expression a) | |
AOErrMsg a SrcSpan (Expression a) | |
AOSource a SrcSpan (Expression a) |
Instances
Constructors
ImpList a SrcSpan (TypeSpec a) (AList ImpElement a) |
Instances
data ImpElement a Source #
Instances
data CommonGroup a Source #
Note that the Declarator
s in common group definitions do not contain
initializing expressions.
Constructors
CommonGroup a SrcSpan (Maybe (Expression a)) (AList Declarator a) |
Instances
Constructors
Namelist a SrcSpan (Expression a) (AList Expression a) |
Instances
Constructors
DataGroup a SrcSpan (AList Expression a) (AList Expression a) |
Instances
data StructureItem a Source #
Constructors
StructFields a SrcSpan (TypeSpec a) (Maybe (AList Attribute a)) (AList Declarator a) | |
StructUnion a SrcSpan (AList UnionMap a) | |
StructStructure a SrcSpan (Maybe String) String (AList StructureItem a) |
Instances
Constructors
UnionMap a SrcSpan (AList StructureItem a) |
Instances
data FormatItem a Source #
Constructors
Instances
Constructors
FSUnit a SrcSpan (Expression a) | |
FSIOStat a SrcSpan (Expression a) | |
FSIOMsg a SrcSpan (Expression a) | |
FSErr a SrcSpan (Expression a) |
Instances
data DoSpecification a Source #
Constructors
DoSpecification a SrcSpan (Statement a) (Expression a) (Maybe (Expression a)) |
Instances
data ProgramUnitName Source #
Constructors
Named String | |
NamelessBlockData | |
NamelessComment | |
NamelessMain |
Instances
Node annotations & related typeclasses
class Annotated f where Source #
Minimal complete definition
Nothing
Methods
getAnnotation :: f a -> a Source #
default getAnnotation :: FirstParameter (f a) a => f a -> a Source #
setAnnotation :: a -> f a -> f a Source #
default setAnnotation :: FirstParameter (f a) a => a -> f a -> f a Source #
modifyAnnotation :: (a -> a) -> f a -> f a Source #
Instances
class Labeled f where Source #
Methods
getLabel :: f a -> Maybe (Expression a) Source #
getLastLabel :: f a -> Maybe (Expression a) Source #
setLabel :: f a -> Expression a -> f a Source #
Instances
Labeled Block Source # | |
Defined in Language.Fortran.AST Methods getLabel :: Block a -> Maybe (Expression a) Source # getLastLabel :: Block a -> Maybe (Expression a) Source # |
Instances
Named (ProgramUnit a) Source # | |
Defined in Language.Fortran.AST Methods getName :: ProgramUnit a -> ProgramUnitName Source # setName :: ProgramUnitName -> ProgramUnit a -> ProgramUnit a Source # |
Helpers
validPrefixSuffix :: PrefixSuffix a -> Bool Source #
emptyPrefixes :: Prefixes a Source #
emptySuffixes :: Suffixes a Source #
nonExecutableStatement :: FortranVersion -> Statement a -> Bool Source #
nonExecutableStatementBlock :: FortranVersion -> Block a -> Bool Source #
executableStatement :: FortranVersion -> Statement a -> Bool Source #
executableStatementBlock :: FortranVersion -> Block a -> Bool Source #
setInitialisation :: Declarator a -> Expression a -> Declarator a Source #
Set a Declarator'
s initializing expression only if it has none already.
Assorted getters & setters
pfSetFilename :: String -> ProgramFile a -> ProgramFile a Source #
pfGetFilename :: ProgramFile a -> String Source #
programUnitBody :: ProgramUnit a -> [Block a] Source #
updateProgramUnitBody :: ProgramUnit a -> [Block a] -> ProgramUnit a Source #
programUnitSubprograms :: ProgramUnit a -> Maybe [ProgramUnit a] Source #