language-c-0.4.7: 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
  - posOf :: a -> Position

# Documentation

data Position

uniform representation of source file positions

Instances

Eq Position |
Data Position |
Ord Position |
Show Position |

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

Deprecated: column number information is inaccurate in presence of macros - do not rely on it.

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

Methods

posOf :: a -> Position

Instances

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