2016-12-02 13:54:32 +00:00
|
|
|
(** [Ordered_set_lang.t] is a sexp-based representation for an ordered list of strings,
|
|
|
|
with some set like operations. *)
|
|
|
|
|
|
|
|
open Import
|
|
|
|
|
|
|
|
type t
|
2017-02-25 17:53:39 +00:00
|
|
|
val t : t Sexp.Of_sexp.t
|
2016-12-02 13:54:32 +00:00
|
|
|
|
2018-02-08 10:12:46 +00:00
|
|
|
(** Return the location of the set. [loc standard] returns [None] *)
|
|
|
|
val loc : t -> Loc.t option
|
|
|
|
|
|
|
|
(** Value parsed from elements in the DSL *)
|
|
|
|
module type Value = sig
|
|
|
|
type t
|
|
|
|
val name : t -> string
|
|
|
|
end
|
|
|
|
|
|
|
|
module Make(Value : Value) : sig
|
|
|
|
(** Evaluate an ordered set. [standard] is the interpretation of [:standard] inside the
|
|
|
|
DSL. *)
|
|
|
|
val eval
|
|
|
|
: t
|
|
|
|
-> parse:(loc:Loc.t -> string -> Value.t)
|
|
|
|
-> standard:Value.t list
|
|
|
|
-> Value.t list
|
|
|
|
|
|
|
|
(** Same as [eval] but the result is unordered *)
|
|
|
|
val eval_unordered
|
|
|
|
: t
|
|
|
|
-> parse:(loc:Loc.t -> string -> Value.t)
|
|
|
|
-> standard:Value.t String_map.t
|
|
|
|
-> Value.t String_map.t
|
|
|
|
end
|
|
|
|
|
2016-12-02 13:54:32 +00:00
|
|
|
val standard : t
|
|
|
|
val is_standard : t -> bool
|
|
|
|
|
|
|
|
module Unexpanded : sig
|
|
|
|
type expanded = t
|
|
|
|
type t
|
2017-02-25 17:53:39 +00:00
|
|
|
val t : t Sexp.Of_sexp.t
|
2016-12-02 13:54:32 +00:00
|
|
|
val standard : t
|
|
|
|
|
|
|
|
(** List of files needed to expand this set *)
|
2017-08-23 20:56:32 +00:00
|
|
|
val files : t -> f:(String_with_vars.t -> string) -> String_set.t
|
2016-12-02 13:54:32 +00:00
|
|
|
|
|
|
|
(** Expand [t] using with the given file contents. [file_contents] is a map from
|
2016-12-23 15:32:23 +00:00
|
|
|
filenames to their parsed contents. Every [(:include fn)] in [t] is replaced by
|
2017-07-05 19:55:17 +00:00
|
|
|
[Map.find files_contents fn]. Every element is converted to a string using [f]. *)
|
2018-02-08 10:12:46 +00:00
|
|
|
val expand
|
|
|
|
: t
|
|
|
|
-> files_contents:Sexp.Ast.t String_map.t
|
|
|
|
-> f:(String_with_vars.t -> string)
|
|
|
|
-> expanded
|
2016-12-02 13:54:32 +00:00
|
|
|
end with type expanded := t
|