Write explicit interface for Expand_to
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
eab7c46bdb
commit
cadee0e661
|
@ -131,7 +131,28 @@ module Expand = struct
|
|||
end
|
||||
end
|
||||
|
||||
module type Expand_intf = sig
|
||||
type context
|
||||
type expansion
|
||||
|
||||
val expand
|
||||
: context
|
||||
-> t
|
||||
-> allow_multivalue:bool
|
||||
-> f:(Loc.t -> string -> expansion option)
|
||||
-> expansion Expand.Full.t
|
||||
|
||||
val partial_expand
|
||||
: context
|
||||
-> t
|
||||
-> allow_multivalue:bool
|
||||
-> f:(Loc.t -> string -> expansion option)
|
||||
-> expansion Expand.Partial.t
|
||||
end
|
||||
|
||||
module Expand_to(V: EXPANSION) = struct
|
||||
type expansion = V.t
|
||||
type context = V.context
|
||||
|
||||
let check_valid_multivalue syntax ~var t x =
|
||||
if not t.quoted && V.is_multivalued x then
|
||||
|
|
|
@ -79,24 +79,27 @@ module Expand : sig
|
|||
end
|
||||
end
|
||||
|
||||
module Expand_to(V : EXPANSION) : sig
|
||||
module type Expand_intf = sig
|
||||
type context
|
||||
type expansion
|
||||
|
||||
val expand
|
||||
: V.context
|
||||
: context
|
||||
-> t
|
||||
-> allow_multivalue:bool
|
||||
-> f:(Loc.t -> string -> V.t option)
|
||||
-> V.t Expand.Full.t
|
||||
-> f:(Loc.t -> string -> expansion option)
|
||||
-> expansion Expand.Full.t
|
||||
(** [expand t ~f] return [t] where all variables have been expanded
|
||||
using [f]. If [f loc var] return [Some x], the variable [var] is
|
||||
replaced by [x]; otherwise, the variable is inserted using the syntax
|
||||
it was originally defined with: ${..} or $(..) *)
|
||||
|
||||
val partial_expand
|
||||
: V.context
|
||||
: context
|
||||
-> t
|
||||
-> allow_multivalue:bool
|
||||
-> f:(Loc.t -> string -> V.t option)
|
||||
-> V.t Expand.Partial.t
|
||||
-> f:(Loc.t -> string -> expansion option)
|
||||
-> expansion Expand.Partial.t
|
||||
(** [partial_expand t ~f] is like [expand_generic] where all
|
||||
variables that could be expanded (i.e., those for which [f]
|
||||
returns [Some _]) are. If all the variables of [t] were
|
||||
|
@ -104,6 +107,9 @@ module Expand_to(V : EXPANSION) : sig
|
|||
least a variable of [t], it returns a string-with-vars. *)
|
||||
end
|
||||
|
||||
module Expand_to(V : EXPANSION) : Expand_intf
|
||||
with type expansion = V.t and type context = V.context
|
||||
|
||||
val expand
|
||||
: t
|
||||
-> f:(Loc.t -> string -> string option)
|
||||
|
|
Loading…
Reference in New Issue