Pacomb.PosSourceshort position
Type to represent an interval between two position
a phantom position, used for grammar accepting the empty input, and other reference initialisation
type pos_info = {start_line : int;start_col : int;start_line_offset : int;start_byte : int;end_line : int;end_col : int;end_line_offset : int;end_byte : int;file_name : string;text : string;}Fully informed positions
Function to recover full position from the information stored in located data.
The optional paramater ~relocate, which is identity by default allows to deal with situation like a moved file since position was produced, or a file name stored with a relative position. The file_name in the pos_info is not affected by relocate which is only used to reopen the file.
The optionnal parameter ~text (false by default) will fill the text field within the position if it is true. Otherwise the text field is set to the empty string.
This function may raise No_detailled_position is the file can not be reopen or File_changed if the file is present but changed its last modification time of size.
type quote = {numbers : bool;includes line number
*)prefix : string;prefix added after each newline but not added for the first printed line
*)header : string;header, added as first line if non empty
*)enlight : string -> string;used to transform the quoted part of the printed lines
*)}configuration for quoting file
default quote: ``` let ulined : string -> string = fun s -> "\0270m\027[4m" ^ s ^ "\027[0m" let default_quote = { numbers = true ; prefix = "" ; header = "" ; footer = "" ; enlight = ulined } '''
Style for printing positions:
printing for the three kind of positions, and the current position of a buffer.
The three functions below will print only the byte_pos if the file cannot be reopenned. The exception File_changed is raised if the file changed since last openning.
If quote is given, the file is quoted.
The three functions below will print only the byte_pos if the file cannot be reopenned. The exception File_changed is raised if the file changed since last openning.
If quote is given, the file is quoted.
val print_buf_pos :
?style:style ->
?quote:quote ->
unit ->
out_channel ->
(Input.buffer * Input.idx) ->
unitException raised when parsing fails
handle_exception fn v applies the function fn to v and handles the Parse_error exception. In particular, a parse error message is presented to the user in case of a failure, then error e is called where e is the raised exception. The default error is fun _ -> exit 1. raise is another possibility.