Library
Module
Module type
Parameter
Class
Class type
module type Callbacks_for_fold_common = sig ... end
module type Callbacks_for_fold_nonrecursive = sig ... end
module type Callbacks_for_fold_recursive = sig ... end
module type Fold = sig ... end
module type Fold_partial = sig ... end
module Field : sig ... end
module Case_sensitivity : sig ... end
and list_grammar =
Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.list_grammar =
| Empty
| Cons of grammar * list_grammar
| Many of grammar
| Fields of record
and record = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.record = {
allow_extra_fields : bool;
fields : field with_tag_list list;
}
and field = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.field = {
name : string;
required : bool;
args : list_grammar;
}
and variant = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.variant = {
case_sensitivity : case_sensitivity;
clauses : clause with_tag_list list;
}
and clause = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.clause = {
name : string;
clause_kind : clause_kind;
}
and clause_kind = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.clause_kind =
| Atom_clause
| List_clause of {
args : list_grammar;
}
and 'a with_tag = 'a Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.with_tag =
{
key : string;
value : Core.Sexp.t;
grammar : 'a;
}
and 'a with_tag_list =
'a Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.with_tag_list =
| Tag of 'a with_tag_list with_tag
| No_tag of 'a
and defn = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.defn = {
tycon : string;
tyvars : string list;
grammar : grammar;
}
val bin_shape_grammar : Core.Bin_prot.Shape.t
val bin_shape_list_grammar : Core.Bin_prot.Shape.t
val bin_shape_record : Core.Bin_prot.Shape.t
val bin_shape_field : Core.Bin_prot.Shape.t
val bin_shape_case_sensitivity : Core.Bin_prot.Shape.t
val bin_shape_variant : Core.Bin_prot.Shape.t
val bin_shape_clause : Core.Bin_prot.Shape.t
val bin_shape_clause_kind : Core.Bin_prot.Shape.t
val bin_shape_with_tag : Core.Bin_prot.Shape.t -> Core.Bin_prot.Shape.t
val bin_shape_with_tag_list : Core.Bin_prot.Shape.t -> Core.Bin_prot.Shape.t
val bin_shape_defn : Core.Bin_prot.Shape.t
val bin_shape_t : Core.Bin_prot.Shape.t -> Core.Bin_prot.Shape.t
val bin_size_grammar : grammar Core.Bin_prot.Size.sizer
val bin_write_grammar : grammar Core.Bin_prot.Write.writer
val bin_writer_grammar : grammar Core.Bin_prot.Type_class.writer
val bin_size_list_grammar : list_grammar Core.Bin_prot.Size.sizer
val bin_write_list_grammar : list_grammar Core.Bin_prot.Write.writer
val bin_writer_list_grammar : list_grammar Core.Bin_prot.Type_class.writer
val bin_size_record : record Core.Bin_prot.Size.sizer
val bin_write_record : record Core.Bin_prot.Write.writer
val bin_writer_record : record Core.Bin_prot.Type_class.writer
val bin_size_field : field Core.Bin_prot.Size.sizer
val bin_write_field : field Core.Bin_prot.Write.writer
val bin_writer_field : field Core.Bin_prot.Type_class.writer
val bin_size_case_sensitivity : case_sensitivity Core.Bin_prot.Size.sizer
val bin_write_case_sensitivity : case_sensitivity Core.Bin_prot.Write.writer
val bin_writer_case_sensitivity :
case_sensitivity Core.Bin_prot.Type_class.writer
val bin_size_variant : variant Core.Bin_prot.Size.sizer
val bin_write_variant : variant Core.Bin_prot.Write.writer
val bin_writer_variant : variant Core.Bin_prot.Type_class.writer
val bin_size_clause : clause Core.Bin_prot.Size.sizer
val bin_write_clause : clause Core.Bin_prot.Write.writer
val bin_writer_clause : clause Core.Bin_prot.Type_class.writer
val bin_size_clause_kind : clause_kind Core.Bin_prot.Size.sizer
val bin_write_clause_kind : clause_kind Core.Bin_prot.Write.writer
val bin_writer_clause_kind : clause_kind Core.Bin_prot.Type_class.writer
val bin_size_with_tag :
'a Core.Bin_prot.Size.sizer ->
'a with_tag Core.Bin_prot.Size.sizer
val bin_write_with_tag :
'a Core.Bin_prot.Write.writer ->
'a with_tag Core.Bin_prot.Write.writer
val bin_writer_with_tag :
'a Core.Bin_prot.Type_class.writer ->
'a with_tag Core.Bin_prot.Type_class.writer
val bin_size_with_tag_list :
'a Core.Bin_prot.Size.sizer ->
'a with_tag_list Core.Bin_prot.Size.sizer
val bin_write_with_tag_list :
'a Core.Bin_prot.Write.writer ->
'a with_tag_list Core.Bin_prot.Write.writer
val bin_writer_with_tag_list :
'a Core.Bin_prot.Type_class.writer ->
'a with_tag_list Core.Bin_prot.Type_class.writer
val bin_size_defn : defn Core.Bin_prot.Size.sizer
val bin_write_defn : defn Core.Bin_prot.Write.writer
val bin_writer_defn : defn Core.Bin_prot.Type_class.writer
val bin_size_t : 'a Core.Bin_prot.Size.sizer -> 'a t Core.Bin_prot.Size.sizer
val bin_write_t :
'a Core.Bin_prot.Write.writer ->
'a t Core.Bin_prot.Write.writer
val bin_writer_t :
'a Core.Bin_prot.Type_class.writer ->
'a t Core.Bin_prot.Type_class.writer
val bin_read_grammar : grammar Core.Bin_prot.Read.reader
val __bin_read_grammar__ : (int -> grammar) Core.Bin_prot.Read.reader
val bin_reader_grammar : grammar Core.Bin_prot.Type_class.reader
val bin_read_list_grammar : list_grammar Core.Bin_prot.Read.reader
val __bin_read_list_grammar__ : (int -> list_grammar) Core.Bin_prot.Read.reader
val bin_reader_list_grammar : list_grammar Core.Bin_prot.Type_class.reader
val bin_read_record : record Core.Bin_prot.Read.reader
val __bin_read_record__ : (int -> record) Core.Bin_prot.Read.reader
val bin_reader_record : record Core.Bin_prot.Type_class.reader
val bin_read_field : field Core.Bin_prot.Read.reader
val __bin_read_field__ : (int -> field) Core.Bin_prot.Read.reader
val bin_reader_field : field Core.Bin_prot.Type_class.reader
val bin_read_case_sensitivity : case_sensitivity Core.Bin_prot.Read.reader
val __bin_read_case_sensitivity__ :
(int -> case_sensitivity) Core.Bin_prot.Read.reader
val bin_reader_case_sensitivity :
case_sensitivity Core.Bin_prot.Type_class.reader
val bin_read_variant : variant Core.Bin_prot.Read.reader
val __bin_read_variant__ : (int -> variant) Core.Bin_prot.Read.reader
val bin_reader_variant : variant Core.Bin_prot.Type_class.reader
val bin_read_clause : clause Core.Bin_prot.Read.reader
val __bin_read_clause__ : (int -> clause) Core.Bin_prot.Read.reader
val bin_reader_clause : clause Core.Bin_prot.Type_class.reader
val bin_read_clause_kind : clause_kind Core.Bin_prot.Read.reader
val __bin_read_clause_kind__ : (int -> clause_kind) Core.Bin_prot.Read.reader
val bin_reader_clause_kind : clause_kind Core.Bin_prot.Type_class.reader
val bin_read_with_tag :
'a Core.Bin_prot.Read.reader ->
'a with_tag Core.Bin_prot.Read.reader
val __bin_read_with_tag__ :
'a Core.Bin_prot.Read.reader ->
(int -> 'a with_tag) Core.Bin_prot.Read.reader
val bin_reader_with_tag :
'a Core.Bin_prot.Type_class.reader ->
'a with_tag Core.Bin_prot.Type_class.reader
val bin_read_with_tag_list :
'a Core.Bin_prot.Read.reader ->
'a with_tag_list Core.Bin_prot.Read.reader
val __bin_read_with_tag_list__ :
'a Core.Bin_prot.Read.reader ->
(int -> 'a with_tag_list) Core.Bin_prot.Read.reader
val bin_reader_with_tag_list :
'a Core.Bin_prot.Type_class.reader ->
'a with_tag_list Core.Bin_prot.Type_class.reader
val bin_read_defn : defn Core.Bin_prot.Read.reader
val __bin_read_defn__ : (int -> defn) Core.Bin_prot.Read.reader
val bin_reader_defn : defn Core.Bin_prot.Type_class.reader
val bin_read_t : 'a Core.Bin_prot.Read.reader -> 'a t Core.Bin_prot.Read.reader
val __bin_read_t__ :
'a Core.Bin_prot.Read.reader ->
(int -> 'a t) Core.Bin_prot.Read.reader
val bin_reader_t :
'a Core.Bin_prot.Type_class.reader ->
'a t Core.Bin_prot.Type_class.reader
val bin_grammar : grammar Core.Bin_prot.Type_class.t
val bin_list_grammar : list_grammar Core.Bin_prot.Type_class.t
val bin_record : record Core.Bin_prot.Type_class.t
val bin_field : field Core.Bin_prot.Type_class.t
val bin_case_sensitivity : case_sensitivity Core.Bin_prot.Type_class.t
val bin_variant : variant Core.Bin_prot.Type_class.t
val bin_clause : clause Core.Bin_prot.Type_class.t
val bin_clause_kind : clause_kind Core.Bin_prot.Type_class.t
val bin_with_tag :
'a Core.Bin_prot.Type_class.t ->
'a with_tag Core.Bin_prot.Type_class.t
val bin_with_tag_list :
'a Core.Bin_prot.Type_class.t ->
'a with_tag_list Core.Bin_prot.Type_class.t
val bin_defn : defn Core.Bin_prot.Type_class.t
val bin_t : 'a Core.Bin_prot.Type_class.t -> 'a t Core.Bin_prot.Type_class.t
val compare_list_grammar : list_grammar -> list_grammar -> int
val compare_case_sensitivity : case_sensitivity -> case_sensitivity -> int
val compare_clause_kind : clause_kind -> clause_kind -> int
val compare_with_tag_list :
('a -> 'a -> int) ->
'a with_tag_list ->
'a with_tag_list ->
int
val equal_list_grammar : list_grammar -> list_grammar -> bool
val equal_case_sensitivity : case_sensitivity -> case_sensitivity -> bool
val equal_clause_kind : clause_kind -> clause_kind -> bool
val equal_with_tag_list :
('a -> 'a -> bool) ->
'a with_tag_list ->
'a with_tag_list ->
bool
val sexp_of_grammar : grammar -> Sexplib0.Sexp.t
val sexp_of_list_grammar : list_grammar -> Sexplib0.Sexp.t
val sexp_of_record : record -> Sexplib0.Sexp.t
val sexp_of_field : field -> Sexplib0.Sexp.t
val sexp_of_case_sensitivity : case_sensitivity -> Sexplib0.Sexp.t
val sexp_of_variant : variant -> Sexplib0.Sexp.t
val sexp_of_clause : clause -> Sexplib0.Sexp.t
val sexp_of_clause_kind : clause_kind -> Sexplib0.Sexp.t
val sexp_of_with_tag :
('a -> Sexplib0.Sexp.t) ->
'a with_tag ->
Sexplib0.Sexp.t
val sexp_of_with_tag_list :
('a -> Sexplib0.Sexp.t) ->
'a with_tag_list ->
Sexplib0.Sexp.t
val sexp_of_defn : defn -> Sexplib0.Sexp.t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
val grammar_of_sexp : Sexplib0.Sexp.t -> grammar
val list_grammar_of_sexp : Sexplib0.Sexp.t -> list_grammar
val record_of_sexp : Sexplib0.Sexp.t -> record
val field_of_sexp : Sexplib0.Sexp.t -> field
val case_sensitivity_of_sexp : Sexplib0.Sexp.t -> case_sensitivity
val variant_of_sexp : Sexplib0.Sexp.t -> variant
val clause_of_sexp : Sexplib0.Sexp.t -> clause
val clause_kind_of_sexp : Sexplib0.Sexp.t -> clause_kind
val with_tag_of_sexp :
(Sexplib0.Sexp.t -> 'a) ->
Sexplib0.Sexp.t ->
'a with_tag
val with_tag_list_of_sexp :
(Sexplib0.Sexp.t -> 'a) ->
Sexplib0.Sexp.t ->
'a with_tag_list
val defn_of_sexp : Sexplib0.Sexp.t -> defn
val t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t
For stable serializations of these types, see Sexp_grammar_stable
.
module Fold_nonrecursive
(Callbacks : Callbacks_for_fold_nonrecursive) :
Fold with type t := Callbacks.t and type list_t := Callbacks.list_t
Folds over a grammar.
module Fold_recursive
(Callbacks : Callbacks_for_fold_recursive) :
Fold_partial with type t := Callbacks.t and type list_t := Callbacks.list_t
Like Fold_nonrecursive
. Ties the knot for recursive grammars. May raise if the grammar contains malformed recursive definitions, e.g. an undefined type variable or applying a type constructor with the wrong arity. Exceptions may be delayed until of_lazy
values are forced.
module Eager_copy : Fold with type t := grammar and type list_t := list_grammar
An instance of Fold_nonrecursive
. Produces an equivalent grammar with no Lazy
nodes. Implicitly used by sexp_of_t
.
module Unroll_recursion :
Fold_partial with type t := grammar and type list_t := list_grammar
An instance of Fold_recursive
. Produces an equivalent grammar with no Recursive
, Tycon
, or Tyvar
nodes. This can be useful for subsequent grammar processing without the need for type variable / type constructor bookkeeping. The resulting tree may unfold infinitely, and uses Lazy
nodes to avoid divergence.
val first_tag_value :
(string * Core.Sexp.t) list ->
string ->
(Sexplib0.Sexp.t -> 'a) ->
'a Core.Or_error.t option
first_tag_value tags name of_sexp
returns the first value of name
in tags
.
completion_suggested = false
on a variant constructor means that Sexp_grammar_completion
will not suggest the constructor as a completion. The constructor is still recognized as valid syntax. Completions are still suggested for its arguments.
Default is true
.
This tag is ignored if its value is not a bool or if it is not placed on a variant constructor.
val validate_sexp : _ t -> (Core.Sexp.t -> unit Core.Or_error.t) Core.Staged.t
validate_sexp [%sexp_grammar: t]
prepares a function to report whether the grammar of t
accepts a sexp.
Staged because the outer application does a lot of work. It is often valuable to apply accepts
to a grammar once, then apply the result to multiple sexps.
val validate_sexp_untyped :
grammar ->
(Core.Sexp.t -> unit Core.Or_error.t) Core.Staged.t
validate_sexp_untyped
is like validate_sexp
but takes the untyped grammar.
val validate_sexp_list :
list_grammar ->
(Core.Sexp.t list -> unit Core.Or_error.t) Core.Staged.t
validate_sexp_list
is like validate_sexp
but validates a sequence of sexps.
unroll_tycon [%sexp_grammar: t]
returns an equivalent grammar in which the top-most node is not a Tycon
.
Acts as identity if the condition is already satisfied, and does a shallow evaluation of the Tycon
otherwise.
If tag_prefix
is provided, then Recursive
and Tyvar
nodes substituted by unroll_tycon
will be tagged respectively with keys tag_prefix ^ ".tycon"
and tag_prefix ^ ".tyvar"
. The value is the name of the tycon / tyvar.