parsec-3.1.13.0: Monadic parser combinators

Copyright(c) Daan Leijen 1999-2001 (c) Paolo Martini 2007
LicenseBSD-style (see the LICENSE file)
Maintainerderek.a.elkins@gmail.com
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Text.Parsec.Pos

Description

Textual source positions.

Synopsis

Documentation

type Line = Int Source #

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.

Instances
Eq SourcePos Source # 
Instance details
Data SourcePos Source # 
Instance details

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SourcePos -> c SourcePos #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SourcePos #

toConstr :: SourcePos -> Constr #

dataTypeOf :: SourcePos -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SourcePos) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SourcePos) #

gmapT :: (forall b. Data b => b -> b) -> SourcePos -> SourcePos #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r #

gmapQ :: (forall d. Data d => d -> u) -> SourcePos -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SourcePos -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos #

Ord SourcePos Source # 
Instance details
Show SourcePos Source # 
Instance details

sourceLine :: SourcePos -> Line Source #

Extracts the line number from a source position.

sourceColumn :: SourcePos -> Column Source #

Extracts the column number from a source position.

sourceName :: SourcePos -> SourceName Source #

Extracts the name of the source from a source position.

incSourceLine :: SourcePos -> Line -> SourcePos Source #

Increments the line number of a source position.

incSourceColumn :: SourcePos -> Column -> SourcePos Source #

Increments the column number of a source position.

setSourceLine :: SourcePos -> Line -> SourcePos Source #

Set the line number of a source position.

setSourceColumn :: SourcePos -> Column -> SourcePos Source #

Set the column number of a source position.

setSourceName :: SourcePos -> SourceName -> SourcePos Source #

Set the name of the source.

newPos :: SourceName -> Line -> Column -> SourcePos Source #

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

initialPos :: SourceName -> SourcePos Source #

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

updatePosChar :: SourcePos -> Char -> SourcePos Source #

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 -> SourcePos Source #

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