Handling parse positions
Author: Jasper Sikorra - jsi@informatik.uni-kiel.de
Version: January 2014
tw
:: Int
|
unknown_fname
:: String
|
setPos
:: String -> Int -> Int -> Int -> Pos
Construct a new position |
initPos
:: String -> Pos
Construct the initial position |
getFilename
:: Pos -> String
|
setFilename
:: Pos -> String -> Pos
|
getAbs
:: Pos -> Int
|
setAbs
:: Pos -> Int -> Pos
|
moveAbs
:: Pos -> Int -> Pos
|
getLn
:: Pos -> Int
|
setLn
:: Pos -> Int -> Pos
|
moveLn
:: Pos -> Int -> Pos
|
getCol
:: Pos -> Int
|
setCol
:: Pos -> Int -> Pos
|
moveCol
:: Pos -> Int -> Pos
|
lnDifference
:: Pos -> Pos -> Int
The difference in lines between two positions |
colDifference
:: Pos -> Pos -> Int
The difference in columns between two positions |
absDifference
:: Pos -> Pos -> Int
The absolute difference between two positions |
fullDifference
:: Pos -> Pos -> (Int,Int)
The line and column difference between two positions |
movePosByChar
:: Pos -> Char -> Pos
Move the position one character |
movePosByString
:: Pos -> String -> Pos
Move the position multiple characters |
toSimplePos
:: Pos -> (Int,Int)
Convert to SimplePos |
fromSimplePos
:: (Int,Int) -> Pos
Convert from SimplePos |
fromSimplePosWithFname
:: (Int,Int) -> String -> Pos
Convert from SimplePos with Filename |
Type synonym: Filename = String
Type synonym: Absolute = Int
Type synonym: Line = Int
Type synonym: Column = Int
Type synonym: SimplePos = (Int,Int)
The Pos data type contains the name of the file, the absolute, where every character is counted as 1 (newlines, tabs too) (starting with 0), the line (starting with 1) and the column (starting with 1) of the character's position.
Constructors:
|
|
Construct a new position
|
Construct the initial position
|
|
|
The difference in lines between two positions |
The difference in columns between two positions |
The absolute difference between two positions |
The line and column difference between two positions |
Move the position one character |
Move the position multiple characters |
Convert to SimplePos
|
Convert from SimplePos |
Convert from SimplePos with Filename |