Portability | ghc |
---|---|
Stability | experimental |
Maintainer | bjpop@csse.unimelb.edu.au |
Safe Haskell | Safe-Inferred |
Source location information for the Python lexer and parser. This module provides single-point locations and spans, and conversions between them.
- data SrcLocation
- = Sloc {
- sloc_filename :: !String
- sloc_row :: !Int
- sloc_column :: !Int
- | NoLocation
- = Sloc {
- data SrcSpan
- = SpanCoLinear {
- span_filename :: !String
- span_row :: !Int
- span_start_column :: !Int
- span_end_column :: !Int
- | SpanMultiLine {
- span_filename :: !String
- span_start_row :: !Int
- span_start_column :: !Int
- span_end_row :: !Int
- span_end_column :: !Int
- | SpanPoint {
- span_filename :: !String
- span_row :: !Int
- span_column :: !Int
- | SpanEmpty
- = SpanCoLinear {
- class Span a where
- spanning :: (Span a, Span b) => a -> b -> SrcSpan
- mkSrcSpan :: SrcLocation -> SrcLocation -> SrcSpan
- combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan
- initialSrcLocation :: String -> SrcLocation
- spanStartPoint :: SrcSpan -> SrcSpan
- incColumn :: Int -> SrcLocation -> SrcLocation
- decColumn :: Int -> SrcLocation -> SrcLocation
- incLine :: Int -> SrcLocation -> SrcLocation
- incTab :: SrcLocation -> SrcLocation
- endCol :: SrcSpan -> Int
- endRow :: SrcSpan -> Int
- startCol :: SrcSpan -> Int
- startRow :: SrcSpan -> Int
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.
Sloc | |
| |
NoLocation |
Source location spanning a contiguous section of a file.
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. |
Types which have a span.
Span SrcSpan | |
Span SrcLocation | |
Span Token | |
Span AssignOpSpan | |
Span OpSpan | |
Span SliceSpan | |
Span ExprSpan | |
Span CompIterSpan | |
Span CompIfSpan | |
Span CompForSpan | |
Span ExceptClauseSpan | |
Span HandlerSpan | |
Span ArgumentSpan | |
Span ParamTupleSpan | |
Span ParameterSpan | |
Span DecoratorSpan | |
Span StatementSpan | |
Span ImportRelativeSpan | |
Span FromItemsSpan | |
Span FromItemSpan | |
Span ImportItemSpan | |
Span IdentSpan | |
Span Subscript | |
Span Trailer | |
Span a => Span [a] | |
Span a => Span (Maybe a) | |
Span (ComprehensionSpan e) | |
(Span a, Span b) => Span (Either a b) | |
(Span a, Span b) => Span (a, b) |
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
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.