language-c-0.6.1: Analysis and generation of C code

Copyright | (c) [1995..2000] Manuel M. T. Chakravarty [2008..2009] Benedikt Huber
License | BSD-style
Maintainer | benedikt.huber@gmail.com
Stability | experimental
Portability | ghc
Safe Haskell | None
Language | Haskell98

Language.C.Data.Position

Description

Source code position

Synopsis

- data Position
- position :: Int -> String -> Int -> Int -> Position
- type PosLength = (Position, Int)
- posFile :: Position -> String
- posRow :: Position -> Int
- posColumn :: Position -> Int
- posOffset :: Position -> Int
- initPos :: FilePath -> Position
- isSourcePos :: Position -> Bool
- nopos :: Position
- isNoPos :: Position -> Bool
- builtinPos :: Position
- isBuiltinPos :: Position -> Bool
- internalPos :: Position
- isInternalPos :: Position -> Bool
- incPos :: Position -> Int -> Position
- retPos :: Position -> Position
- adjustPos :: FilePath -> Int -> Position -> Position
- incOffset :: Position -> Int -> Position
- class Pos a where

# Documentation

data Position #

uniform representation of source file positions

Instances

Eq Position # |
Methods (==) :: Position -> Position -> Bool # (/=) :: Position -> Position -> Bool #
Data Position # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Position -> c Position # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Position # toConstr :: Position -> Constr # dataTypeOf :: Position -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Position) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position) # gmapT :: (forall b. Data b => b -> b) -> Position -> Position # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r # gmapQ :: (forall d. Data d => d -> u) -> Position -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Position -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Position -> m Position # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position #
Ord Position # |
Methods compare :: Position -> Position -> Ordering # (<) :: Position -> Position -> Bool # (<=) :: Position -> Position -> Bool # (>) :: Position -> Position -> Bool # (>=) :: Position -> Position -> Bool # max :: Position -> Position -> Position # min :: Position -> Position -> Position #
Show Position # |
Methods showsPrec :: Int -> Position -> ShowS # show :: Position -> String # showList :: [Position] -> ShowS #

position :: Int -> String -> Int -> Int -> Position #

`position absoluteOffset fileName lineNumber columnNumber` initializes a `Position` using the given arguments

type PosLength = (Position, Int) #

Position and length of a token

posFile :: Position -> String #

source file

posRow :: Position -> Int #

row (line) in the original file. Affected by #LINE pragmas.

posColumn :: Position -> Int #

column in the preprocessed file. Inaccurate w.r.t. to the original file in the presence of preprocessor macros.

posOffset :: Position -> Int #

absolute offset in the preprocessed file

initPos :: FilePath -> Position #

initialize a Position to the start of the translation unit starting in the given file

isSourcePos :: Position -> Bool #

returns `True` if the given position refers to an actual source file

nopos :: Position #

no position (for unknown position information)

isNoPos :: Position -> Bool #

returns `True` if the there is no position information available

builtinPos :: Position #

position attached to built-in objects

isBuiltinPos :: Position -> Bool #

returns `True` if the given position refers to a builtin definition

internalPos :: Position #

position used for internal errors

isInternalPos :: Position -> Bool #

returns `True` if the given position is internal

incPos :: Position -> Int -> Position #

advance column

retPos :: Position -> Position #

advance to next line

adjustPos :: FilePath -> Int -> Position -> Position #

adjust position: change file and line number, reseting column to 1. This is usually used for #LINE pragmas. The absolute offset is not changed - this can be done by `adjustPos newFile line . incPos (length pragma)`.

incOffset :: Position -> Int -> Position #

advance just the offset

class Pos a where #

class of type which aggregate a source code location

Minimal complete definition

posOf

Methods

posOf :: a -> Position #

Instances

