mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 03:05:31 -05:00
leancheck: parse ind
This commit is contained in:
parent
38133dc163
commit
6fee09848b
3 changed files with 44 additions and 0 deletions
|
|
@ -138,6 +138,25 @@ let process_files ~max_err (files : string list) : unit =
|
||||||
(T.pi (binder_of_string b) (Idx.get_name idx n)
|
(T.pi (binder_of_string b) (Idx.get_name idx n)
|
||||||
~var_ty:(Idx.get_term idx i) (Idx.get_term idx j))
|
~var_ty:(Idx.get_term idx i) (Idx.get_term idx j))
|
||||||
|
|
||||||
|
let ind ~n_params ~nidx ~tyidx ~intros ~univ_params : unit =
|
||||||
|
let name = Idx.get_name idx nidx in
|
||||||
|
let ty = Idx.get_term idx tyidx in
|
||||||
|
let intros =
|
||||||
|
List.map
|
||||||
|
(fun (i, j) -> Idx.get_name idx i, Idx.get_term idx j)
|
||||||
|
intros
|
||||||
|
in
|
||||||
|
let univ_params =
|
||||||
|
List.map (fun i -> Idx.get_name idx i) univ_params
|
||||||
|
in
|
||||||
|
Fmt.eprintf "@[<2>>> @{<Green>Ind@} %s %a:%a [%d params] :=@ %a@]@."
|
||||||
|
name
|
||||||
|
Fmt.Dump.(list string)
|
||||||
|
univ_params T.pp_debug ty n_params
|
||||||
|
Fmt.(hvbox @@ Dump.(list @@ pair string T.pp_debug))
|
||||||
|
intros;
|
||||||
|
()
|
||||||
|
|
||||||
let after_line () = Fmt.eprintf "%a@." Idx.dump idx
|
let after_line () = Fmt.eprintf "%a@." Idx.dump idx
|
||||||
end)
|
end)
|
||||||
in
|
in
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,23 @@ let parse ?(max_errors = max_int) (input : input) (cb : callback) : unit =
|
||||||
| [ I at; S "#ES"; I i ] -> CB.es ~at i
|
| [ I at; S "#ES"; I i ] -> CB.es ~at i
|
||||||
| [ I at; S "#EL"; S b; I n; I i; I j ] -> CB.el ~at b n i j
|
| [ I at; S "#EL"; S b; I n; I i; I j ] -> CB.el ~at b n i j
|
||||||
| [ I at; S "#EP"; S b; I n; I i; I j ] -> CB.ep ~at b n i j
|
| [ I at; S "#EP"; S b; I n; I i; I j ] -> CB.ep ~at b n i j
|
||||||
|
| S "#IND" :: I n_params :: I nidx :: I tyidx :: I n_intros :: tl ->
|
||||||
|
let rec get_intros n acc = function
|
||||||
|
| l when n = 0 -> List.rev acc, l
|
||||||
|
| [] | [ _ ] -> failwith "missing intro"
|
||||||
|
| I nidx :: I tyidx :: tl ->
|
||||||
|
get_intros (n - 1) ((nidx, tyidx) :: acc) tl
|
||||||
|
| _ -> failwith "invalid intro"
|
||||||
|
in
|
||||||
|
let intros, l = get_intros n_intros [] tl in
|
||||||
|
let univ_params =
|
||||||
|
List.map
|
||||||
|
(function
|
||||||
|
| I i -> i
|
||||||
|
| _ -> failwith "invalid param")
|
||||||
|
l
|
||||||
|
in
|
||||||
|
CB.ind ~n_params ~nidx ~tyidx ~intros ~univ_params
|
||||||
| _ ->
|
| _ ->
|
||||||
incr n_errors;
|
incr n_errors;
|
||||||
Fmt.eprintf "@{<Yellow>warn@}: unhandled line %d: %s@." !n_line line
|
Fmt.eprintf "@{<Yellow>warn@}: unhandled line %d: %s@." !n_line line
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,12 @@ module type CALLBACK = sig
|
||||||
val es : at:int -> int -> unit
|
val es : at:int -> int -> unit
|
||||||
val el : at:int -> string -> int -> int -> int -> unit
|
val el : at:int -> string -> int -> int -> int -> unit
|
||||||
val ep : at:int -> string -> int -> int -> int -> unit
|
val ep : at:int -> string -> int -> int -> int -> unit
|
||||||
|
|
||||||
|
val ind :
|
||||||
|
n_params:int ->
|
||||||
|
nidx:int ->
|
||||||
|
tyidx:int ->
|
||||||
|
intros:(int * int) list ->
|
||||||
|
univ_params:int list ->
|
||||||
|
unit
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue