language-fortran-0.5.1: Fortran lexer and parser, language support, and extensions.

Safe HaskellNone



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)



type ProgName = String Source

Fortran program names

data SubName p Source

Fortran subroutine names


SubName p String 
NullSubName p 

data Arg p Source

The src span denotes the end of the arg list before ')'


Arg p (ArgName p) SrcSpan 


data ArgList p Source


ArgList p (Expr p) 

type Program p = [ProgUnit p] Source

data Implicit p Source

Implicit none or no implicit


ImplicitNone p 
ImplicitNull p 

type Renames = [(Variable, Variable)] Source

renames for "use"s

data UseBlock p Source


UseBlock (Uses p) SrcLoc 

data Uses p Source

(second p let's you annotate the cons part of the cell)


Uses p Use (Uses p) p 
UseNil p 

data Block p Source


Block p (UseBlock p) (Implicit p) SrcSpan (Decl p) (Fortran p) 

data Type p 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) 

data GSpec p Source


GName p (Expr p) 
GOper p (BinOp p) 
GAssg p 

data DataForm p Source


Data p [(Expr p, Expr p)] 

data IntentAttr p Source


In p 
Out p 
InOut p 

data Fortran p Source

data BinOp p Source


Plus p 
Minus p 
Mul p 
Div p 
Or p 
And p 
Concat p 
Power p 
RelEQ p 
RelNE p 
RelLT p 
RelLE p 
RelGT p 
RelGE p 


data UnaryOp p Source


UMinus p 
Not p 

data Spec p 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 


class Span t where Source


srcSpan :: t -> (SrcLoc, SrcLoc) Source