Module Sexp.Annotated
Module for parsing S-expressions annotated with location information
type pos= Pre_sexp.Annotated.pos={line : int;col : int;offset : int;}Position information for annotated S-expressions
type range= Pre_sexp.Annotated.range={start_pos : pos;end_pos : pos;}Range information for annotated S-expressions
type t= Pre_sexp.Annotated.t=|Atom of range * Type.t|List of range * t list * Type.tS-expression annotated with location information
type 'a conv=[|`Result of 'a|`Error of exn * t]Type of conversion results of annotated S-expressions.
exceptionConv_exn of string * exnException associated with conversion errors. First argument describes the location, the second the reason.
type stack= Pre_sexp.Annotated.stack={mutable positions : pos list;mutable stack : t list list;}Stack used by annotation parsers
val get_sexp : t -> Type.tget_sexp annot_sexp- returns
S-expression associated with annotated S-expression
annot_sexp.
val get_range : t -> rangeget_range annot_sexp- returns
the range associated with annotated S-expression
annot_sexp.
val find_sexp : t -> Type.t -> t optionfind_sexp annot_sexp sexp- returns
Some reswhereresis the annotated S-expression that is physically equivalent tosexpinannot_sexp, orNoneif there is no such S-expression.
Annotated (partial) parsing
val parse : ?parse_pos:Parse_pos.t -> ?len:int -> string -> (string, t) parse_resultparse ?parse_pos ?len strsame asparse, but returns an S-expression annotated with location information.
val parse_bigstring : ?parse_pos:Parse_pos.t -> ?len:int -> bigstring -> (bigstring, t) parse_resultparse_bigstring ?parse_pos ?len strsame asparse_bigstring, but returns an S-expression annotated with location information.
val input_sexp : ?parse_pos:Parse_pos.t -> Stdlib.in_channel -> tinput_sexp ?parse_pos iclikeinput_sexp, but returns an annotated S-expression instead.
val input_sexps : ?parse_pos:Parse_pos.t -> ?buf:bytes -> Stdlib.in_channel -> t listinput_sexps ?parse_pos ?buf iclikeinput_sexps, but returns a list of annotated S-expressions.
val input_rev_sexps : ?parse_pos:Parse_pos.t -> ?buf:bytes -> Stdlib.in_channel -> t listinput_sexps ?parse_pos ?buf iclikeinput_rev_sexps, but returns a list of annotated S-expressions.
Loading of annotated S-expressions
val load_sexp : ?strict:bool -> ?buf:bytes -> string -> tload_sexp ?strict ?buf filelikeload_sexp, but returns an annotated S-expression.
val load_sexps : ?buf:bytes -> string -> t listload_sexps ?buf filelikeload_sexps, but returns a list of annotated S-expressions.
val load_rev_sexps : ?buf:bytes -> string -> t listload_rev_sexps ?buf filelikeload_rev_sexps, but returns a list of annotated S-expressions.
String and bigstring conversions
val conv : (Type.t -> 'a) -> t -> 'a convconv f annot_sexpconverts the S-expression associated with annotated S-expressionannot_sexpusingf.- returns
`Result reson success, or`Error (exn, sub_annot_sexp)otherwise, whereexnis the exception associated with the conversion error, andsub_annot_sexpis the annotated S-expression on which conversion failed.
val get_conv_exn : file:string -> exc:exn -> t -> exnget_conv_exn ~file ~exc annot_sexp- returns
the exception that would be raised for a given
fileand exceptionexcif conversion had failed on annotated S-expressionannot_sexp. The format of the exception message is "file:line:col"