Add Sexp.kind

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
Jeremie Dimino 2018-06-19 15:38:50 +01:00
parent 43f274b323
commit 3c15e3d041
2 changed files with 18 additions and 0 deletions

View File

@ -508,6 +508,16 @@ module Of_sexp = struct
(x, [])
let record t = enter (fields t)
type kind =
| Values of Loc.t * string option
| Fields of Loc.t * string option
let kind : type k. k context -> k -> kind * k
= fun ctx state ->
match ctx with
| Values (loc, cstr, _) -> (Values (loc, cstr), state)
| Fields (loc, cstr, _) -> (Fields (loc, cstr), state)
end
module type Sexpable = sig

View File

@ -118,6 +118,14 @@ module Of_sexp : sig
S-expressions to parse *)
val eos : (bool, _) parser
(** What is currently being parsed. The second argument is the atom
at the beginnig of the list when inside a [sum ...] or [field
...]. *)
type kind =
| Values of Loc.t * string option
| Fields of Loc.t * string option
val kind : (kind, _) parser
(** [repeat t] use [t] to consume all remaning elements of the input
until the end of sequence is reached. *)
val repeat : 'a t -> 'a list t