language-python-0.3.2: Parsing and pretty printing of Python code.

Portabilityghc
Stabilityexperimental
Maintainerbjpop@csse.unimelb.edu.au

Language.Python.Common.SrcLocation

Contents

Description

Source location information for the Python lexer and parser. This module provides single-point locations and spans, and conversions between them.

Synopsis

Construction

data SrcLocation Source

A location for a syntactic entity from the source code. The location is specified by its filename, and starting row and column.

Constructors

Sloc 
NoLocation 

data SrcSpan Source

Source location spanning a contiguous section of a file.

Constructors

SpanCoLinear

A span which starts and ends on the same line.

SpanMultiLine

A span which starts and ends on different lines.

SpanPoint

A span which is actually just one point in the file.

SpanEmpty

No span information.

spanning :: (Span a, Span b) => a -> b -> SrcSpanSource

Create a new span which encloses two spanned things.

mkSrcSpan :: SrcLocation -> SrcLocation -> SrcSpanSource

Make a span from two locations. Assumption: either the arguments are the same, or the left one preceeds the right one.

combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpanSource

Combines two SrcSpan into one that spans at least all the characters within both spans. Assumes the file part is the same in both inputs

initialSrcLocation :: String -> SrcLocationSource

Construct the initial source location for a file.

spanStartPoint :: SrcSpan -> SrcSpanSource

Make a point span from the start of a span

Modification

incColumn :: Int -> SrcLocation -> SrcLocationSource

Increment the column of a location.

decColumn :: Int -> SrcLocation -> SrcLocationSource

Decrement the column of a location, only if they are on the same row.

incLine :: Int -> SrcLocation -> SrcLocationSource

Increment the line number (row) of a location by one.

incTab :: SrcLocation -> SrcLocationSource

Increment the column of a location by one tab stop.

endCol :: SrcSpan -> IntSource

Get the column of the end of a span.

Projection of components of a span

endRow :: SrcSpan -> IntSource

Get the row of the end of a span.

startCol :: SrcSpan -> IntSource

Get the column of the start of a span.

startRow :: SrcSpan -> IntSource

Get the row of the start of a span.