package goblint

Build not yet checked
  1. Overview
  2. Docs
Static analysis framework for C

Install

dune-project
 Dependency

Authors

Maintainers

Sources

goblint-2.9.0.tbz
sha256=882f25e68cc14d42879ab4775fb2cf99aaac7e3cc70d58fa632b7edef304a731
sha512=dc90f0a685709688bbc13c80d0e2b01bf87cf2bbdc7f0c22632227ae32bee9377f3f1cb50f00cf564d6f1313c27fba5d811c53bb17a24972ab5aa570bf62278b

doc/src/goblint.std/gobYaml.ml.html

Source file gobYaml.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
let to_string' ?(len=65535 * 4) ?encoding ?scalar_style ?layout_style v =
  assert (len >= 1);
  let rec aux len =
    match Yaml.to_string ~len ?encoding ?scalar_style ?layout_style v with
    | Ok _ as o -> o
    | Error (`Msg ("stream_start failed" | "stream_end failed" | "doc_start failed" | "doc_end failed" | "scalar failed" | "seq_start failed" | "seq_end failed" | "mapping_start failed" | "mapping_end failed" | "alias failed")) when len < Sys.max_string_length / 2 ->
      aux (len * 2)
    | Error (`Msg _) as e -> e
  in
  aux len

include Yaml.Util

include GobResult.Syntax

let option_map (f: 'a -> ('b, 'e) result) (o: 'a option): ('b option, 'e) result =
  match o with
  | Some x -> Result.map Option.some (f x)
  | None -> Ok None

let rec list_map (f: 'a -> ('b, 'e) result) (l: 'a list): ('b list, 'e) result =
  match l with
  | [] -> Ok []
  | x :: xs ->
    let+ y = f x
    and+ ys = list_map f xs in
    y :: ys

let find s y =
  match Yaml.Util.find s y with
  | Ok (Some y'') -> Ok y''
  | Ok None -> Error (`Msg ("find " ^ s))
  | Error `Msg e ->
    Error (`Msg ("find " ^ s ^ ": " ^ e))

let to_int y =
  let+ f = to_float y in
  int_of_float f

let list = function
  | `A l -> Ok l
  | _ -> Error (`Msg "Failed to get elements from non-array value")

let entries = function
  | `O assoc -> Ok assoc
  | _ -> Error (`Msg "Failed to get entries from non-object value")

let int i = float (float_of_int i)