Add context and all supported versions when an syntax id is unset

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-08-17 14:45:19 +03:00
parent 166dd06886
commit f130b62648
1 changed files with 11 additions and 3 deletions

View File

@ -40,6 +40,10 @@ end
module Supported_versions = struct
type t = int Int.Map.t
let sexp_of_t (t : t) =
let open Sexp.To_sexp in
(list (pair int int)) (Int.Map.to_list t)
let make l : t =
match
List.map l ~f:(fun (major, minor) -> (major, minor))
@ -125,11 +129,15 @@ let set t ver parser =
set t.key ver parser
let get_exn t =
get t.key >>| function
| Some x -> x
get t.key >>= function
| Some x -> return x
| None ->
get_all >>| fun context ->
Exn.code_error "Syntax identifier is unset"
[ "name", Sexp.To_sexp.string t.name ]
[ "name", Sexp.To_sexp.string t.name
; "supported_versions", Supported_versions.sexp_of_t t.supported_versions
; "context", Univ_map.sexp_of_t context
]
let desc () =
kind >>| fun kind ->