Source file ThunkLuaCst.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
type t = ThunkLuaScript.chunk list

let create t = t

(* canonicalization != concrete syntax. Sometimes, like for ThunkAsset,
   we have to remove fields for canonicalization. Add options to
   [concrete] so that one function can do both. *)
let concrete ?(compliant = true) cst : string =
  let buf = Buffer.create 1024 in
  List.iter
    (fun chunk ->
      Buffer.add_string buf (ThunkLuaPrint.show_chunk ~compliant chunk))
    cst;
  Buffer.contents buf

let canonicalize cst : string = concrete ~compliant:true cst

let canonical_id cst =
  Digestif.SHA256.to_hex @@ Digestif.SHA256.digest_string (canonicalize cst)