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

Portabilityghc
Stabilityexperimental
Maintainerbenedikt.huber@gmail.com
Safe HaskellNone

Language.C.Data.Position

Description

Source code position

Synopsis

Documentation

data Position Source

uniform representation of source file positions

position :: Int -> String -> Int -> Int -> PositionSource

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

type PosLength = (Position, Int)Source

Position and length of a token

posFile :: Position -> StringSource

source file

posRow :: Position -> IntSource

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

posColumn :: Position -> IntSource

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

posOffset :: Position -> IntSource

absolute offset in the preprocessed file

initPos :: FilePath -> PositionSource

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

isSourcePos :: Position -> BoolSource

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

nopos :: PositionSource

no position (for unknown position information)

isNoPos :: Position -> BoolSource

returns True if the there is no position information available

builtinPos :: PositionSource

position attached to built-in objects

isBuiltinPos :: Position -> BoolSource

returns True if the given position refers to a builtin definition

internalPos :: PositionSource

position used for internal errors

isInternalPos :: Position -> BoolSource

returns True if the given position is internal

incPos :: Position -> Int -> PositionSource

advance column

retPos :: Position -> PositionSource

advance to next line

adjustPos :: FilePath -> Int -> Position -> PositionSource

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 -> PositionSource

advance just the offset

class Pos a whereSource

class of type which aggregate a source code location

Methods

posOf :: a -> PositionSource