Frama-C:
Plug-ins:
Libraries:

Frama-C API - Fileloc

This module handle locations in a source file. Fileloc.t is a Frama-C datatype, and comes with usual compare, equal, hash and pretty functions.

  • compare first compares the starting position of the location then - if they are equal - compares the ending position.
  • hash only hashes the first position.
type t = Filepos.t * Filepos.t
val pp : Ppx_deriving_runtime.Format.formatter -> t -> Ppx_deriving_runtime.unit
val show : t -> Ppx_deriving_runtime.string
include Datatype.S_with_collections with type t := t
include Datatype.S with type t := t
include Datatype.S_no_copy with type t := t
val datatype_name : string

Unique name of the datatype.

val datatype_descr : t Descr.t

Datatype descriptor.

val packed_descr : Structural_descr.pack

Packed version of the descriptor.

val reprs : t list

List of representants of the descriptor.

val equal : t -> t -> bool
val compare : t -> t -> int

Comparison: same spec than Stdlib.compare.

val hash : t -> int

Hash function: same spec than Hashtbl.hash.

val mem_project : (Project_skeleton.t -> bool) -> t -> bool

mem_project f x must return true iff there is a value p of type Project.t in x such that f p returns true.

val copy : t -> t

Deep copy: no possible sharing between x and copy x.

module Set : Datatype.Set with type elt = t
module Map : Datatype.Map with type key = t
module Hashtbl : Datatype.Hashtbl with type key = t
val unknown : t

Special representation of an unknown location.

val generated : ?loc:t -> string -> t

Make a new location for a generated input. The generator name is given as a string. If the location is provided, it is copied (except for its origin), else it is unknown.

Pretty printing

val pretty : Stdlib.Format.formatter -> t -> unit

Pretty prints a locaton in a short format file:<line1>-<line2>:<char1>-<char2>, with variants depending on if both positions are in the same file/line/column. Generated locations are printed inside a tag <generated by <generator> from <loc>>

val pretty_long : t Pretty_utils.formatter

Pretty prints a locaton in a long format "file", lines <line1>-<line2>, characters <char1>-<char2>, with variants depending on if both positions are in the same file/line/column. Generated locations are printed as such generated by <generator> from <loc>.

val pretty_long_with_inclusions : t Pretty_utils.formatter

Same as pretty_long but also prints the list of inclusion.

val pretty_debug : t Pretty_utils.formatter

Pretty-prints the ocaml internal representation of a location, for debug purposes.

  • since 22.0-Titanium

Conversion from/to Lexing.position

val of_lexing_loc : (Stdlib.Lexing.position * Stdlib.Lexing.position) -> t

Convert a pair of Lexing.position to a Fileloc.t.

val to_lexing_loc : t -> Stdlib.Lexing.position * Stdlib.Lexing.position

Convert a pair of Fileloc.t to a Lexing.position.

Accessors

val line : t -> int

Get the first line of the location.

val path : t -> Filepath.t

Get the file path of the location.

val is_empty : t -> bool

is_empty loc returns true if the first position is empty according to Filepos.is_empty.

Datatype with comparison/hash on original source positions

This module provides an alternative datatype where only original location are considered for compare, equal and hash. See Filepos.origin.Original.