parsec-3.1.5: Monadic parser combinators

Portabilityportable
Stabilityprovisional
Maintainerderek.a.elkins@gmail.com
Safe HaskellSafe-Inferred

Text.Parsec.Pos

Description

Textual source positions.

Synopsis

Documentation

data SourcePos Source

The abstract data type SourcePos represents source positions. It contains the name of the source (i.e. file name), a line number and a column number. SourcePos is an instance of the Show, Eq and Ord class.

sourceLine :: SourcePos -> LineSource

Extracts the line number from a source position.

sourceColumn :: SourcePos -> ColumnSource

Extracts the column number from a source position.

sourceName :: SourcePos -> SourceNameSource

Extracts the name of the source from a source position.

incSourceLine :: SourcePos -> Line -> SourcePosSource

Increments the line number of a source position.

incSourceColumn :: SourcePos -> Column -> SourcePosSource

Increments the column number of a source position.

setSourceLine :: SourcePos -> Line -> SourcePosSource

Set the line number of a source position.

setSourceColumn :: SourcePos -> Column -> SourcePosSource

Set the column number of a source position.

setSourceName :: SourcePos -> SourceName -> SourcePosSource

Set the name of the source.

newPos :: SourceName -> Line -> Column -> SourcePosSource

Create a new SourcePos with the given source name, line number and column number.

initialPos :: SourceName -> SourcePosSource

Create a new SourcePos with the given source name, and line number and column number set to 1, the upper left.

updatePosChar :: SourcePos -> Char -> SourcePosSource

Update a source position given a character. If the character is a newline ('\n') or carriage return ('\r') the line number is incremented by 1. If the character is a tab ('t') the column number is incremented to the nearest 8'th column, ie. column + 8 - ((column-1) `mod` 8). In all other cases, the column is incremented by 1.

updatePosString :: SourcePos -> String -> SourcePosSource

The expression updatePosString pos s updates the source position pos by calling updatePosChar on every character in s, ie. foldl updatePosChar pos string.