Frama-C API - Filepos
This module handle positions in a source file. Filepos.t is a Frama-C datatype, and comes with usual compare, equal, hash and pretty functions.
compareorders location first by file path, then by offset in the file. This means the position order will be compatible with the apparition order in each file. If no offset information is available in both compared positions, the line then column will be used.hashonly hashes the path and the line of the position.
val pp : Ppx_deriving_runtime.Format.formatter -> t -> Ppx_deriving_runtime.unitval show : t -> Ppx_deriving_runtime.stringtype origin = | Unknown(*Unknown position. This constructor should be avoided.
*)| Original(*The position is in one of the user input files.
*)| Generated of string(*The position is in generated input. The string is a name identifying the generator.
*)| Preprocessed of t(*The position is in file that have been produced from a preprocessing at the given position.
*)| Included of t(*The position is in a file included from the given position
*)
val pp_origin : Ppx_deriving_runtime.Format.formatter -> origin -> Ppx_deriving_runtime.unitval show_origin : origin -> Ppx_deriving_runtime.stringinclude Datatype.S_with_collections with type t := t
include Datatype.S with type t := t
include Datatype.S_no_copy with type t := t
include Datatype.Ty with type t := t
val packed_descr : Structural_descr.packPacked version of the descriptor.
val reprs : t listList of representants of the descriptor.
val hash : t -> intHash function: same spec than Hashtbl.hash.
val mem_project : (Project_skeleton.t -> bool) -> t -> boolmem_project f x must return true iff there is a value p of type Project.t in x such that f p returns true.
module Set : Datatype.Set with type elt = tmodule Map : Datatype.Map with type key = tmodule Hashtbl : Datatype.Hashtbl with type key = tPretty printing
val pretty : Stdlib.Format.formatter -> t -> unitPretty prints a position in the format <file>:<line>, with variants for unknown files or generated positions.
val pretty_long : Stdlib.Format.formatter -> t -> unitPretty prints a position in the format "<file>", line <line> or, if the column number is available, in the format "<file>", line <line>, character <char>, with variants for unknown files or generated positions.
val pretty_debug : Stdlib.Format.formatter -> t -> unitDebug printer. Prints the internal representation of locations.
Construction
val make : ?path:Filepath.t -> ?offset:int -> ?line:int -> ?column:int -> ?origin:origin -> unit -> tMake a new position. The default for origin is Original.
Special positions
Make a new position for a generated input. The generator name is given as a string. If the position is provided, it is copied (except for its origin), else it is unknown.
val unknown : tSpecial representation of an unknown position.
Conversion from/to Lexing.position
Convert a Lexing.position to a Filepos.t.
val to_lexing_pos : t -> Stdlib.Lexing.positionConvert a Filepos.t to a Lexing.position
Position tracking
val update_line : ?path:Filepath.t -> line:int -> t -> tUpdate the current line of the position. Tries to keep track the file inclusions; recursive inclusion is unsupported.
Accessors
Get the original position. If the position is in a preprocessed code, returns the source of the preprocessing otherwise this function is the identity.
val path : t -> Filepath.tGet the path of a position. If the position is in a preprocessed code, returns the original file.
val line : t -> intGet the line of a position, starting at 1. If the position is in a preprocessed code, returns the line in the original file.
val column : t -> intGet the column of the position, starting at 1. If the position is in a preprocessed code and as Frama-C cannot track the column in the original file, this function will likely return 0.
val input_path : t -> Filepath.tGet the path of the input file. Unlike path, if the position is in a preprocessed code, it returns the preprocessed output path.
val input_line : t -> intGet the line in the input file, starting at 1. Unlike line, if the position is in a preprocessed code, it returns the line in the preprocessed output.
val input_column : t -> intGet the column in the input file, starting at 1. Unlike column, if the position is in a preprocessed code, it returns the column in the preprocessed output.
val input_offset : t -> intGet the offset in the input file, starting at 0. Unlike offset, if the position is in a preprocessed code, it returns the offset in the preprocessed output.
val generated_by : t -> string optionIf the origine of the position is Generated name, return Some name else return None.
val is_empty : t -> boolReturn true if all values of the given position are the default values of make.
val is_preprocessed : t -> boolReturns whether the location is a preprocessed file. If true is returned then original will likely not be the identity path and line will likely to return different results than input_path and input_line.
Returns the list of inclusion positions when the position is in preprocessed code; returns nothing if the position is not in an included file.
Datatype with comparison/hash on original source positions
module Original : Datatype.S_with_collections with type t = tThis module provides an alternative datatype where only original positions are considered for compare, equal and hash. This is intended for preprocessed code where the same file can be included several times leading to tokens having different position in the preprocessing output but the same original position.
