module Pa_estring:sig
..end
typespecifier =
string
type
context
val register_expr_specifier : specifier ->
(context ->
Camlp4.PreCast.Loc.t -> string -> Camlp4.PreCast.Ast.expr) ->
unit
register_expr_specifier spec f
registers f
as a mapping
function for string with the specifier spec
in expressions.val register_patt_specifier : specifier ->
(context ->
Camlp4.PreCast.Loc.t -> string -> Camlp4.PreCast.Ast.patt) ->
unit
register_patt_specifier spec f
same thing but for strings in
patternsval register_when_specifier : specifier ->
(context ->
Camlp4.PreCast.Loc.t ->
Camlp4.PreCast.Ast.ident -> string -> Camlp4.PreCast.Ast.expr) ->
unit
register_when_specifier spec f
same thing, but for strings in
match case, which will be compared using a when clause. f
takes as argument the identifier used in the pattern and the
string.context -> Camlp4.PreCast.Ast.expr -> Camlp4.PreCast.Ast.ident
: register_shared_expr context expr
registers expr
as a shared
constant and return the identifier to which it is bound. The
binding will be placed in the current definition.
for example with the following specifier:
register_expr_specifier "u"
(fun context _loc str ->
let id = register_shared_expr context <:expr< UTF8.of_string $str:str$ >> in
<:expr< $id:id$ >>)
The following definition:
let f x y z = u"foo"
will be expanded to:
let f =
let __estring_shared_0 = UTF8.of_string "foo" in
fun x y z -> __estring_shared_0
(char * Loc.t) list
is not
suitable since we do not know the location of the end of the
list. The right choise is:type 'a
llist =
| |
Nil of |
| |
Cons of |
val loc_of_llist : 'a llist -> Camlp4.PreCast.Loc.t
val llength : 'a llist -> int
val lfoldr : (Camlp4.PreCast.Loc.t -> 'a -> 'acc -> 'acc) ->
(Camlp4.PreCast.Loc.t -> 'acc) -> 'a llist -> 'acc
lfoldr f g l
fold_right-like function for llist.
For example:
lfoldr f g (Cons(loc1, 1, Cons(loc2, 2, Nil loc3)))
is the same as:
f loc1 1 (f loc2 2 (g loc3))
val list_of_llist : 'a llist -> 'a list
val llist_of_list : Camlp4.PreCast.Loc.t -> 'a list -> 'a llist
llist_of_list loc l
Create a llist with all elements from l
.
The nth element will be at loc + n.val ldrop : int -> 'a llist -> 'a llist
ldrop count ll
returns ll
without its firsts count
elements.val ltake : int -> 'a llist -> 'a llist
ltake count ll
returns the firsts count
elements of ll
.val lappend : 'a llist -> 'a llist -> 'a llist
lappend ll1 ll2
appends ll2
to ll1
val llist_expr : (Camlp4.PreCast.Loc.t -> 'a -> Camlp4.PreCast.Ast.expr) ->
'a llist -> Camlp4.PreCast.Ast.expr
llist_expr f ll
returns the expression representing a list
with element obtained by applying f
on element of ll
val llist_patt : (Camlp4.PreCast.Loc.t -> 'a -> Camlp4.PreCast.Ast.patt) ->
'a llist -> Camlp4.PreCast.Ast.patt
val unescape : Camlp4.PreCast.Loc.t -> string -> char llist
unescape loc str
returns the unescaped version of str
where
each unescaped character position has been computed