module Annotated: sig .. end
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 = {
}
Range information for annotated S-expressions
type t = Pre_sexp.Annotated.t =
S-expression annotated with location information
type 'a conv = [ `Error of exn * t | `Result of 'a ]
Type of conversion results of annotated S-expressions.
exception Conv_exn of string * exn
Exception 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.t
get_sexp annot_sexp
Returns S-expression associated with annotated
S-expression annot_sexp.
val get_range : t -> range
get_range annot_sexp
Returns the range associated with annotated
S-expression annot_sexp.
val find_sexp : t -> Type.t -> t option
find_sexp annot_sexp sexp
Returns Some res where res is the
annotated S-expression that is physically equivalent to sexp in
annot_sexp, or None if there is no such S-expression.
Annotated (partial) parsing
val parse : ?parse_pos:Sexp_intf.S.Parse_pos.t ->
?len:int ->
string -> (string, t) Sexp_intf.S.parse_result
val parse_bigstring : ?parse_pos:Sexp_intf.S.Parse_pos.t ->
?len:int ->
Sexp_intf.S.bigstring ->
(Sexp_intf.S.bigstring, t) Sexp_intf.S.parse_result
val input_sexp : ?parse_pos:Sexp_intf.S.Parse_pos.t ->
Pervasives.in_channel -> t
val input_sexps : ?parse_pos:Sexp_intf.S.Parse_pos.t ->
?buf:string -> Pervasives.in_channel -> t list
val input_rev_sexps : ?parse_pos:Sexp_intf.S.Parse_pos.t ->
?buf:string -> Pervasives.in_channel -> t list
Loading of annotated S-expressions
NOTE: these functions should only be used if an annotated S-expression
is required.
val load_sexp : ?strict:bool -> ?buf:string -> string -> t
val load_sexps : ?buf:string -> string -> t list
val load_rev_sexps : ?buf:string -> string -> t list
String and bigstring conversions
val of_string : string -> t
val of_bigstring : Sexp_intf.S.bigstring -> t
Converters using annotations for determining error locations
val conv : (Type.t -> 'a) -> t -> 'a conv
conv f annot_sexp converts the S-expression associated with
annotated S-expression annot_sexp using f.
Returns `Result
res on success, or `Error (exn, sub_annot_sexp) otherwise, where
exn is the exception associated with the conversion error, and
sub_annot_sexp is the annotated S-expression on which conversion
failed.
val get_conv_exn : file:string -> exc:exn -> t -> exn
get_conv_exn ~file ~exc annot_sexp
Returns the exception that
would be raised for a given file and exception exc
if conversion had failed on annotated S-expression annot_sexp.
The format of the exception message is "file:line:col"