package sexp_grammar

  1. Overview
  2. Docs
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
type grammar = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.grammar =
  1. | Any of string
  2. | Bool
  3. | Char
  4. | Integer
  5. | Float
  6. | String
  7. | Option of grammar
  8. | List of list_grammar
  9. | Variant of variant
  10. | Union of grammar list
  11. | Tagged of grammar with_tag
  12. | Tyvar of string
  13. | Tycon of string * grammar list * defn list
  14. | Recursive of string * grammar list
  15. | Lazy of grammar Core.Lazy.t
and list_grammar = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.list_grammar =
  1. | Empty
  2. | Cons of grammar * list_grammar
  3. | Many of grammar
  4. | Fields of record
and record = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.record = {
  1. allow_extra_fields : bool;
  2. fields : field with_tag_list list;
}
and field = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.field = {
  1. name : string;
  2. required : bool;
  3. args : list_grammar;
}
and case_sensitivity = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.case_sensitivity =
  1. | Case_insensitive
  2. | Case_sensitive
  3. | Case_sensitive_except_first_character
and variant = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.variant = {
  1. case_sensitivity : case_sensitivity;
  2. clauses : clause with_tag_list list;
}
and clause = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.clause = {
  1. name : string;
  2. clause_kind : clause_kind;
}
and clause_kind = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.clause_kind =
  1. | Atom_clause
  2. | List_clause of {
    1. args : list_grammar;
    }
and 'a with_tag = 'a Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.with_tag = {
  1. key : string;
  2. value : Core.Sexp.t;
  3. grammar : 'a;
}
and 'a with_tag_list = 'a Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.with_tag_list =
  1. | Tag of 'a with_tag_list with_tag
  2. | No_tag of 'a
and defn = Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.defn = {
  1. tycon : string;
  2. tyvars : string list;
  3. grammar : grammar;
}
and 'a t = 'a Sexp_grammar__.Sexp_grammar_intf.{Sexp_grammar}1.t = {
  1. untyped : 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_grammar : grammar -> grammar -> int
val compare_list_grammar : list_grammar -> list_grammar -> int
val compare_record : record -> record -> int
val compare_field : field -> field -> int
val compare_case_sensitivity : case_sensitivity -> case_sensitivity -> int
val compare_variant : variant -> variant -> int
val compare_clause : clause -> clause -> int
val compare_clause_kind : clause_kind -> clause_kind -> int
val compare_with_tag : ('a -> 'a -> int) -> 'a with_tag -> 'a with_tag -> int
val compare_with_tag_list : ('a -> 'a -> int) -> 'a with_tag_list -> 'a with_tag_list -> int
val compare_defn : defn -> defn -> int
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val equal_grammar : grammar -> grammar -> bool
val equal_list_grammar : list_grammar -> list_grammar -> bool
val equal_record : record -> record -> bool
val equal_field : field -> field -> bool
val equal_case_sensitivity : case_sensitivity -> case_sensitivity -> bool
val equal_variant : variant -> variant -> bool
val equal_clause : clause -> clause -> bool
val equal_clause_kind : clause_kind -> clause_kind -> bool
val equal_with_tag : ('a -> 'a -> bool) -> 'a with_tag -> 'a with_tag -> bool
val equal_with_tag_list : ('a -> 'a -> bool) -> 'a with_tag_list -> 'a with_tag_list -> bool
val equal_defn : defn -> defn -> bool
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> 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.

val coerce : _ t -> _ t

Folds over a grammar.

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.

Tagging

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.

val completion_suggested : string

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.

val unroll_tycon : ?tag_prefix:string -> 'a t -> 'a t

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.

val unroll_tycon_untyped : ?tag_prefix:string -> grammar -> grammar

unroll_tycon_untyped is like unroll_tycon but takes the untyped grammar.

OCaml

Innovation. Community. Security.