{-# LANGUAGE DeriveDataTypeable #-}
module Language.C.Data.Position (
Position(),
position,
PosLength,
posFile,posRow,posColumn,posOffset,posParent,
initPos, isSourcePos,
nopos, isNoPos,
builtinPos, isBuiltinPos,
internalPos, isInternalPos,
incPos, retPos,
incOffset,
Pos(..),
) where
import Data.Data (Data)
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Control.DeepSeq (NFData)
data FilePosition = FilePosition { FilePosition -> String
posSrcFile :: String,
FilePosition -> Maybe Position
posParentFile :: (Maybe Position)
}
deriving (FilePosition -> FilePosition -> Bool
(FilePosition -> FilePosition -> Bool)
-> (FilePosition -> FilePosition -> Bool) -> Eq FilePosition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FilePosition -> FilePosition -> Bool
== :: FilePosition -> FilePosition -> Bool
$c/= :: FilePosition -> FilePosition -> Bool
/= :: FilePosition -> FilePosition -> Bool
Eq, Eq FilePosition
Eq FilePosition =>
(FilePosition -> FilePosition -> Ordering)
-> (FilePosition -> FilePosition -> Bool)
-> (FilePosition -> FilePosition -> Bool)
-> (FilePosition -> FilePosition -> Bool)
-> (FilePosition -> FilePosition -> Bool)
-> (FilePosition -> FilePosition -> FilePosition)
-> (FilePosition -> FilePosition -> FilePosition)
-> Ord FilePosition
FilePosition -> FilePosition -> Bool
FilePosition -> FilePosition -> Ordering
FilePosition -> FilePosition -> FilePosition
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FilePosition -> FilePosition -> Ordering
compare :: FilePosition -> FilePosition -> Ordering
$c< :: FilePosition -> FilePosition -> Bool
< :: FilePosition -> FilePosition -> Bool
$c<= :: FilePosition -> FilePosition -> Bool
<= :: FilePosition -> FilePosition -> Bool
$c> :: FilePosition -> FilePosition -> Bool
> :: FilePosition -> FilePosition -> Bool
$c>= :: FilePosition -> FilePosition -> Bool
>= :: FilePosition -> FilePosition -> Bool
$cmax :: FilePosition -> FilePosition -> FilePosition
max :: FilePosition -> FilePosition -> FilePosition
$cmin :: FilePosition -> FilePosition -> FilePosition
min :: FilePosition -> FilePosition -> FilePosition
Ord, Typeable, Typeable FilePosition
Typeable FilePosition =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FilePosition -> c FilePosition)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FilePosition)
-> (FilePosition -> Constr)
-> (FilePosition -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FilePosition))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FilePosition))
-> ((forall b. Data b => b -> b) -> FilePosition -> FilePosition)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FilePosition -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FilePosition -> r)
-> (forall u. (forall d. Data d => d -> u) -> FilePosition -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> FilePosition -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition)
-> Data FilePosition
FilePosition -> Constr
FilePosition -> DataType
(forall b. Data b => b -> b) -> FilePosition -> FilePosition
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> FilePosition -> u
forall u. (forall d. Data d => d -> u) -> FilePosition -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FilePosition -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FilePosition -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FilePosition
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FilePosition -> c FilePosition
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FilePosition)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FilePosition)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FilePosition -> c FilePosition
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FilePosition -> c FilePosition
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FilePosition
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FilePosition
$ctoConstr :: FilePosition -> Constr
toConstr :: FilePosition -> Constr
$cdataTypeOf :: FilePosition -> DataType
dataTypeOf :: FilePosition -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FilePosition)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FilePosition)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FilePosition)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FilePosition)
$cgmapT :: (forall b. Data b => b -> b) -> FilePosition -> FilePosition
gmapT :: (forall b. Data b => b -> b) -> FilePosition -> FilePosition
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FilePosition -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FilePosition -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FilePosition -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FilePosition -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> FilePosition -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> FilePosition -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FilePosition -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FilePosition -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FilePosition -> m FilePosition
Data, (forall x. FilePosition -> Rep FilePosition x)
-> (forall x. Rep FilePosition x -> FilePosition)
-> Generic FilePosition
forall x. Rep FilePosition x -> FilePosition
forall x. FilePosition -> Rep FilePosition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FilePosition -> Rep FilePosition x
from :: forall x. FilePosition -> Rep FilePosition x
$cto :: forall x. Rep FilePosition x -> FilePosition
to :: forall x. Rep FilePosition x -> FilePosition
Generic)
instance NFData FilePosition
data Position = Position { Position -> Int
posOffset :: {-# UNPACK #-} !Int
, Position -> Int
posRow :: {-# UNPACK #-} !Int
, Position -> Int
posColumn :: {-# UNPACK #-} !Int
, Position -> FilePosition
posFileInfo :: FilePosition
}
| NoPosition
| BuiltinPosition
| InternalPosition
deriving (Position -> Position -> Bool
(Position -> Position -> Bool)
-> (Position -> Position -> Bool) -> Eq Position
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Position -> Position -> Bool
== :: Position -> Position -> Bool
$c/= :: Position -> Position -> Bool
/= :: Position -> Position -> Bool
Eq, Eq Position
Eq Position =>
(Position -> Position -> Ordering)
-> (Position -> Position -> Bool)
-> (Position -> Position -> Bool)
-> (Position -> Position -> Bool)
-> (Position -> Position -> Bool)
-> (Position -> Position -> Position)
-> (Position -> Position -> Position)
-> Ord Position
Position -> Position -> Bool
Position -> Position -> Ordering
Position -> Position -> Position
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Position -> Position -> Ordering
compare :: Position -> Position -> Ordering
$c< :: Position -> Position -> Bool
< :: Position -> Position -> Bool
$c<= :: Position -> Position -> Bool
<= :: Position -> Position -> Bool
$c> :: Position -> Position -> Bool
> :: Position -> Position -> Bool
$c>= :: Position -> Position -> Bool
>= :: Position -> Position -> Bool
$cmax :: Position -> Position -> Position
max :: Position -> Position -> Position
$cmin :: Position -> Position -> Position
min :: Position -> Position -> Position
Ord, Typeable, Typeable Position
Typeable Position =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position -> c Position)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Position)
-> (Position -> Constr)
-> (Position -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Position))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position))
-> ((forall b. Data b => b -> b) -> Position -> Position)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Position -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Position -> r)
-> (forall u. (forall d. Data d => d -> u) -> Position -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Position -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Position -> m Position)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position -> m Position)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position -> m Position)
-> Data Position
Position -> Constr
Position -> DataType
(forall b. Data b => b -> b) -> Position -> Position
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Position -> u
forall u. (forall d. Data d => d -> u) -> Position -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Position -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Position -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Position -> m Position
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position -> m Position
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Position
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position -> c Position
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Position)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position -> c Position
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position -> c Position
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Position
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Position
$ctoConstr :: Position -> Constr
toConstr :: Position -> Constr
$cdataTypeOf :: Position -> DataType
dataTypeOf :: Position -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Position)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Position)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position)
$cgmapT :: (forall b. Data b => b -> b) -> Position -> Position
gmapT :: (forall b. Data b => b -> b) -> Position -> Position
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Position -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Position -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Position -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Position -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Position -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Position -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Position -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Position -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Position -> m Position
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Position -> m Position
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position -> m Position
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position -> m Position
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position -> m Position
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position -> m Position
Data, (forall x. Position -> Rep Position x)
-> (forall x. Rep Position x -> Position) -> Generic Position
forall x. Rep Position x -> Position
forall x. Position -> Rep Position x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Position -> Rep Position x
from :: forall x. Position -> Rep Position x
$cto :: forall x. Rep Position x -> Position
to :: forall x. Rep Position x -> Position
Generic)
instance NFData Position
posFile :: Position -> String
posFile :: Position -> String
posFile = FilePosition -> String
posSrcFile (FilePosition -> String)
-> (Position -> FilePosition) -> Position -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Position -> FilePosition
posFileInfo
posParent :: Position -> (Maybe Position)
posParent :: Position -> Maybe Position
posParent = FilePosition -> Maybe Position
posParentFile (FilePosition -> Maybe Position)
-> (Position -> FilePosition) -> Position -> Maybe Position
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Position -> FilePosition
posFileInfo
type PosLength = (Position,Int)
instance Show Position where
showsPrec :: Int -> Position -> ShowS
showsPrec Int
_ (Position Int
_ Int
row Int
_ (FilePosition String
fname Maybe Position
mparent)) =
String -> ShowS
showString String
"(" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
0 String
fname ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
": line " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
0 Int
row ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
ShowS -> (Position -> ShowS) -> Maybe Position -> ShowS
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ShowS
forall a. a -> a
id (\Position
p -> String -> ShowS
showString String
", in file included from " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Position -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
0 Position
p) Maybe Position
mparent ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
String -> ShowS
showString String
")"
showsPrec Int
_ Position
NoPosition = String -> ShowS
showString String
"<no file>"
showsPrec Int
_ Position
BuiltinPosition = String -> ShowS
showString String
"<builtin>"
showsPrec Int
_ Position
InternalPosition = String -> ShowS
showString String
"<internal>"
position :: Int -> String -> Int -> Int -> Maybe Position -> Position
position :: Int -> String -> Int -> Int -> Maybe Position -> Position
position Int
offset String
fname Int
row Int
col Maybe Position
mparent = Int -> Int -> Int -> FilePosition -> Position
Position Int
offset Int
row Int
col (String -> Maybe Position -> FilePosition
FilePosition String
fname Maybe Position
mparent)
class Pos a where
posOf :: a -> Position
initPos :: FilePath -> Position
initPos :: String -> Position
initPos String
file = Int -> Int -> Int -> FilePosition -> Position
Position Int
0 Int
1 Int
1 (String -> Maybe Position -> FilePosition
FilePosition String
file Maybe Position
forall a. Maybe a
Nothing)
isSourcePos :: Position -> Bool
isSourcePos :: Position -> Bool
isSourcePos (Position Int
_ Int
_ Int
_ FilePosition
_) = Bool
True
isSourcePos Position
_ = Bool
False
nopos :: Position
nopos :: Position
nopos = Position
NoPosition
isNoPos :: Position -> Bool
isNoPos :: Position -> Bool
isNoPos Position
NoPosition = Bool
True
isNoPos Position
_ = Bool
False
builtinPos :: Position
builtinPos :: Position
builtinPos = Position
BuiltinPosition
isBuiltinPos :: Position -> Bool
isBuiltinPos :: Position -> Bool
isBuiltinPos Position
BuiltinPosition = Bool
True
isBuiltinPos Position
_ = Bool
False
internalPos :: Position
internalPos :: Position
internalPos = Position
InternalPosition
isInternalPos :: Position -> Bool
isInternalPos :: Position -> Bool
isInternalPos Position
InternalPosition = Bool
True
isInternalPos Position
_ = Bool
False
{-# INLINE incPos #-}
incPos :: Position -> Int -> Position
incPos :: Position -> Int -> Position
incPos (Position Int
offs Int
row Int
col FilePosition
fpos) Int
n = Int -> Int -> Int -> FilePosition -> Position
Position (Int
offs Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
n) Int
row (Int
col Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
n) FilePosition
fpos
incPos Position
p Int
_ = Position
p
{-# INLINE retPos #-}
retPos :: Position -> Position
retPos :: Position -> Position
retPos (Position Int
offs Int
row Int
_ FilePosition
fpos) = Int -> Int -> Int -> FilePosition -> Position
Position (Int
offsInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1) (Int
row Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Int
1 FilePosition
fpos
retPos Position
p = Position
p
{-# INLINE incOffset #-}
incOffset :: Position -> Int -> Position
incOffset :: Position -> Int -> Position
incOffset (Position Int
o Int
r Int
c FilePosition
f) Int
n = Int -> Int -> Int -> FilePosition -> Position
Position (Int
o Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
n) Int
r Int
c FilePosition
f
incOffset Position
pos Int
_ = Position
pos