From 4b2a72d01b48b9e5fd4743b98b0c6bf6422cfc0c Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Tue, 20 Feb 2024 14:00:27 +0100 Subject: use yuujinchou for identifiers --- lib/Ast.ml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'lib/Ast.ml') diff --git a/lib/Ast.ml b/lib/Ast.ml index d26cc0f..2f6536d 100644 --- a/lib/Ast.ml +++ b/lib/Ast.ml @@ -1,4 +1,4 @@ -type raw_ident = string +type raw_ident = Yuujinchou.Trie.path type ident = raw_ident Asai.Range.located type raw_arg = { name : ident; ty : expr } @@ -27,7 +27,9 @@ and raw_expr = and expr = raw_expr Asai.Range.located -let pp_raw_ident fmt (id : raw_ident) = Format.fprintf fmt "@[%s@]" id +let pp_raw_ident fmt (id : raw_ident) = Format.pp_print_list + ~pp_sep:(fun fmt () -> Format.pp_print_char fmt '.') + Format.pp_print_string fmt id let pp_ident fmt ({ value; _ } : ident) = pp_raw_ident fmt value let rec pp_raw_arg fmt ({ name; ty } : raw_arg) = @@ -41,22 +43,23 @@ and pp_raw_expr fmt = function | True -> Format.pp_print_string fmt "True" | False -> Format.pp_print_string fmt "False" | BoolElim { motive_var; motive_body; true_case; false_case; scrut } -> - Format.fprintf fmt - "@[<10>BoolElim (@[%a@] ->@ @[%a@],@ @[%a@],@ @[%a@],@ @[%a@])@]" pp_ident - motive_var pp_expr motive_body pp_expr true_case pp_expr - false_case pp_expr scrut + Format.fprintf fmt + "@[<10>BoolElim (@[%a@] ->@ @[%a@],@ @[%a@],@ @[%a@],@ @[%a@])@]" + pp_ident motive_var + pp_expr motive_body + pp_expr true_case + pp_expr false_case + pp_expr scrut | Pi (dom, cod) -> - Format.fprintf fmt "@[<4>Pi (@[%a@],@ @[%a@])@]" pp_arg dom pp_expr cod + Format.fprintf fmt "@[<4>Pi (@[%a@],@ @[%a@])@]" pp_arg dom pp_expr cod | Lam (var, body) -> - Format.fprintf fmt "@[<5>Lam (@[%a@].@ @[%a@])@]" pp_ident var pp_expr - body + Format.fprintf fmt "@[<5>Lam (@[%a@].@ @[%a@])@]" pp_ident var pp_expr body | App (fn, arg) -> - Format.fprintf fmt "@[<5>App (@[%a@],@ @[%a@])@]" pp_expr fn pp_expr arg + Format.fprintf fmt "@[<5>App (@[%a@],@ @[%a@])@]" pp_expr fn pp_expr arg | Sg (fst, snd) -> - Format.fprintf fmt "@[<4>Sg (@[%a@],@ @[%a@])@]" pp_arg fst pp_expr snd + Format.fprintf fmt "@[<4>Sg (@[%a@],@ @[%a@])@]" pp_arg fst pp_expr snd | Pair (fst, snd) -> - Format.fprintf fmt "@[<6>Pair (@[%a@],@ @[%a@])@]" pp_expr fst pp_expr - snd + Format.fprintf fmt "@[<6>Pair (@[%a@],@ @[%a@])@]" pp_expr fst pp_expr snd | Fst p -> Format.fprintf fmt "@[<5>Fst (@[%a@])@]" pp_expr p | Snd p -> Format.fprintf fmt "@[<5>Snd (@[%a@])@]" pp_expr p | Type -> Format.pp_print_string fmt "Type" -- cgit 1.4.1