package sexp_grammar

  1. Overview
  2. Docs

Module Sexp_grammarSource

Sourcemodule type Callbacks_for_fold_common = sig ... end
Sourcemodule type Callbacks_for_fold_nonrecursive = sig ... end
Sourcemodule type Callbacks_for_fold_recursive = sig ... end
Sourcemodule type Fold = sig ... end
Sourcemodule type Fold_partial = sig ... end
Sourcemodule Field : sig ... end
Sourcemodule Case_sensitivity : sig ... end
Sourcetype grammar = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.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
Sourceand list_grammar = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.list_grammar =
  1. | Empty
  2. | Cons of grammar * list_grammar
  3. | Many of grammar
  4. | Fields of record
Sourceand record = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.record = {
  1. allow_extra_fields : bool;
  2. fields : field with_tag_list list;
}
Sourceand field = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.field = {
  1. name : string;
  2. required : bool;
  3. args : list_grammar;
}
Sourceand case_sensitivity = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.case_sensitivity =
  1. | Case_insensitive
  2. | Case_sensitive
  3. | Case_sensitive_except_first_character
Sourceand variant = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.variant = {
  1. case_sensitivity : case_sensitivity;
  2. clauses : clause with_tag_list list;
}
Sourceand clause = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.clause = {
  1. name : string;
  2. clause_kind : clause_kind;
}
Sourceand clause_kind = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.clause_kind =
  1. | Atom_clause
  2. | List_clause of {
    1. args : list_grammar;
    }
Sourceand 'a with_tag = 'a Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.with_tag = {
  1. key : string;
  2. value : Core.Sexp.t;
  3. grammar : 'a;
}
Sourceand 'a with_tag_list = 'a Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.with_tag_list =
  1. | Tag of 'a with_tag_list with_tag
  2. | No_tag of 'a
