module Errorloc:sig
..end
The module stores the current file,line, and working directory in a hidden internal state, modified by the three following functions.
val newline : unit -> unit
Call this function to announce a new line
val currentLoc : unit -> Lexing.position * Lexing.position
val setCurrentWorkingDirectory : string -> unit
This function is used especially when the preprocessor has generated linemarkers in the output that let us know the current working directory at the time of preprocessing (option -fworking-directory for GNU CPP).
val setCurrentFile : ?normalize:bool -> string -> unit
If normalize is false, setCurrentFile ~normalize:false path
accepts path
as the current file "as is". Else (the default), if
path
is relative, make it relative to the current working
directory if it has been set; then in any case attempts to shorten
the path to the current file using Filepath.normalize
.
This function should not be called with a string argument which
has been already normalized (because normalization can make path
relative to a different path).
val setCurrentLine : int -> unit
val startParsing : string -> Lexing.lexbuf
Call this function to start parsing.
val finishParsing : unit -> unit
Call this function to finish parsing and close the input channel
val pp_context_from_file : ?ctx:int -> ?start_line:int -> Format.formatter -> Lexing.position -> unit
prints the line identified by the position, together with ctx
lines
of context before and after. ctx
defaults to 2.
If start_line
is specified, then all lines between start_line
and
pos.pos_lnum
are considered part of the error.
val parse_error : ?source:Lexing.position ->
('a, Format.formatter, unit, 'b) Pervasives.format4 -> 'a
Parse errors are usually fatal, but their reporting is sometimes
delayed until the end of the current parsing phase. Functions that
intend to ultimately fail should call Errorloc.clear_errors
when they
start, and check Errorloc.had_errors
when they end.
val had_errors : unit -> bool
Has an error been raised since the last call to Errorloc.clear_errors
?
val clear_errors : unit -> unit