From 11bcf393682116afccb19fb11c07b85356497819 Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Tue, 10 Dec 2024 01:12:32 -0600 Subject: [PATCH] Delete :Format --- :Format | 64 --------------------------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 :Format diff --git a/:Format b/:Format deleted file mode 100644 index 807d125286..0000000000 --- a/:Format +++ /dev/null @@ -1,64 +0,0 @@ -let rec methods_of_xml = function - | Xml.PCData s -> ("text", Lang.string s) - | Xml.Element (name, params, ([Xml.PCData s] as children)) -> - (name, Lang.meth (Lang.string s) (xml_node ~params ~children)) - | Xml.Element (name, params, children) -> - ( name, - Lang.record ( - (List.fold_left - (fun methods el -> - let (name, v) = methods_of_xml el in - let v = - match Methods.find_opt name methods with - | None -> v - | Some (`Tuple {value}) -> Value.make (`Tuple (value @[v])) - | Some value -> (name, Value.make (`Tuple [value; v])) - in - Methods.add name value methods) - Methods.append elements (methods_of_xml el)) - (xml_node ~params ~children) - children) - -and xml_node ~params ~children = - Methods.from_list - [ - ( "xml_params", - Term.make - ~methods: - (Methods.from_list - (List.map (fun (k, v) -> (k, Term.make (`String v))) params)) - Term.unit ); - ( "xml_children", - Term.make (`Tuple (List.map (fun v -> term_of_xml v) children)) ); - ] - -and term_of_xml v = Term.make ~methods:(methods_of_xml v) `Null - -let _ = - Lang.add_builtin "_internal_xml_parser_" ~category:`String ~flags:[`Hidden] - ~descr:"Internal xml parser" - [ - ("type", Value.RuntimeType.t, None, Some "Runtime type"); - ("", Lang.string_t, None, None); - ] - (Lang.univ_t ()) - (fun p -> - let s = Lang.to_string (List.assoc "" p) in - let ty = Value.RuntimeType.of_value (List.assoc "type" p) in - let ty = Type.fresh ty in - try - let xml = Xml.parse_string s in - let tm = term_of_xml xml in - Typechecking.check ~throw:(fun exn -> raise exn) tm; - Typing.(ty <: tm.Term.t); - Evaluation.eval tm - with exn -> ( - let bt = Printexc.get_raw_backtrace () in - match exn with - | _ -> - Runtime_error.raise ~bt ~pos:(Lang.pos p) - ~message: - (Printf.sprintf - "Parse error: xml value cannot be parsed as type: %s" - (Type.to_string ty)) - "xml"))