fortran-src-0.4.2: Parsers and analyses for Fortran standards 66, 77, 90 and 95.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Fortran.Rewriter

Description

This module provides an interface for rewriting textual, unparsed Fortran using a diff-like algorithm.

Original code from Bloomberg, used with permission.

Original authors: * Daniel Beer * Anthony Burzillo * Raoul Hidalgo Charman * Aiden Jeffrey * Jason Xu * Beleth Apophis * Lukasz Kolodziejczyk

Synopsis

Documentation

data SourceLocation Source #

Represents location in source code.

Note that, SourceLocation indicates space between characters, i.e the following example:

 SourceLocation 0 1

indicates position between first and second characters in a file.

Constructors

SourceLocation Int Int 

data SourceRange Source #

Represents range in source code.

Instances

Instances details
Eq SourceRange Source # 
Instance details

Defined in Language.Fortran.Rewriter.Internal

Show SourceRange Source # 
Instance details

Defined in Language.Fortran.Rewriter.Internal

data Replacement Source #

Represents the intent to replace content in the file.

The content in Replacement will be used in place of what is in the range described. Note that the replacement text can be shorter or larger than the original span, and it can also be multi-line.

type ReplacementMap = Map String [Replacement] Source #

Represents map of files and replacements that will be done.

partitionOverlapping :: [Replacement] -> ([Replacement], [Replacement]) Source #

Remove overlapping items from a list of replacements and return a pair of lists containing disjoint items and overlapping items, respectively.

Important notes:

Replacements that come first in the list will be given precedence over later items.

processReplacements :: ReplacementMap -> IO () Source #

Apply a list of Replacements to the orginal source file.

Important notes:

Source locations specified in replacements are 0-indexed.

Rewriting applies continuation lines when lines are longer than 72 characters.

Example replacements:

Delete the first character in a file

 Replacement (SourceRange (SourceLocation 0 0) (SourceLocation 0 1)) ""

Prepend "a" to 1 line, 2 column character

 Replacement (SourceRange (SourceLocation 0 1) (SourceLocation 0 1)) "a"

Replace a character located in 2 line, 4 column with "a"

 Replacement (SourceRange (SourceLocation 1 3) (SourceLocation 1 4)) "a"

Replace string starting in 2 line, 4 column and ending in 2 line, 6 column (inclusive) with "a"

 Replacement (SourceRange (SourceLocation 1 3) (SourceLocation 1 6)) "a"

Since: 0.1.0.0

spanToSourceRange :: SrcSpan -> SourceRange Source #

Utility function to convert SrcSpan to SourceRange

Since: 0.1.13.7

spanToSourceRange2 :: SrcSpan -> SrcSpan -> SourceRange Source #

Given two Spans, returns a SourceRange that starts at the starting location of the first span, and ends at the starting location of the second span

Since: 0.1.17.2

sourceRangeBetweenTwoSpans :: SrcSpan -> SrcSpan -> SourceRange Source #

Given two Spans, returns a SourceRange that starts at the ending location of the first span, and ends at the starting location of the second span

Since: 0.1.17.2