Language.C.Data.Position

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

Portability | ghc
Stability | experimental
Maintainer | benedikt.huber@gmail.com
Safe Haskell | None

Language.C.Data.Position

Description

Source code position

Synopsis

- data Position = Position String !Int !Int
- initPos :: FilePath -> Position
- posFile :: Position -> String
- posRow :: Position -> Int
- posColumn :: Position -> Int
- isSourcePos :: Position -> Bool
- nopos :: Position
- isNoPos :: Position -> Bool
- builtinPos :: Position
- isBuiltinPos :: Position -> Bool
- internalPos :: Position
- isInternalPos :: Position -> Bool
- incPos :: Position -> Int -> Position
- tabPos :: Position -> Position
- retPos :: Position -> Position
- adjustPos :: FilePath -> Int -> Position -> Position
- class Pos a where
  - posOf :: a -> Position

# Documentation

data Position

uniform representation of source file positions; the order of the arguments is important as it leads to the desired ordering of source positions

Constructors

Position String !Int !Int |

Instances

Eq Position |
Data Position |
Ord Position |
Read Position |
Show Position |
Typeable Position |

initPos :: FilePath -> Position

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

posFile :: Position -> String

get the source file of the specified position. Fails unless `isSourcePos pos`.

posRow :: Position -> Int

get the line number of the specified position. Fails unless `isSourcePos pos`

posColumn :: Position -> Int

get the column of the specified position. Fails unless `isSourcePos pos`

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

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

tabPos :: Position -> Position

Deprecated: Use 'incPos column-adjustment' instead

advance column to next tab positions (tabs are considered to be at every 8th 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.

class Pos a where

class of type which aggregate a source code location

Methods

posOf :: a -> Position

Instances

Pos NodeInfo |
Pos Ident |
Pos CStrLit |
Pos CConst |
Pos CBuiltin |
Pos CExpr |
Pos CAttr |
Pos CDesignator |
Pos CInit |
Pos CEnum |
Pos CStructUnion |
Pos CTypeQual |
Pos CTypeSpec |
Pos CStorageSpec |
Pos CDeclSpec |
Pos CBlockItem |
Pos CAsmOperand |
Pos CAsmStmt |
Pos CStat |
Pos CDerivedDeclr |
Pos CDeclr |
Pos CDecl |
Pos CFunDef |
Pos CExtDecl |
Pos CTranslUnit |
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 |
Pos a => Pos [a] |