Pos NodeInfo # |
Methods posOf :: NodeInfo -> Position #
Pos Ident # |
Methods posOf :: Ident -> Position #
Pos Attr # |
Methods posOf :: Attr -> Position #
Pos Enumerator # |
Methods posOf :: Enumerator -> Position #
Pos EnumType # |
Methods posOf :: EnumType -> Position #
Pos CompType # |
Methods posOf :: CompType -> Position #
Pos EnumTypeRef # |
Methods posOf :: EnumTypeRef -> Position #
Pos CompTypeRef # |
Methods posOf :: CompTypeRef -> Position #
Pos TypeDefRef # |
Methods posOf :: TypeDefRef -> Position #
Pos TypeDef # |
Methods posOf :: TypeDef -> Position #
Pos MemberDecl # |
Methods posOf :: MemberDecl -> Position #
Pos ParamDecl # |
Methods posOf :: ParamDecl -> Position #
Pos FunDef # |
Methods posOf :: FunDef -> Position #
Pos ObjDef # |
Methods posOf :: ObjDef -> Position #
Pos Decl # |
Methods posOf :: Decl -> Position #
Pos DeclEvent # |
Methods posOf :: DeclEvent -> Position #
Pos IdentDecl # |
Methods posOf :: IdentDecl -> Position #
Pos TagDef # |
Methods posOf :: TagDef -> Position #
CNode t1 => Pos (CStringLiteral t1) # |
Methods posOf :: CStringLiteral t1 -> Position #
CNode t1 => Pos (CConstant t1) # |
Methods posOf :: CConstant t1 -> Position #
CNode t1 => Pos (CBuiltinThing t1) # |
Methods posOf :: CBuiltinThing t1 -> Position #
CNode t1 => Pos (CExpression t1) # |
Methods posOf :: CExpression t1 -> Position #
CNode t1 => Pos (CAttribute t1) # |
Methods posOf :: CAttribute t1 -> Position #
CNode t1 => Pos (CPartDesignator t1) # |
Methods posOf :: CPartDesignator t1 -> Position #
CNode t1 => Pos (CInitializer t1) # |
Methods posOf :: CInitializer t1 -> Position #
CNode t1 => Pos (CEnumeration t1) # |
Methods posOf :: CEnumeration t1 -> Position #
CNode t1 => Pos (CStructureUnion t1) # |
Methods posOf :: CStructureUnion t1 -> Position #
CNode t1 => Pos (CAlignmentSpecifier t1) # |
Methods posOf :: CAlignmentSpecifier t1 -> Position #
CNode t1 => Pos (CFunctionSpecifier t1) # |
Methods posOf :: CFunctionSpecifier t1 -> Position #
CNode t1 => Pos (CTypeQualifier t1) # |
Methods posOf :: CTypeQualifier t1 -> Position #
CNode t1 => Pos (CTypeSpecifier t1) # |
Methods posOf :: CTypeSpecifier t1 -> Position #
CNode t1 => Pos (CStorageSpecifier t1) # |
Methods posOf :: CStorageSpecifier t1 -> Position #
CNode t1 => Pos (CDeclarationSpecifier t1) # |
Methods posOf :: CDeclarationSpecifier t1 -> Position #
CNode t1 => Pos (CCompoundBlockItem t1) # |
Methods posOf :: CCompoundBlockItem t1 -> Position #
CNode t1 => Pos (CAssemblyOperand t1) # |
Methods posOf :: CAssemblyOperand t1 -> Position #
CNode t1 => Pos (CAssemblyStatement t1) # |
Methods posOf :: CAssemblyStatement t1 -> Position #
CNode t1 => Pos (CStatement t1) # |
Methods posOf :: CStatement t1 -> Position #
CNode t1 => Pos (CDerivedDeclarator t1) # |
Methods posOf :: CDerivedDeclarator t1 -> Position #
CNode t1 => Pos (CDeclarator t1) # |
Methods posOf :: CDeclarator t1 -> Position #
CNode t1 => Pos (CDeclaration t1) # |
Methods posOf :: CDeclaration t1 -> Position #
CNode t1 => Pos (CFunctionDef t1) # |
Methods posOf :: CFunctionDef t1 -> Position #
CNode t1 => Pos (CExternalDeclaration t1) # |
Methods posOf :: CExternalDeclaration t1 -> Position #
CNode t1 => Pos (CTranslationUnit t1) # |
Methods posOf :: CTranslationUnit t1 -> Position #