Page
Library
Module
Module type
Parameter
Class
Class type
Source
Sexp_grammar
Sourcetype grammar = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.grammar =
| Any of Base.string
| Bool
| Char
| Integer
| Float
| String
| Option of grammar
| List of list_grammar
| Variant of variant
| Union of grammar Base.list
| Tagged of grammar with_tag
| Tyvar of Base.string
| Tycon of Base.string * grammar Base.list
| Recursive of grammar * defn Base.list
| Lazy of grammar Base.Lazy.t
and list_grammar = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.list_grammar =
| Empty
| Cons of grammar * list_grammar
| Many of grammar
| Fields of record
and record = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.record = {
allow_extra_fields : Base.bool;
fields : field with_tag_list Base.list;
}
and field = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.field = {
name : Base.string;
required : Base.bool;
args : list_grammar;
}
and variant = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.variant = {
case_sensitivity : case_sensitivity;
clauses : clause with_tag_list Base.list;
}
and clause = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.clause = {
name : Base.string;
clause_kind : clause_kind;
}
and clause_kind = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.clause_kind =
| Atom_clause
| List_clause of {
args : list_grammar;
}
and 'a with_tag = 'a Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.with_tag = {
key : Base.string;
value : Base.Sexp.t;
grammar : 'a;
}
and 'a with_tag_list =
'a Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.with_tag_list =
| Tag of 'a with_tag_list with_tag
| No_tag of 'a
and defn = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.defn = {
tycon : Base.string;
tyvars : Base.string Base.list;
grammar : grammar;
}
val compare_with_tag_list :
('a -> 'a -> Base.int) ->
'a with_tag_list ->
'a with_tag_list ->
Base.int
val equal_with_tag_list :
('a -> 'a -> Base.bool) ->
'a with_tag_list ->
'a with_tag_list ->
Base.bool
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.
An instance of Fold_nonrecursive
. Produces an equivalent grammar with no Lazy
nodes. Implicitly used by sexp_of_t
.
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 :
(Base.string * Base.Sexp.t) Base.list ->
Base.string ->
(Sexplib0.Sexp.t -> 'a) ->
'a Base.Or_error.t Base.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.