B0caml_script
OCaml scripts
val loc : smeta -> B0_text.Tloc.t
loc i
is the text source location of i
.
val loc_errf :
smeta ->
('a, Stdlib.Format.formatter, unit, string) Stdlib.format4 ->
'a
loc_errf smeta fmt
formats an error for the location in smeta.
val of_string : file:B0_std.Fpath.t -> string -> (t, string) Stdlib.result
of_string ?file s
parses a b0caml script from s
. file
is the file used for locations, it must be an absolute file path.
val file : t -> B0_std.Fpath.t
file s
is the script's file.
shebang s
is the optional shebang line without the shebang and the new line.
directories s
are the script's #directory
directives. The location spans the directive's argument. Relative file paths or +
are not resolved. See directory_resolution
.
mod_uses s
are the script's #mod_use
directives. The location spans the directive's argument. Relative file paths are not resolved. See mod_use_resolution
.
val pp_dump : t B0_std.Fmt.t
pp_dump
dumps the parsed script.
val pp_locs : t B0_std.Fmt.t
pp_locs
dumps the source text locations of s
.
#directory
resolutiontype directory_resolution = B0_std.Fpath.t * smeta
The type for #directory
resolution results. An absolute path to a existing directory and the directive where it originates from.
type directory_resolution_error =
B0_std.Fpath.t * smeta * [ `Error of string | `Miss ]
The type for #directory
resolution error. An absolute or logical path that failed to resolve, the directive where it originates from and either a file system error or a missing error.
val directory_resolution_dir : directory_resolution -> B0_std.Fpath.t
directory_resolution_dir res
is the directory mentioned in res
. The file path is syntactically a directory path.
val resolve_directories :
ocamlpath:B0caml_ocamlpath.t ->
t ->
(directory_resolution list, directory_resolution_error list) Stdlib.result
resolve_directories ~ocamlpath s
resolves the #directory
directives of s
according to ocamlpath
. See the types for a description of the result.
#mod_use
resolutiontype mod_use_resolution = B0_std.Fpath.t option * B0_std.Fpath.t * smeta
The type for #mod_use
resolution results. An absolute path to an optional existing interface file, an absolute path to an existing implementation file and the directive where it originates from.
type mod_use_resolution_error =
B0_std.Fpath.t * smeta * [ `Error of string | `Miss ]
The type for #mod_use
resolution errors. An absolute paths to an a resolved file and either a file system error or a missing file.
val mod_use_resolution_files : mod_use_resolution -> B0_std.Fpath.t list
mod_use_resolution_files res
are the files mentioned in res
.
val resolve_mod_uses :
t ->
(mod_use_resolution list, mod_use_resolution_error list) Stdlib.result
resolve_mod_uses s
resolves the #mod_use
directives of s
. See the types for a description of the result.
val src :
mod_use_resolutions:mod_use_resolution list ->
t ->
(string, string) Stdlib.result
src ~mod_use_resolutions s
uses mod_use_resolutions
(see resolve_mod_uses
) to produce the final script source of s
.