Copyright | (c) Daan Leijen 1999-2001, (c) Paolo Martini 2007 |
---|---|
License | BSD-style (see the LICENSE file) |
Maintainer | derek.a.elkins@gmail.com |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
Textual source positions.
- type SourceName = String
- type Line = Int
- type Column = Int
- data SourcePos
- sourceLine :: SourcePos -> Line
- sourceColumn :: SourcePos -> Column
- sourceName :: SourcePos -> SourceName
- incSourceLine :: SourcePos -> Line -> SourcePos
- incSourceColumn :: SourcePos -> Column -> SourcePos
- setSourceLine :: SourcePos -> Line -> SourcePos
- setSourceColumn :: SourcePos -> Column -> SourcePos
- setSourceName :: SourcePos -> SourceName -> SourcePos
- newPos :: SourceName -> Line -> Column -> SourcePos
- initialPos :: SourceName -> SourcePos
- updatePosChar :: SourcePos -> Char -> SourcePos
- updatePosString :: SourcePos -> String -> SourcePos
Documentation
type SourceName = String Source
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
.