Copyright | (c) Harvard University 2006-2011 (c) Geoffrey Mainland 2011-2015 |
---|---|
License | BSD-style |
Maintainer | Geoffrey Mainland <mainland@cs.drexel.edu> |
Safe Haskell | None |
Language | Haskell98 |
- data Pos = Pos !FilePath !Int !Int !Int
- posFile :: Pos -> FilePath
- posLine :: Pos -> Int
- posCol :: Pos -> Int
- posCoff :: Pos -> Int
- startPos :: FilePath -> Pos
- linePos :: FilePath -> Int -> Pos
- advancePos :: Pos -> Char -> Pos
- displayPos :: Pos -> String
- displaySPos :: Pos -> ShowS
- data Loc
- locStart :: Loc -> Loc
- locEnd :: Loc -> Loc
- (<-->) :: (Located a, Located b) => a -> b -> Loc
- displayLoc :: Loc -> String
- displaySLoc :: Loc -> ShowS
- newtype SrcLoc = SrcLoc Loc
- srclocOf :: Located a => a -> SrcLoc
- srcspan :: (Located a, Located b) => a -> b -> SrcLoc
- class IsLocation a where
- noLoc :: IsLocation a => a
- class Located a where
- class Relocatable a where
- data L a = L Loc a
- unLoc :: L a -> a
Documentation
data Pos
Position type.
linePos :: FilePath -> Int -> Pos
Position corresponding to given file and line.
Note that the associated character offset is set to 0.
advancePos :: Pos -> Char -> Pos
Advance a position by a single character. Newlines increment the line number, tabs increase the position column following a tab stop width of 8, and all other characters increase the position column by one. All characters, including newlines and tabs, increase the character offset by 1.
Note that advancePos
assumes UNIX-style newlines.
displayPos :: Pos -> String
Format a position in a human-readable way, returning an ordinary
String
.
displaySPos :: Pos -> ShowS
Format a position in a human-readable way.
data Loc
Location type, consisting of a beginning position and an end position.
(<-->) :: (Located a, Located b) => a -> b -> Loc infixl 6
Merge the locations of two Located
values.
displayLoc :: Loc -> String
Format a location in a human-readable way, returning an ordinary
String
.
displaySLoc :: Loc -> ShowS
Format a location in a human-readable way.
newtype SrcLoc
Source location type. Source location are all equal, which allows AST nodes to be compared modulo location information.
class IsLocation a where
Locations
noLoc :: IsLocation a => a
No location.
class Located a where
Located values have a location.