From 7cfc654422bf1486b5e5a413d1f6eb0068d310c1 Mon Sep 17 00:00:00 2001 From: Daniel Hilst Date: Sat, 20 Aug 2022 14:35:53 -0300 Subject: [PATCH] Run ocamlformat --- lib/json5/ast.ml | 29 +++--- lib/json5/basic.ml | 10 +- lib/json5/lexer.ml | 190 +++++++++++++++++++++++++------------ lib/json5/parser.ml | 141 ++++++++++++++------------- lib/json5/raw.ml | 10 +- lib/json5/read.ml | 9 +- lib/json5/safe.ml | 10 +- lib/json5/yojson_json5.mli | 81 +++++++++++++--- 8 files changed, 312 insertions(+), 168 deletions(-) diff --git a/lib/json5/ast.ml b/lib/json5/ast.ml index 33c67f9d..40dd9a9f 100644 --- a/lib/json5/ast.ml +++ b/lib/json5/ast.ml @@ -9,38 +9,39 @@ type internal = | Bool of bool | Null -let strip_quotes s = - String.(sub s 1 (length s - 2)) +let strip_quotes s = String.(sub s 1 (length s - 2)) let safe_strip_quotes s = - if String.(get s 0 = '"' && get s (length s - 1) = '"') - then strip_quotes s + if String.(get s 0 = '"' && get s (length s - 1) = '"') then strip_quotes s else s let rec to_basic : internal -> Yojson.Basic.t = function - | Assoc l -> `Assoc (List.map (fun (name, obj) -> (safe_strip_quotes name, to_basic obj)) l) + | Assoc l -> + `Assoc + (List.map (fun (name, obj) -> (safe_strip_quotes name, to_basic obj)) l) | List l -> `List (List.map to_basic l) - | StringLit s -> - `String (strip_quotes s) + | StringLit s -> `String (strip_quotes s) | FloatLit s -> `Float (float_of_string s) | IntLit s -> `Int (int_of_string s) | Bool b -> `Bool b | Null -> `Null -let rec to_safe : internal -> Yojson.Safe.t = function - | Assoc l -> `Assoc (List.map (fun (name, obj) -> (safe_strip_quotes name, to_safe obj)) l) +let rec to_safe : internal -> Yojson.Safe.t = function + | Assoc l -> + `Assoc + (List.map (fun (name, obj) -> (safe_strip_quotes name, to_safe obj)) l) | List l -> `List (List.map to_safe l) | StringLit s -> `String (strip_quotes s) | FloatLit s -> `Float (float_of_string s) - | IntLit s -> - (match int_of_string_opt s with - | Some i -> `Int i - | None -> `Intlit s) + | IntLit s -> ( + match int_of_string_opt s with Some i -> `Int i | None -> `Intlit s) | Bool b -> `Bool b | Null -> `Null let rec to_raw : internal -> Yojson.Raw.t = function - | Assoc l -> `Assoc (List.map (fun (name, obj) -> (safe_strip_quotes name, to_raw obj)) l) + | Assoc l -> + `Assoc + (List.map (fun (name, obj) -> (safe_strip_quotes name, to_raw obj)) l) | List l -> `List (List.map to_raw l) | StringLit s -> `Stringlit s | FloatLit s -> `Floatlit s diff --git a/lib/json5/basic.ml b/lib/json5/basic.ml index c9303897..02998593 100644 --- a/lib/json5/basic.ml +++ b/lib/json5/basic.ml @@ -1,5 +1,7 @@ include Yojson.Basic -include Read.Make(struct - type t = Yojson.Basic.t - let convert = Ast.to_basic - end) + +include Read.Make (struct + type t = Yojson.Basic.t + + let convert = Ast.to_basic +end) diff --git a/lib/json5/lexer.ml b/lib/json5/lexer.ml index 3cccc6ac..902efc8f 100644 --- a/lib/json5/lexer.ml +++ b/lib/json5/lexer.ml @@ -17,8 +17,7 @@ type token = | STRING of string | IDENTIFIER_NAME of string - -let pp_token ppf = function +let pp_token ppf = function | OPEN_PAREN -> Format.fprintf ppf "'('" | CLOSE_PAREN -> Format.fprintf ppf "')'" | OPEN_BRACE -> Format.fprintf ppf "'{'" @@ -39,96 +38,165 @@ let pp_token ppf = function let source_character = [%sedlex.regexp? any] let line_terminator = [%sedlex.regexp? 0x000A | 0x000D | 0x2028 | 0x2029] -let line_terminator_sequence = [%sedlex.regexp? 0x000A | 0x000D, Opt 0x000A | 0x2028 | 0x2029] + +let line_terminator_sequence = + [%sedlex.regexp? 0x000A | 0x000D, Opt 0x000A | 0x2028 | 0x2029] (* NUMBERS, 7.8.3 *) -let non_zero_digit = [%sedlex.regexp? '1'..'9'] -let decimal_digit = [%sedlex.regexp? '0'..'9'] +let non_zero_digit = [%sedlex.regexp? '1' .. '9'] +let decimal_digit = [%sedlex.regexp? '0' .. '9'] let decimal_digits = [%sedlex.regexp? Plus decimal_digit] -let hex_digit = [%sedlex.regexp? '0'..'9'|'a'..'f'|'A'..'F'] -let exponent_indicator = [%sedlex.regexp? 'e'|'E'] -let signed_integer = [%sedlex.regexp? decimal_digits | '+', decimal_digits | '-', decimal_digits] +let hex_digit = [%sedlex.regexp? '0' .. '9' | 'a' .. 'f' | 'A' .. 'F'] +let exponent_indicator = [%sedlex.regexp? 'e' | 'E'] + +let signed_integer = + [%sedlex.regexp? decimal_digits | '+', decimal_digits | '-', decimal_digits] + let exponent_part = [%sedlex.regexp? exponent_indicator, signed_integer] -let decimal_integer_literal = [%sedlex.regexp? '0' | non_zero_digit, Opt decimal_digits] -let hex_integer_literal = [%sedlex.regexp? "0x", Plus hex_digit | "0X", Plus hex_digit] + +let decimal_integer_literal = + [%sedlex.regexp? '0' | non_zero_digit, Opt decimal_digits] + +let hex_integer_literal = + [%sedlex.regexp? "0x", Plus hex_digit | "0X", Plus hex_digit] + (* float *) -let float_literal = [%sedlex.regexp? decimal_integer_literal, '.', Opt decimal_digits, Opt exponent_part | '.', decimal_digits, Opt exponent_part] -let json5_float = [%sedlex.regexp? float_literal | '+', float_literal | '-', float_literal] +let float_literal = + [%sedlex.regexp? + ( decimal_integer_literal, '.', Opt decimal_digits, Opt exponent_part + | '.', decimal_digits, Opt exponent_part )] + +let json5_float = + [%sedlex.regexp? float_literal | '+', float_literal | '-', float_literal] + (* int_or_float *) -let int_or_float_literal = [%sedlex.regexp? decimal_integer_literal, Opt exponent_part] -let json5_int_or_float = [%sedlex.regexp? int_or_float_literal | '+', int_or_float_literal | '-', int_or_float_literal] +let int_or_float_literal = + [%sedlex.regexp? decimal_integer_literal, Opt exponent_part] + +let json5_int_or_float = + [%sedlex.regexp? + int_or_float_literal | '+', int_or_float_literal | '-', int_or_float_literal] + (* int/hex *) -let int_literal = [%sedlex.regexp? decimal_digits | '+', decimal_digits | '-', decimal_digits] -let json5_int = [%sedlex.regexp? hex_integer_literal | '+', hex_integer_literal | '-', hex_integer_literal | int_literal] +let int_literal = + [%sedlex.regexp? decimal_digits | '+', decimal_digits | '-', decimal_digits] + +let json5_int = + [%sedlex.regexp? + ( hex_integer_literal + | '+', hex_integer_literal + | '-', hex_integer_literal + | int_literal )] (* STRING LITERALS, 7.8.4 *) -let unicode_escape_sequence = [%sedlex.regexp? 'u', hex_digit, hex_digit, hex_digit, hex_digit] +let unicode_escape_sequence = + [%sedlex.regexp? 'u', hex_digit, hex_digit, hex_digit, hex_digit] + let single_escape_character = [%sedlex.regexp? Chars {|'"\\bfnrtv|}] -let escape_character = [%sedlex.regexp? single_escape_character | decimal_digit | 'x' | 'u' ] -let non_escape_character = [%sedlex.regexp? Sub (source_character, ( escape_character | line_terminator ) ) ] -let character_escape_sequence = [%sedlex.regexp? single_escape_character | non_escape_character ] -let line_continuation = [%sedlex.regexp? '\\', line_terminator_sequence ] -let escape_sequence = [%sedlex.regexp? character_escape_sequence | '0' | unicode_escape_sequence ] (* TODO *) -let single_string_character = [%sedlex.regexp? Sub (source_character, ('\'' | '\\' | line_terminator)) | '\\', escape_sequence | line_continuation ] -let double_string_character = [%sedlex.regexp? Sub (source_character, ('"' | '\\' | line_terminator)) | '\\', escape_sequence | line_continuation ] -let string_literal = [%sedlex.regexp? '"', Star double_string_character, '"' | '\'', Star single_string_character, '\'' ] + +let escape_character = + [%sedlex.regexp? single_escape_character | decimal_digit | 'x' | 'u'] + +let non_escape_character = + [%sedlex.regexp? Sub (source_character, (escape_character | line_terminator))] + +let character_escape_sequence = + [%sedlex.regexp? single_escape_character | non_escape_character] + +let line_continuation = [%sedlex.regexp? '\\', line_terminator_sequence] + +let escape_sequence = + [%sedlex.regexp? character_escape_sequence | '0' | unicode_escape_sequence] +(* TODO *) + +let single_string_character = + [%sedlex.regexp? + ( Sub (source_character, ('\'' | '\\' | line_terminator)) + | '\\', escape_sequence + | line_continuation )] + +let double_string_character = + [%sedlex.regexp? + ( Sub (source_character, ('"' | '\\' | line_terminator)) + | '\\', escape_sequence + | line_continuation )] + +let string_literal = + [%sedlex.regexp? + ( '"', Star double_string_character, '"' + | '\'', Star single_string_character, '\'' )] (* IDENTIFIER_NAME (keys in objects) *) -let unicode_combining_mark =[%sedlex.regexp? mn | mc] +let unicode_combining_mark = [%sedlex.regexp? mn | mc] let unicode_digit = [%sedlex.regexp? nd] let unicode_connector_punctuation = [%sedlex.regexp? pc] let unicode_letter = [%sedlex.regexp? lu | ll | lt | lm | lo | nl] let zwnj = [%sedlex.regexp? 0x200C] let zwj = [%sedlex.regexp? 0x200D] -let identifier_start = [%sedlex.regexp? unicode_letter | '$' | '_' | '\\', unicode_escape_sequence] -let identifier_part = [%sedlex.regexp? identifier_start | unicode_combining_mark | unicode_digit | unicode_connector_punctuation | zwnj | zwj] + +let identifier_start = + [%sedlex.regexp? unicode_letter | '$' | '_' | '\\', unicode_escape_sequence] + +let identifier_part = + [%sedlex.regexp? + ( identifier_start | unicode_combining_mark | unicode_digit + | unicode_connector_punctuation | zwnj | zwj )] + let identifier_name = [%sedlex.regexp? identifier_start, Star identifier_part] (* COMMENTS 7.4 *) -let single_line_comment_char = [%sedlex.regexp? Sub (source_character, line_terminator)] +let single_line_comment_char = + [%sedlex.regexp? Sub (source_character, line_terminator)] + let single_line_comment = [%sedlex.regexp? "//", Star single_line_comment_char] let multi_line_not_asterisk_char = [%sedlex.regexp? Sub (source_character, '*')] let multi_line_not_slash_char = [%sedlex.regexp? Sub (source_character, '/')] -let multi_line_comment_char = [%sedlex.regexp? multi_line_not_asterisk_char | '*', Plus multi_line_not_slash_char] -let multi_line_comment = [%sedlex.regexp? "/*", Star multi_line_comment_char, Opt '*', "*/"] + +let multi_line_comment_char = + [%sedlex.regexp? + multi_line_not_asterisk_char | '*', Plus multi_line_not_slash_char] + +let multi_line_comment = + [%sedlex.regexp? "/*", Star multi_line_comment_char, Opt '*', "*/"] + let comment = [%sedlex.regexp? multi_line_comment | single_line_comment] -let white_space = [%sedlex.regexp? 0x0009 | 0x000B | 0x000C | 0x0020 | 0x00A0 | 0xFEFF | zs] +let white_space = + [%sedlex.regexp? 0x0009 | 0x000B | 0x000C | 0x0020 | 0x00A0 | 0xFEFF | zs] -let rec lex : token list -> Sedlexing.lexbuf -> (token list, string) Result.t = fun tokens buf -> +let rec lex : token list -> Sedlexing.lexbuf -> (token list, string) Result.t = + fun tokens buf -> let lexeme = Sedlexing.Utf8.lexeme in match%sedlex buf with - | '(' -> lex (OPEN_PAREN::tokens) buf - | ')' -> lex (CLOSE_PAREN::tokens) buf - | '{' -> lex (OPEN_BRACE::tokens) buf - | '}' -> lex (CLOSE_BRACE::tokens) buf - | '[' -> lex (OPEN_BRACKET::tokens) buf - | ']' -> lex (CLOSE_BRACKET::tokens) buf - | ':' -> lex (COLON::tokens) buf - | ',' -> lex (COMMA::tokens) buf - | multi_line_comment - | single_line_comment - | white_space - | line_terminator -> lex tokens buf - | "true" -> lex (TRUE::tokens) buf - | "false" -> lex (FALSE::tokens) buf - | "null" -> lex (NULL::tokens) buf + | '(' -> lex (OPEN_PAREN :: tokens) buf + | ')' -> lex (CLOSE_PAREN :: tokens) buf + | '{' -> lex (OPEN_BRACE :: tokens) buf + | '}' -> lex (CLOSE_BRACE :: tokens) buf + | '[' -> lex (OPEN_BRACKET :: tokens) buf + | ']' -> lex (CLOSE_BRACKET :: tokens) buf + | ':' -> lex (COLON :: tokens) buf + | ',' -> lex (COMMA :: tokens) buf + | multi_line_comment | single_line_comment | white_space | line_terminator -> + lex tokens buf + | "true" -> lex (TRUE :: tokens) buf + | "false" -> lex (FALSE :: tokens) buf + | "null" -> lex (NULL :: tokens) buf | json5_float -> - let s = lexeme buf in - lex (FLOAT s::tokens) buf + let s = lexeme buf in + lex (FLOAT s :: tokens) buf | json5_int -> - let s = lexeme buf in - lex (INT s::tokens) buf + let s = lexeme buf in + lex (INT s :: tokens) buf | json5_int_or_float -> - let s = lexeme buf in - lex (INT_OR_FLOAT s::tokens) buf + let s = lexeme buf in + lex (INT_OR_FLOAT s :: tokens) buf | identifier_name -> - let s = lexeme buf in - lex (IDENTIFIER_NAME s::tokens) buf - | string_literal -> - let s = lexeme buf in - lex (STRING s::tokens) buf + let s = lexeme buf in + lex (IDENTIFIER_NAME s :: tokens) buf + | string_literal -> + let s = lexeme buf in + lex (STRING s :: tokens) buf | eof -> Result.Ok (List.rev tokens) | _ -> - let s = lexeme buf in - Result.Error ("Unexpected character: '" ^ s ^ "'") + let s = lexeme buf in + Result.Error ("Unexpected character: '" ^ s ^ "'") diff --git a/lib/json5/parser.ml b/lib/json5/parser.ml index 1b703526..b7586a73 100644 --- a/lib/json5/parser.ml +++ b/lib/json5/parser.ml @@ -1,89 +1,96 @@ -let (let*) = Result.bind +let ( let* ) = Result.bind let rec parse_list acc = function - | [] -> Result.Error "List never ends" - | Lexer.CLOSE_BRACKET::xs - | COMMA::CLOSE_BRACKET::xs -> Result.Ok (acc, xs) - | xs -> ( - let* (v, xs) = parse xs in - match xs with - | [] -> Result.Error "List was not closed" - | Lexer.CLOSE_BRACKET::xs - | COMMA::CLOSE_BRACKET::xs -> Result.Ok (v::acc, xs) - | COMMA::xs -> parse_list (v::acc) xs - | x::_ -> - let s = Format.asprintf "Unexpected list token: %a" Lexer.pp_token x in - Result.Error s) + | [] -> Result.Error "List never ends" + | Lexer.CLOSE_BRACKET :: xs | COMMA :: CLOSE_BRACKET :: xs -> + Result.Ok (acc, xs) + | xs -> ( + let* v, xs = parse xs in + match xs with + | [] -> Result.Error "List was not closed" + | Lexer.CLOSE_BRACKET :: xs | COMMA :: CLOSE_BRACKET :: xs -> + Result.Ok (v :: acc, xs) + | COMMA :: xs -> parse_list (v :: acc) xs + | x :: _ -> + let s = + Format.asprintf "Unexpected list token: %a" Lexer.pp_token x + in + Result.Error s) and parse_assoc acc = function - | [] -> Result.Error "Assoc never ends" - | Lexer.CLOSE_BRACE::xs - | COMMA::CLOSE_BRACE::xs -> Result.Ok (acc, xs) - | (STRING k)::COLON::xs - | (IDENTIFIER_NAME k)::COLON::xs -> ( - let* (v, xs) = parse xs in - let item = (k, v) in - match xs with - | [] -> Result.Error "Object was not closed" - | Lexer.CLOSE_BRACE::xs - | COMMA::CLOSE_BRACE::xs -> Result.Ok (item::acc, xs) - | COMMA::xs -> parse_assoc (item::acc) xs - | x::_ -> - let s = Format.asprintf "Unexpected assoc list token: %a" Lexer.pp_token x in - Result.Error s) - | x::_ -> - let s = Format.asprintf "Unexpected assoc list token: %a" Lexer.pp_token x in - Result.Error s + | [] -> Result.Error "Assoc never ends" + | Lexer.CLOSE_BRACE :: xs | COMMA :: CLOSE_BRACE :: xs -> Result.Ok (acc, xs) + | STRING k :: COLON :: xs | IDENTIFIER_NAME k :: COLON :: xs -> ( + let* v, xs = parse xs in + let item = (k, v) in + match xs with + | [] -> Result.Error "Object was not closed" + | Lexer.CLOSE_BRACE :: xs | COMMA :: CLOSE_BRACE :: xs -> + Result.Ok (item :: acc, xs) + | COMMA :: xs -> parse_assoc (item :: acc) xs + | x :: _ -> + let s = + Format.asprintf "Unexpected assoc list token: %a" Lexer.pp_token x + in + Result.Error s) + | x :: _ -> + let s = + Format.asprintf "Unexpected assoc list token: %a" Lexer.pp_token x + in + Result.Error s and parse = function - | [] -> Result.Error "empty list of tokens" - | token::xs -> - match token with - | TRUE -> Result.Ok (Ast.Bool true, xs) - | FALSE -> Result.Ok (Bool false, xs) - | NULL -> Result.Ok (Null, xs) - | INT v -> Result.Ok (IntLit v, xs) - | FLOAT v -> Result.Ok (FloatLit v, xs) - | INT_OR_FLOAT v -> - Result.Ok (FloatLit v, xs) - | STRING s -> - Result.Ok (StringLit s, xs) - | OPEN_BRACKET -> - let* (l, xs) = parse_list [] xs in - Result.Ok (Ast.List (List.rev l), xs) - | OPEN_BRACE -> - let* (a, xs) = parse_assoc [] xs in - Result.Ok (Ast.Assoc (List.rev a), xs) - | x -> - let s = Format.asprintf "Unexpected token: %a" Lexer.pp_token x in - Result.Error s + | [] -> Result.Error "empty list of tokens" + | token :: xs -> ( + match token with + | TRUE -> Result.Ok (Ast.Bool true, xs) + | FALSE -> Result.Ok (Bool false, xs) + | NULL -> Result.Ok (Null, xs) + | INT v -> Result.Ok (IntLit v, xs) + | FLOAT v -> Result.Ok (FloatLit v, xs) + | INT_OR_FLOAT v -> Result.Ok (FloatLit v, xs) + | STRING s -> Result.Ok (StringLit s, xs) + | OPEN_BRACKET -> + let* l, xs = parse_list [] xs in + Result.Ok (Ast.List (List.rev l), xs) + | OPEN_BRACE -> + let* a, xs = parse_assoc [] xs in + Result.Ok (Ast.Assoc (List.rev a), xs) + | x -> + let s = Format.asprintf "Unexpected token: %a" Lexer.pp_token x in + Result.Error s) -let parse_from_lexbuf : ?fname:string -> ?lnum:int -> Sedlexing.lexbuf -> (Ast.internal, string) Result.t = - fun ?fname ?lnum lexbuffer -> +let parse_from_lexbuf : + ?fname:string -> + ?lnum:int -> + Sedlexing.lexbuf -> + (Ast.internal, string) Result.t = + fun ?fname ?lnum lexbuffer -> let fname = Option.value fname ~default:"" in let _ = Sedlexing.set_filename lexbuffer fname in let lnum = Option.value lnum ~default:1 in - let pos = { - Lexing.pos_fname = fname; - pos_lnum = lnum; - pos_bol = 0; - pos_cnum = 0; - } in + let pos = + { Lexing.pos_fname = fname; pos_lnum = lnum; pos_bol = 0; pos_cnum = 0 } + in let _ = Sedlexing.set_position lexbuffer pos in let* tokens = Lexer.lex [] lexbuffer in let* ast = parse tokens in Result.Ok (fst ast) -let parse_from_string : ?fname:string -> ?lnum:int -> string -> (Ast.internal, string) Result.t = - fun ?fname ?lnum input -> +let parse_from_string : + ?fname:string -> ?lnum:int -> string -> (Ast.internal, string) Result.t = + fun ?fname ?lnum input -> parse_from_lexbuf (Sedlexing.Utf8.from_string input) ?fname ?lnum -let parse_from_channel : ?fname:string -> ?lnum:int -> in_channel -> (Ast.internal, string) Result.t = - fun ?fname ?lnum ic -> +let parse_from_channel : + ?fname:string -> ?lnum:int -> in_channel -> (Ast.internal, string) Result.t + = + fun ?fname ?lnum ic -> parse_from_lexbuf (Sedlexing.Utf8.from_channel ic) ?fname ?lnum -let parse_from_file : ?fname:string -> ?lnum:int -> string -> (Ast.internal, string) Result.t - = fun ?fname ?lnum filename -> +let parse_from_file : + ?fname:string -> ?lnum:int -> string -> (Ast.internal, string) Result.t = + fun ?fname ?lnum filename -> let ic = open_in filename in let out = parse_from_channel ?fname ?lnum ic in close_in ic; diff --git a/lib/json5/raw.ml b/lib/json5/raw.ml index 27e16cd0..8cf9bc27 100644 --- a/lib/json5/raw.ml +++ b/lib/json5/raw.ml @@ -1,5 +1,7 @@ include Yojson.Raw -include Read.Make(struct - type t = Yojson.Raw.t - let convert = Ast.to_raw - end) + +include Read.Make (struct + type t = Yojson.Raw.t + + let convert = Ast.to_raw +end) diff --git a/lib/json5/read.ml b/lib/json5/read.ml index 90dc663e..a3ead019 100644 --- a/lib/json5/read.ml +++ b/lib/json5/read.ml @@ -1,14 +1,19 @@ -let (let*) = Result.bind +let ( let* ) = Result.bind module type S = sig type t + val convert : Ast.internal -> t end module type Out = sig type t + val from_string : ?fname:string -> ?lnum:int -> string -> (t, string) Result.t - val from_channel : ?fname:string -> ?lnum:int -> in_channel -> (t, string) Result.t + + val from_channel : + ?fname:string -> ?lnum:int -> in_channel -> (t, string) Result.t + val from_file : ?fname:string -> ?lnum:int -> string -> (t, string) Result.t end diff --git a/lib/json5/safe.ml b/lib/json5/safe.ml index 451fd64d..1eace77c 100644 --- a/lib/json5/safe.ml +++ b/lib/json5/safe.ml @@ -1,5 +1,7 @@ include Yojson.Safe -include Read.Make(struct - type t = Yojson.Safe.t - let convert = Ast.to_safe - end) + +include Read.Make (struct + type t = Yojson.Safe.t + + let convert = Ast.to_safe +end) diff --git a/lib/json5/yojson_json5.mli b/lib/json5/yojson_json5.mli index 78a69bd8..f1c6a51f 100644 --- a/lib/json5/yojson_json5.mli +++ b/lib/json5/yojson_json5.mli @@ -1,13 +1,32 @@ module Safe : sig type t = Yojson.Safe.t type result := (t, string) Result.t + val from_string : ?fname:string -> ?lnum:int -> string -> result val from_channel : ?fname:string -> ?lnum:int -> in_channel -> result val from_file : ?fname:string -> ?lnum:int -> string -> result - val to_string : ?buf:Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> t -> string - val to_channel : ?buf:Stdlib.Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> Stdlib.out_channel -> t -> unit - val to_output : ?buf:Stdlib.Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> - < output : string -> int -> int -> int > -> t -> unit + + val to_string : + ?buf:Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> t -> string + + val to_channel : + ?buf:Stdlib.Buffer.t -> + ?len:int -> + ?suf:string -> + ?std:bool -> + Stdlib.out_channel -> + t -> + unit + + val to_output : + ?buf:Stdlib.Buffer.t -> + ?len:int -> + ?suf:string -> + ?std:bool -> + < output : string -> int -> int -> int > -> + t -> + unit + val to_file : ?len:int -> ?std:bool -> ?suf:string -> string -> t -> unit val pp : Format.formatter -> t -> unit val equal : t -> t -> bool @@ -16,13 +35,32 @@ end module Basic : sig type t = Yojson.Basic.t type result := (t, string) Result.t + val from_string : ?fname:string -> ?lnum:int -> string -> result val from_channel : ?fname:string -> ?lnum:int -> in_channel -> result val from_file : ?fname:string -> ?lnum:int -> string -> result - val to_string : ?buf:Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> t -> string - val to_channel : ?buf:Stdlib.Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> Stdlib.out_channel -> t -> unit - val to_output : ?buf:Stdlib.Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> - < output : string -> int -> int -> int > -> t -> unit + + val to_string : + ?buf:Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> t -> string + + val to_channel : + ?buf:Stdlib.Buffer.t -> + ?len:int -> + ?suf:string -> + ?std:bool -> + Stdlib.out_channel -> + t -> + unit + + val to_output : + ?buf:Stdlib.Buffer.t -> + ?len:int -> + ?suf:string -> + ?std:bool -> + < output : string -> int -> int -> int > -> + t -> + unit + val to_file : ?len:int -> ?std:bool -> ?suf:string -> string -> t -> unit val pp : Format.formatter -> t -> unit val equal : t -> t -> bool @@ -31,13 +69,32 @@ end module Raw : sig type t = Yojson.Raw.t type result := (t, string) Result.t + val from_string : ?fname:string -> ?lnum:int -> string -> result val from_channel : ?fname:string -> ?lnum:int -> in_channel -> result val from_file : ?fname:string -> ?lnum:int -> string -> result - val to_string : ?buf:Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> t -> string - val to_channel : ?buf:Stdlib.Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> Stdlib.out_channel -> t -> unit - val to_output : ?buf:Stdlib.Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> - < output : string -> int -> int -> int > -> t -> unit + + val to_string : + ?buf:Buffer.t -> ?len:int -> ?suf:string -> ?std:bool -> t -> string + + val to_channel : + ?buf:Stdlib.Buffer.t -> + ?len:int -> + ?suf:string -> + ?std:bool -> + Stdlib.out_channel -> + t -> + unit + + val to_output : + ?buf:Stdlib.Buffer.t -> + ?len:int -> + ?suf:string -> + ?std:bool -> + < output : string -> int -> int -> int > -> + t -> + unit + val to_file : ?len:int -> ?std:bool -> ?suf:string -> string -> t -> unit val pp : Format.formatter -> t -> unit val equal : t -> t -> bool