Skip to content

Commit

Permalink
Merge branch 'guido_range' of github:FStarLang/FStar
Browse files Browse the repository at this point in the history
  • Loading branch information
mtzguido committed Apr 26, 2023
2 parents b0bc6c8 + 249bb81 commit fd4a8e1
Show file tree
Hide file tree
Showing 109 changed files with 2,241 additions and 1,991 deletions.
2 changes: 2 additions & 0 deletions ocaml/fstar-lib/FStar_Compiler_Range.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include FStar_Compiler_Range_Type
include FStar_Compiler_Range_Ops
44 changes: 2 additions & 42 deletions ocaml/fstar-lib/FStar_Compiler_Util.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open FStar_Json

let max_int = Z.of_int max_int
let is_letter c = if c > 255 then false else BatChar.is_letter (BatChar.chr c)
let is_digit c = if c > 255 then false else BatChar.is_digit (BatChar.chr c)
Expand Down Expand Up @@ -528,14 +530,6 @@ let pr = Printf.printf
let spr = Printf.sprintf
let fpr = Printf.fprintf

type json =
| JsonNull
| JsonBool of bool
| JsonInt of Z.t
| JsonStr of string
| JsonList of json list
| JsonAssoc of (string * json) list

type printer = {
printer_prinfo: string -> unit;
printer_prwarning: string -> unit;
Expand Down Expand Up @@ -1236,40 +1230,6 @@ let read_hints (filename: string) : hints_read_result =
| Sys_error _ ->
UnableToOpen

(** Interactive protocol **)

exception UnsupportedJson

let json_of_yojson yjs: json option =
let rec aux yjs =
match yjs with
| `Null -> JsonNull
| `Bool b -> JsonBool b
| `Int i -> JsonInt (Z.of_int i)
| `String s -> JsonStr s
| `List l -> JsonList (List.map aux l)
| `Assoc a -> JsonAssoc (List.map (fun (k, v) -> (k, aux v)) a)
| _ -> raise UnsupportedJson in
try Some (aux yjs) with UnsupportedJson -> None

let rec yojson_of_json js =
match js with
| JsonNull -> `Null
| JsonBool b -> `Bool b
| JsonInt i -> `Int (Z.to_int i)
| JsonStr s -> `String s
| JsonList l -> `List (List.map yojson_of_json l)
| JsonAssoc a -> `Assoc (List.map (fun (k, v) -> (k, yojson_of_json v)) a)

let json_of_string str : json option =
let open Yojson.Basic in
try
json_of_yojson (Yojson.Basic.from_string str)
with Yojson.Json_error _ -> None

let string_of_json json =
Yojson.Basic.to_string (yojson_of_json json)

(* Outside of this file the reference to FStar_Util.ref must use the following combinators *)
(* Export it at the end of the file so that we don't break other internal uses of ref *)
type 'a ref = 'a FStar_Monotonic_Heap.ref
Expand Down
39 changes: 39 additions & 0 deletions ocaml/fstar-lib/FStar_Json.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
exception UnsupportedJson

type json =
| JsonNull
| JsonBool of bool
| JsonInt of Z.t
| JsonStr of string
| JsonList of json list
| JsonAssoc of (string * json) list

let json_of_yojson yjs: json option =
let rec aux yjs =
match yjs with
| `Null -> JsonNull
| `Bool b -> JsonBool b
| `Int i -> JsonInt (Z.of_int i)
| `String s -> JsonStr s
| `List l -> JsonList (List.map aux l)
| `Assoc a -> JsonAssoc (List.map (fun (k, v) -> (k, aux v)) a)
| _ -> raise UnsupportedJson in
try Some (aux yjs) with UnsupportedJson -> None

let rec yojson_of_json js =
match js with
| JsonNull -> `Null
| JsonBool b -> `Bool b
| JsonInt i -> `Int (Z.to_int i)
| JsonStr s -> `String s
| JsonList l -> `List (List.map yojson_of_json l)
| JsonAssoc a -> `Assoc (List.map (fun (k, v) -> (k, yojson_of_json v)) a)

let json_of_string str : json option =
let open Yojson.Basic in
try
json_of_yojson (Yojson.Basic.from_string str)
with Yojson.Json_error _ -> None

let string_of_json json =
Yojson.Basic.to_string (yojson_of_json json)
4 changes: 2 additions & 2 deletions ocaml/fstar-lib/FStar_Range.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type __range = FStar_Compiler_Range.range
type __range = FStar_Compiler_Range_Type.range
type range = __range

let mk_range f a b c d = FStar_Compiler_Range.mk_range f {line=a;col=b} {line=c;col=d}
let mk_range f a b c d = FStar_Compiler_Range_Type.mk_range f {line=a;col=b} {line=c;col=d}
let range_0 : range = let z = Prims.parse_int "0" in mk_range "<dummy>" z z z z

type ('Ar,'Amsg,'Ab) labeled = 'Ab
14 changes: 8 additions & 6 deletions ocaml/fstar-lib/generated/FStar_CheckedFiles.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

219 changes: 0 additions & 219 deletions ocaml/fstar-lib/generated/FStar_Compiler_Range.ml

This file was deleted.

Loading

0 comments on commit fd4a8e1

Please sign in to comment.