package acgtk
Abstract Categorial Grammar development toolkit
Install
Dune Dependency
Authors
Maintainers
Sources
acg-2.1.0-20240219.tar.gz
sha512=5d380a947658fb1201895cb4cb449b1f60f54914c563e85181d628a89f045c1dd7b5b2226bb7865dd090f87caa9187e0ea6c7a4ee3dc3dda340d404c4e76c7c2
doc/src/acgtk.scripting/value.ml.html
Source file value.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
open Logic.Lambda open UtilsLib module AcgSig = AcgData.Signature.Data_Signature type vterm = | StringTerm of string * Error.pos | RealTerm of AcgSig.t * Lambda.term * Lambda.stype * (Containers.SharedForest.SharedForest.weight option) type value = vterm LazyList.t let get_term_value_in_sig s vt = match vt with | StringTerm (str, (pos, _)) -> let lexbuf = Sedlexing.Utf8.from_string str in let () = Error.set_position lexbuf pos in let () = Sedlexing.set_filename lexbuf pos.Lexing.pos_fname in (match Grammars.Parsers.parse_term lexbuf s with | None -> failwith "Term parsing error" | Some (t, ty) -> (t, ty)) | RealTerm (st, t, ty, _w) -> if st = s then (t, ty) else Errors.(ScriptErrors.emit (Script_l.WrongSignature (fst (AcgSig.name st), fst (AcgSig.name s)))) let value_from_string s (s_pos, e_pos) = let s_pos = { s_pos with Lexing.pos_cnum = s_pos.Lexing.pos_cnum + 1 } in LazyList.one (StringTerm (s, (s_pos, e_pos))) let print_aux c v = match v with | RealTerm (s, t, ty, w) -> let pp_w fmt = function | None -> () | Some w -> Format.fprintf fmt " (%a)" Containers.SharedForest.SharedForest.pp_weight w in (* Kept for debugging: depth/size pretty printer for terms *) (*let pp_s fmt (d, s) = Format.fprintf fmt " (depth: %d, size: %d)" d s in Logs.app (fun m -> m "@[<hv 2>Term%a%a:@ %a@ :@ %a@]" *) let () = Logs.app (fun m -> m "@[<hov>Term%a:@ @[%a@ @[:@ %a@]@]@]" pp_w w (* pp_s (Lambda.size ~id_to_term:(fun i -> AcgSig.unfold_term_definition i s) t) *) (AcgSig.pp_term s) t (AcgSig.pp_type s) ty) in let () = flush stdout in c + 1 | StringTerm _ -> Errors.(ScriptErrors.emit Script_l.NoSignatureTerm) let print print_count vl = try let nb_terms = LazyList.fold_left print_aux 0 vl in if print_count then Logs.app (fun m -> m "%i term%s computed." nb_terms (if nb_terms = 1 then "" else "s")) with Sys.Break -> let () = Logs.app (fun m -> m "@.") in let () = flush stdout in ()
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>