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

Copyright(c) 2009 Bernie Pope
LicenseBSD-style
Maintainerbjpop@csse.unimelb.edu.au
Stabilityexperimental
Portabilityghc
Safe HaskellSafe-Inferred
LanguageHaskell98

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 

spanning :: (Span a, Span b) => a -> b -> SrcSpan Source

Create a new span which encloses two spanned things.

mkSrcSpan :: SrcLocation -> SrcLocation -> SrcSpan Source

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

combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan Source

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 -> SrcLocation Source

Construct the initial source location for a file.

spanStartPoint :: SrcSpan -> SrcSpan Source

Make a point span from the start of a span

Modification

incColumn :: Int -> SrcLocation -> SrcLocation Source

Increment the column of a location.

decColumn :: Int -> SrcLocation -> SrcLocation Source

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

incLine :: Int -> SrcLocation -> SrcLocation Source

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

incTab :: SrcLocation -> SrcLocation Source

Increment the column of a location by one tab stop.

endCol :: SrcSpan -> Int Source

Get the column of the end of a span.

Projection of components of a span

endRow :: SrcSpan -> Int Source

Get the row of the end of a span.

startCol :: SrcSpan -> Int Source

Get the column of the start of a span.

startRow :: SrcSpan -> Int Source

Get the row of the start of a span.