Safe Haskell | None |
---|---|
Language | Haskell98 |
Based on FortranP.hs from Parameterized Fortran by Martin Erwig.
Language definition for Fortran (covers a lot of standards, but still incomplete)
The AST is parameterised by type variable p which allows all nodes
of the AST to be annotated. The default annotation is (). This is
useful for analysis. The Tagged
type class provides the function
tag :: d a -> a
to extract these annotations.
Furthermore, many nodes of the tree have a SrcSpan
which is the
start and end locations of the syntax in the source file (including
whitespace etc.) This is useful for error reporting and
refactoring. The Span
type class provides the function srcSpan
:: d a -> SrcSpan
which which extracts the span (where possible)
- data SrcLoc = SrcLoc {}
- type SrcSpan = (SrcLoc, SrcLoc)
- type Variable = String
- type ProgName = String
- data SubName p
- = SubName p String
- | NullSubName p
- data VarName p = VarName p Variable
- data ArgName p
- data Arg p = Arg p (ArgName p) SrcSpan
- data ArgList p = ArgList p (Expr p)
- type Program p = [ProgUnit p]
- data ProgUnit p
- = Main p SrcSpan (SubName p) (Arg p) (Block p) [ProgUnit p]
- | Sub p SrcSpan (Maybe (BaseType p)) (SubName p) (Arg p) (Block p)
- | Function p SrcSpan (Maybe (BaseType p)) (SubName p) (Arg p) (Maybe (VarName p)) (Block p)
- | Module p SrcSpan (SubName p) (Uses p) (Implicit p) (Decl p) [ProgUnit p]
- | BlockData p SrcSpan (SubName p) (Uses p) (Implicit p) (Decl p)
- | Prog p SrcSpan (ProgUnit p)
- | NullProg p SrcSpan
- | IncludeProg p SrcSpan (Decl p) (Maybe (Fortran p))
- data Implicit p
- = ImplicitNone p
- | ImplicitNull p
- type Renames = [(Variable, Variable)]
- data UseBlock p = UseBlock (Uses p) SrcLoc
- data Use
- data Uses p
- data Block p = Block p (UseBlock p) (Implicit p) SrcSpan (Decl p) (Fortran p)
- data Decl p
- = Decl p SrcSpan [(Expr p, Expr p, Maybe Int)] (Type p)
- | Namelist p [(Expr p, [Expr p])]
- | DataDecl p (DataForm p)
- | Equivalence p SrcSpan [Expr p]
- | AttrStmt p (Attr p) [(Expr p, Expr p, Maybe Int)]
- | AccessStmt p (Attr p) [GSpec p]
- | ExternalStmt p [String]
- | Interface p (Maybe (GSpec p)) [InterfaceSpec p]
- | Common p SrcSpan (Maybe String) [Expr p]
- | DerivedTypeDef p SrcSpan (SubName p) [Attr p] [Attr p] [Decl p]
- | Include p (Expr p)
- | DSeq p (Decl p) (Decl p)
- | TextDecl p String
- | NullDecl p SrcSpan
- | MeasureUnitDef p SrcSpan [(MeasureUnit, MeasureUnitSpec p)]
- data Type p
- data BaseType p
- data Attr p
- = Parameter p
- | Allocatable p
- | External p
- | Intent p (IntentAttr p)
- | Intrinsic p
- | Optional p
- | Pointer p
- | Save p
- | Target p
- | Volatile p
- | Public p
- | Private p
- | Sequence p
- | Dimension p [(Expr p, Expr p)]
- | MeasureUnit p (MeasureUnitSpec p)
- type MeasureUnit = String
- data MeasureUnitSpec p
- = UnitProduct p [(MeasureUnit, Fraction p)]
- | UnitQuotient p [(MeasureUnit, Fraction p)] [(MeasureUnit, Fraction p)]
- | UnitNone p
- data Fraction p
- = IntegerConst p String
- | FractionConst p String String
- | NullFraction p
- data GSpec p
- data InterfaceSpec p
- = FunctionInterface p (SubName p) (Arg p) (Uses p) (Implicit p) (Decl p)
- | SubroutineInterface p (SubName p) (Arg p) (Uses p) (Implicit p) (Decl p)
- | ModuleProcedure p [SubName p]
- data DataForm p = Data p [(Expr p, Expr p)]
- data IntentAttr p
- data Fortran p
- = Assg p SrcSpan (Expr p) (Expr p)
- | For p SrcSpan (VarName p) (Expr p) (Expr p) (Expr p) (Fortran p)
- | DoWhile p SrcSpan (Expr p) (Fortran p)
- | FSeq p SrcSpan (Fortran p) (Fortran p)
- | If p SrcSpan (Expr p) (Fortran p) [(Expr p, Fortran p)] (Maybe (Fortran p))
- | Allocate p SrcSpan (Expr p) (Expr p)
- | Backspace p SrcSpan [Spec p]
- | Call p SrcSpan (Expr p) (ArgList p)
- | Open p SrcSpan [Spec p]
- | Close p SrcSpan [Spec p]
- | Continue p SrcSpan
- | Cycle p SrcSpan String
- | DataStmt p SrcSpan (DataForm p)
- | Deallocate p SrcSpan [Expr p] (Expr p)
- | Endfile p SrcSpan [Spec p]
- | Exit p SrcSpan String
- | Format p SrcSpan [Spec p]
- | Forall p SrcSpan ([(String, Expr p, Expr p, Expr p)], Expr p) (Fortran p)
- | Goto p SrcSpan String
- | Nullify p SrcSpan [Expr p]
- | Inquire p SrcSpan [Spec p] [Expr p]
- | Pause p SrcSpan String
- | Rewind p SrcSpan [Spec p]
- | Stop p SrcSpan (Expr p)
- | Where p SrcSpan (Expr p) (Fortran p) (Maybe (Fortran p))
- | Write p SrcSpan [Spec p] [Expr p]
- | PointerAssg p SrcSpan (Expr p) (Expr p)
- | Return p SrcSpan (Expr p)
- | Label p SrcSpan String (Fortran p)
- | Print p SrcSpan (Expr p) [Expr p]
- | ReadS p SrcSpan [Spec p] [Expr p]
- | TextStmt p SrcSpan String
- | NullStmt p SrcSpan
- data Expr p
- = Con p SrcSpan String
- | ConL p SrcSpan Char String
- | ConS p SrcSpan String
- | Var p SrcSpan [(VarName p, [Expr p])]
- | Bin p SrcSpan (BinOp p) (Expr p) (Expr p)
- | Unary p SrcSpan (UnaryOp p) (Expr p)
- | CallExpr p SrcSpan (Expr p) (ArgList p)
- | NullExpr p SrcSpan
- | Null p SrcSpan
- | ESeq p SrcSpan (Expr p) (Expr p)
- | Bound p SrcSpan (Expr p) (Expr p)
- | Sqrt p SrcSpan (Expr p)
- | ArrayCon p SrcSpan [Expr p]
- | AssgExpr p SrcSpan String (Expr p)
- data BinOp p
- data UnaryOp p
- data Spec p
- = Access p (Expr p)
- | Action p (Expr p)
- | Advance p (Expr p)
- | Blank p (Expr p)
- | Delim p (Expr p)
- | Direct p (Expr p)
- | End p (Expr p)
- | Err p (Expr p)
- | ExFile p (Expr p)
- | Exist p (Expr p)
- | Eor p (Expr p)
- | File p (Expr p)
- | FMT p (Expr p)
- | Form p (Expr p)
- | Formatted p (Expr p)
- | Unformatted p (Expr p)
- | IOLength p (Expr p)
- | IOStat p (Expr p)
- | Name p (Expr p)
- | Named p (Expr p)
- | NoSpec p (Expr p)
- | Number p (Expr p)
- | Floating p (Expr p) (Expr p)
- | NextRec p (Expr p)
- | NML p (Expr p)
- | Opened p (Expr p)
- | Pad p (Expr p)
- | Position p (Expr p)
- | Read p (Expr p)
- | ReadWrite p (Expr p)
- | Rec p (Expr p)
- | Recl p (Expr p)
- | Sequential p (Expr p)
- | Size p (Expr p)
- | Status p (Expr p)
- | StringLit p String
- | Unit p (Expr p)
- | WriteSp p (Expr p)
- | Delimiter p
- class Span t where
- class Tagged d where
- tag :: d a -> a
Documentation
Fortran subroutine names
SubName p String | |
NullSubName p |
The src span denotes the end of the arg list before ')'
Main p SrcSpan (SubName p) (Arg p) (Block p) [ProgUnit p] | |
Sub p SrcSpan (Maybe (BaseType p)) (SubName p) (Arg p) (Block p) | |
Function p SrcSpan (Maybe (BaseType p)) (SubName p) (Arg p) (Maybe (VarName p)) (Block p) | |
Module p SrcSpan (SubName p) (Uses p) (Implicit p) (Decl p) [ProgUnit p] | |
BlockData p SrcSpan (SubName p) (Uses p) (Implicit p) (Decl p) | |
Prog p SrcSpan (ProgUnit p) | |
NullProg p SrcSpan | |
IncludeProg p SrcSpan (Decl p) (Maybe (Fortran p)) |
Functor ProgUnit Source | |
Tagged ProgUnit Source | |
Eq p => Eq (ProgUnit p) Source | |
Data p => Data (ProgUnit p) Source | |
Show p => Show (ProgUnit p) Source | |
Span (ProgUnit a) Source | |
(PPVersion v, PrintSlave (ProgUnit p) v) => PrintMaster [ProgUnit p] v Source | |
(PrintSlave (Arg p) v, PrintSlave (BaseType p) v, PrintSlave (Block p) v, PrintSlave (Decl p) v, PrintSlave (Fortran p) v, PrintSlave (Implicit p) v, PrintSlave (SubName p) v, PrintSlave (VarName p) v, PrintSlave (ProgUnit p) v, PPVersion v) => PrintMaster (ProgUnit p) v Source |
Implicit none or no implicit
(second p
let's you annotate the cons
part of the cell)
Decl p SrcSpan [(Expr p, Expr p, Maybe Int)] (Type p) | |
Namelist p [(Expr p, [Expr p])] | |
DataDecl p (DataForm p) | |
Equivalence p SrcSpan [Expr p] | |
AttrStmt p (Attr p) [(Expr p, Expr p, Maybe Int)] | |
AccessStmt p (Attr p) [GSpec p] | |
ExternalStmt p [String] | |
Interface p (Maybe (GSpec p)) [InterfaceSpec p] | |
Common p SrcSpan (Maybe String) [Expr p] | |
DerivedTypeDef p SrcSpan (SubName p) [Attr p] [Attr p] [Decl p] | |
Include p (Expr p) | |
DSeq p (Decl p) (Decl p) | |
TextDecl p String | |
NullDecl p SrcSpan | |
MeasureUnitDef p SrcSpan [(MeasureUnit, MeasureUnitSpec p)] |
Functor Decl Source | |
Tagged Decl Source | |
Eq p => Eq (Decl p) Source | |
Data p => Data (Decl p) Source | |
Show p => Show (Decl p) Source | |
Span (Decl a) Source | |
(Indentor (Decl p), PrintSlave (Arg p) v, PrintSlave (ArgList p) v, PrintSlave (Attr p) v, PrintSlave (BinOp p) v, PrintSlave (Decl p) v, PrintSlave (DataForm p) v, PrintSlave (Expr p) v, PrintSlave (GSpec p) v, PrintSlave (Implicit p) v, PrintSlave (InterfaceSpec p) v, PrintSlave (MeasureUnitSpec p) v, PrintSlave (SubName p) v, PrintSlave (UnaryOp p) v, PrintSlave (VarName p) v, PrintSlave (Type p) v, PPVersion v) => PrintMaster (Decl p) v Source |
BaseType p (BaseType p) [Attr p] (Expr p) (Expr p) | |
ArrayT p [(Expr p, Expr p)] (BaseType p) [Attr p] (Expr p) (Expr p) |
Functor Type Source | |
Eq p => Eq (Type p) Source | |
Data p => Data (Type p) Source | |
Show p => Show (Type p) Source | |
(PrintSlave (ArgList p) v, PrintSlave (BinOp p) v, PrintSlave (UnaryOp p) v, PrintSlave (BaseType p) v, PrintSlave (Expr p) v, PrintSlave (MeasureUnitSpec p) v, PrintSlave (VarName p) v, PPVersion v) => PrintMaster (Type p) v Source |
Parameter p | |
Allocatable p | |
External p | |
Intent p (IntentAttr p) | |
Intrinsic p | |
Optional p | |
Pointer p | |
Save p | |
Target p | |
Volatile p | |
Public p | |
Private p | |
Sequence p | |
Dimension p [(Expr p, Expr p)] | |
MeasureUnit p (MeasureUnitSpec p) |
Functor Attr Source | |
Tagged Attr Source | |
Eq p => Eq (Attr p) Source | |
Data p => Data (Attr p) Source | |
Show p => Show (Attr p) Source | |
(PrintSlave (ArgList p) v, PrintSlave (BinOp p) v, PrintSlave (Expr p) v, PrintSlave (UnaryOp p) v, PrintSlave (VarName p) v, PrintSlave (MeasureUnitSpec p) v, PPVersion v) => PrintMaster (Attr p) v Source |
type MeasureUnit = String Source
data MeasureUnitSpec p Source
UnitProduct p [(MeasureUnit, Fraction p)] | |
UnitQuotient p [(MeasureUnit, Fraction p)] [(MeasureUnit, Fraction p)] | |
UnitNone p |
Functor MeasureUnitSpec Source | |
Eq p => Eq (MeasureUnitSpec p) Source | |
Data p => Data (MeasureUnitSpec p) Source | |
Show p => Show (MeasureUnitSpec p) Source | |
PPVersion v => PrintMaster (MeasureUnitSpec p) v Source |
data InterfaceSpec p Source
FunctionInterface p (SubName p) (Arg p) (Uses p) (Implicit p) (Decl p) | |
SubroutineInterface p (SubName p) (Arg p) (Uses p) (Implicit p) (Decl p) | |
ModuleProcedure p [SubName p] |
Functor InterfaceSpec Source | |
Eq p => Eq (InterfaceSpec p) Source | |
Data p => Data (InterfaceSpec p) Source | |
Show p => Show (InterfaceSpec p) Source | |
(PrintSlave (Arg p) v, PrintSlave (Decl p) v, PrintSlave (Implicit p) v, PrintSlave (SubName p) v, PPVersion v) => PrintMaster (InterfaceSpec p) v Source |
data IntentAttr p Source
Functor IntentAttr Source | |
Eq p => Eq (IntentAttr p) Source | |
Data p => Data (IntentAttr p) Source | |
Show p => Show (IntentAttr p) Source |
Functor Fortran Source | |
Tagged Fortran Source | |
Eq p => Eq (Fortran p) Source | |
Data p => Data (Fortran p) Source | |
Show p => Show (Fortran p) Source | |
Span (Fortran a) Source | |
(Indentor (Fortran p), PrintSlave (VarName p) v, PrintSlave (Expr p) v, PrintSlave (UnaryOp p) v, PrintSlave (BinOp p) v, PrintSlave (ArgList p) v, PrintIndSlave (Fortran p) v, PrintSlave (DataForm p) v, PrintSlave (Fortran p) v, PrintSlave (Spec p) v, PPVersion v) => PrintIndMaster (Fortran p) v Source | |
(PrintIndMaster (Fortran p) v, PPVersion v) => PrintMaster (Fortran p) v Source |
Con p SrcSpan String | |
ConL p SrcSpan Char String | |
ConS p SrcSpan String | |
Var p SrcSpan [(VarName p, [Expr p])] | |
Bin p SrcSpan (BinOp p) (Expr p) (Expr p) | |
Unary p SrcSpan (UnaryOp p) (Expr p) | |
CallExpr p SrcSpan (Expr p) (ArgList p) | |
NullExpr p SrcSpan | |
Null p SrcSpan | |
ESeq p SrcSpan (Expr p) (Expr p) | |
Bound p SrcSpan (Expr p) (Expr p) | |
Sqrt p SrcSpan (Expr p) | |
ArrayCon p SrcSpan [Expr p] | |
AssgExpr p SrcSpan String (Expr p) |
Functor Expr Source | |
Tagged Expr Source | |
Eq p => Eq (Expr p) Source | |
Data p => Data (Expr p) Source | |
Show p => Show (Expr p) Source | |
Span (Expr a) Source | |
(PrintSlave (ArgList p) v, PrintSlave (BinOp p) v, PrintSlave (Expr p) v, PrintSlave (UnaryOp p) v, PrintSlave (VarName p) v, PPVersion v) => PrintMaster (Expr p) v Source |
Access p (Expr p) | |
Action p (Expr p) | |
Advance p (Expr p) | |
Blank p (Expr p) | |
Delim p (Expr p) | |
Direct p (Expr p) | |
End p (Expr p) | |
Err p (Expr p) | |
ExFile p (Expr p) | |
Exist p (Expr p) | |
Eor p (Expr p) | |
File p (Expr p) | |
FMT p (Expr p) | |
Form p (Expr p) | |
Formatted p (Expr p) | |
Unformatted p (Expr p) | |
IOLength p (Expr p) | |
IOStat p (Expr p) | |
Name p (Expr p) | |
Named p (Expr p) | |
NoSpec p (Expr p) | |
Number p (Expr p) | |
Floating p (Expr p) (Expr p) | |
NextRec p (Expr p) | |
NML p (Expr p) | |
Opened p (Expr p) | |
Pad p (Expr p) | |
Position p (Expr p) | |
Read p (Expr p) | |
ReadWrite p (Expr p) | |
Rec p (Expr p) | |
Recl p (Expr p) | |
Sequential p (Expr p) | |
Size p (Expr p) | |
Status p (Expr p) | |
StringLit p String | |
Unit p (Expr p) | |
WriteSp p (Expr p) | |
Delimiter p |