Sourceand defn = Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.defn = {
  1. tycon : string;
  2. tyvars : string list;
  3. grammar : grammar;
}
Sourceand 'a t = 'a Sexp_grammar__.Sexp_grammar_intf.Sexp_grammar.t = {
  1. untyped : grammar;
}
Sourceval bin_shape_grammar : Core.Bin_prot.Shape.t
Sourceval bin_shape_list_grammar : Core.Bin_prot.Shape.t
Sourceval bin_shape_record : Core.Bin_prot.Shape.t
Sourceval bin_shape_field : Core.Bin_prot.Shape.t
Sourceval bin_shape_case_sensitivity : Core.Bin_prot.Shape.t
Sourceval bin_shape_variant : Core.Bin_prot.Shape.t
Sourceval bin_shape_clause : Core.Bin_prot.Shape.t
Sourceval bin_shape_clause_kind : Core.Bin_prot.Shape.t
Sourceval bin_shape_with_tag_list : Core.Bin_prot.Shape.t -> Core.Bin_prot.Shape.t
Sourceval bin_shape_defn : Core.Bin_prot.Shape.t
Sourceval bin_size_list_grammar : list_grammar Core.Bin_prot.Size.sizer
Sourceval bin_write_list_grammar : list_grammar Core.Bin_prot.Write.writer
Sourceval bin_size_case_sensitivity : case_sensitivity Core.Bin_prot.Size.sizer
Sourceval bin_write_case_sensitivity : case_sensitivity Core.Bin_prot.Write.writer
Sourceval bin_size_clause_kind : clause_kind Core.Bin_prot.Size.sizer
Sourceval bin_write_clause_kind : clause_kind Core.Bin_prot.Write.writer
Sourceval __bin_read_grammar__ : (int -> grammar) Core.Bin_prot.Read.reader
Sourceval bin_read_list_grammar : list_grammar Core.Bin_prot.Read.reader
Sourceval __bin_read_list_grammar__ : (int -> list_grammar) Core.Bin_prot.Read.reader
Sourceval __bin_read_record__ : (int -> record) Core.Bin_prot.Read.reader
Sourceval __bin_read_field__ : (int -> field) Core.Bin_prot.Read.reader
Sourceval bin_read_case_sensitivity : case_sensitivity Core.Bin_prot.Read.reader
Sourceval __bin_read_case_sensitivity__ : (int -> case_sensitivity) Core.Bin_prot.Read.reader
Sourceval __bin_read_variant__ : (int -> variant) Core.Bin_prot.Read.reader
Sourceval __bin_read_clause__ : (int -> clause) Core.Bin_prot.Read.reader
Sourceval bin_read_clause_kind : clause_kind Core.Bin_prot.Read.reader
Sourceval __bin_read_clause_kind__ : (int -> clause_kind) Core.Bin_prot.Read.reader
Sourceval __bin_read_with_tag__ : 'a Core.Bin_prot.Read.reader -> (int -> 'a with_tag) Core.Bin_prot.Read.reader
Sourceval __bin_read_with_tag_list__ : 'a Core.Bin_prot.Read.reader -> (int -> 'a with_tag_list) Core.Bin_prot.Read.reader
Sourceval __bin_read_defn__ : (int -> defn) Core.Bin_prot.Read.reader
Sourceval __bin_read_t__ : 'a Core.Bin_prot.Read.reader -> (int -> 'a t) Core.Bin_prot.Read.reader
Sourceval compare_grammar : grammar -> grammar -> int
Sourceval compare_list_grammar : list_grammar -> list_grammar -> int
Sourceval compare_record : record -> record -> int
Sourceval compare_field : field -> field -> int
Sourceval compare_case_sensitivity : case_sensitivity -> case_sensitivity -> int
Sourceval compare_variant : variant -> variant -> int
Sourceval compare_clause : clause -> clause -> int
Sourceval compare_clause_kind : clause_kind -> clause_kind -> int
Sourceval compare_with_tag : ('a -> 'a -> int) -> 'a with_tag -> 'a with_tag -> int
Sourceval compare_with_tag_list : ('a -> 'a -> int) -> 'a with_tag_list -> 'a with_tag_list -> int
Sourceval compare_defn : defn -> defn -> int
Sourceval compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
Sourceval equal_grammar : grammar -> grammar -> bool
Sourceval equal_list_grammar : list_grammar -> list_grammar -> bool
Sourceval equal_record : record -> record -> bool
Sourceval equal_field : field -> field -> bool
Sourceval equal_case_sensitivity : case_sensitivity -> case_sensitivity -> bool
Sourceval equal_variant : variant -> variant -> bool
Sourceval equal_clause : clause -> clause -> bool
Sourceval equal_clause_kind : clause_kind -> clause_kind -> bool
Sourceval equal_with_tag : ('a -> 'a -> bool) -> 'a with_tag -> 'a with_tag -> bool
Sourceval equal_with_tag_list : ('a -> 'a -> bool) -> 'a with_tag_list -> 'a with_tag_list -> bool
Sourceval equal_defn : defn -> defn -> bool
Sourceval equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
Sourceval sexp_of_grammar : grammar -> Sexplib0.Sexp.t
Sourceval sexp_of_list_grammar : list_grammar -> Sexplib0.Sexp.t
Sourceval sexp_of_record : record -> Sexplib0.Sexp.t
Sourceval sexp_of_field : field -> Sexplib0.Sexp.t
Sourceval sexp_of_case_sensitivity : case_sensitivity -> Sexplib0.Sexp.t
Sourceval sexp_of_variant : variant -> Sexplib0.Sexp.t
Sourceval sexp_of_clause : clause -> Sexplib0.Sexp.t
Sourceval sexp_of_clause_kind : clause_kind -> Sexplib0.Sexp.t
Sourceval sexp_of_with_tag : ('a -> Sexplib0.Sexp.t) -> 'a with_tag -> Sexplib0.Sexp.t
Sourceval sexp_of_with_tag_list : ('a -> Sexplib0.Sexp.t) -> 'a with_tag_list -> Sexplib0.Sexp.t
Sourceval sexp_of_defn : defn -> Sexplib0.Sexp.t
Sourceval sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
Sourceval grammar_of_sexp : Sexplib0.Sexp.t -> grammar
Sourceval list_grammar_of_sexp : Sexplib0.Sexp.t -> list_grammar
Sourceval record_of_sexp : Sexplib0.Sexp.t -> record
Sourceval field_of_sexp : Sexplib0.Sexp.t -> field
Sourceval case_sensitivity_of_sexp : Sexplib0.Sexp.t -> case_sensitivity
Sourceval variant_of_sexp : Sexplib0.Sexp.t -> variant
Sourceval clause_of_sexp : Sexplib0.Sexp.t -> clause
Sourceval clause_kind_of_sexp : Sexplib0.Sexp.t -> clause_kind
Sourceval with_tag_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a with_tag
Sourceval with_tag_list_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a with_tag_list
Sourceval defn_of_sexp : Sexplib0.Sexp.t -> defn
Sourceval t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t

For stable serializations of these types, see Sexp_grammar_stable.

Sourceval coerce : _ t -> _ 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.

Sourcemodule 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.

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

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval 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.

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

unroll_tycon_untyped is like unroll_tycon but takes the untyped grammar.