Skip to content

Commit

Permalink
MNT: apply changes from pull request review
Browse files Browse the repository at this point in the history
<#140>

Signed-off-by: Ioannis Filippidis <[email protected]>
  • Loading branch information
johnyf committed Nov 13, 2024
1 parent 303e7f8 commit 3b69928
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 72 deletions.
2 changes: 0 additions & 2 deletions src/expr.mli
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,6 @@ module Namespaces: sig
val mint_by_min_free:
string -> int -> string list ->
string
val mint_by_count:
string -> int -> int * string
end


Expand Down
29 changes: 2 additions & 27 deletions src/expr/e_namespaces.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ let mint_by_coordinate
(* A similar idea was implemented inside
the function `Coalesce.rename_with_loc`.
*)
let line = string_of_int line in
let column = string_of_int column in
(basename ^
(* "_filename_" ^ filename ^ *)
"_line_" ^ line ^
"_column_" ^ column)
Printf.sprintf "%s_line_%d_column_%d" basename line column


let mint_from_hint
Expand Down Expand Up @@ -82,31 +77,11 @@ let mint_by_min_free
`E_action.normalize_lambda_signature`.
*)
let mk_id name i =
let numeral = string_of_int i in
name ^ "_" ^ numeral in
Printf.sprintf "%s_%d" name i in
let f i = List.mem
(mk_id basename i) used_identifiers in
let i = ref start in
while (f !i) do
i := !i + 1
done;
mk_id basename !i


(* Scheme 3: Globally incremental
This is the simplest scheme.
`count + 1` is appended to `basename` to
form an identifier.
The new count and identifier are
the result.
*)
let mint_by_count
(basename: string)
(count: int):
int * string =
let new_count = count + 1 in
let k = string_of_int new_count in
let name = basename ^ k in
(new_count, name)
2 changes: 0 additions & 2 deletions src/expr/e_namespaces.mli
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ val mint_from_hint:
val mint_by_min_free:
string -> int -> string list ->
string
val mint_by_count:
string -> int -> int * string
14 changes: 5 additions & 9 deletions src/expr/e_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,11 @@ let make_dittos
bound_domain ->
'a):
'a list =
let name = List.hd names in
let head = make_bound
name (Domain dom) in
let make_ditto name = make_bound
name Ditto in
let rest = List.tl names in
let tail = List.map
make_ditto rest in
head :: tail
match names with
| name :: rest ->
make_bound name (Domain dom) ::
List.map (fun name -> make_bound name Ditto) rest
| [] -> assert false


let make_unboundeds
Expand Down
4 changes: 2 additions & 2 deletions src/expr/e_tuply_declarations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ let make_choose_from_tuply
/\ fresh_name = <<... names ...>>
/\ predicate
or
CHOOSE fresh_name:
CHOOSE fresh_name \in dom1 \X dom2:
LET
name1 == fresh_name[1]
name2 == fresh_name[2]
Expand All @@ -661,7 +661,7 @@ let make_setst_from_tuply
/\ fresh_name = <<... names ...>>
/\ predicate}
or
{fresh_name \in dom:
{fresh_name \in dom1 \X dom2:
LET
name1 == fresh_name[1]
name2 == fresh_name[2]
Expand Down
10 changes: 5 additions & 5 deletions src/expr/e_visit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ class virtual ['s, 'a] foldmap = object (self : 'self)
| ChooseTuply (_, _, _)
| SetStTuply (_, _, _)
| SetOfTuply (_, _)
| FcnTuply (_, _) -> failwith "unexpected case"
| FcnTuply (_, _) -> assert false

method pform scx a pf = a, pf

Expand Down Expand Up @@ -1225,7 +1225,7 @@ class virtual ['s, 'a] fold = object (self : 'self)
| ChooseTuply (_, _, _)
| SetStTuply (_, _, _)
| SetOfTuply (_, _)
| FcnTuply (_, _) -> failwith "unexpected case"
| FcnTuply (_, _) -> assert false

method pform scx a pf = a

Expand Down Expand Up @@ -1356,7 +1356,7 @@ class virtual ['s] map_visible_hyp = object (self : 'self)
(adj scx h, h)
| FreshTuply _ ->
failwith "use instead the class \
`E_visit.iter_concrete`"
`E_visit.map_concrete`"
end

class virtual ['s] iter_visible_hyp = object (self : 'self)
Expand Down Expand Up @@ -1609,7 +1609,7 @@ class virtual ['s] map_rename = object (self : 'self)
| SetStTuply _
| SetOfTuply _
| FcnTuply _ ->
failwith "unused pattern-case, so not implemented"
assert false
| _ -> super#expr scx oe

method defn scx df =
Expand Down Expand Up @@ -1675,7 +1675,7 @@ class virtual ['s] map_rename = object (self : 'self)
let (h, _) = self#rename cx h nm in
(self#adj scx h, h)
| FreshTuply _ ->
failwith "unused pattern-case, so not implemented"
assert false
| Flex s ->
let h = Flex s @@ h in
let (h, _) = self#rename cx h s in
Expand Down
4 changes: 2 additions & 2 deletions src/global/intermediate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Tuply = Expr.Tuply_declarations
type mule = Module.T.mule


let expand_tuplys_and_tuplify
let expand_tuplys
(tla_module: mule):
mule =
let visitor =
Expand Down Expand Up @@ -45,4 +45,4 @@ let expand
(* Expand tuplys. *)
module_tree
(* |> Refs.expand *)
|> expand_tuplys_and_tuplify
|> expand_tuplys
24 changes: 2 additions & 22 deletions src/util/fmtutil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,8 @@

open Format

let join
(separator: string)
(items: string list):
string =
(* Concatenate `items`.
Return the concatenation of `items`,
with `separator` inserted in-between.
Example:
```ocaml
let items = ["a"; "b"] in
let separator = "," in
let s = join separator items in
assert s = "a, b"
```
*)
let step accum item =
accum ^ separator ^ item in
let accum = "" in
List.fold_left step accum items
let comma items = join "," items

let comma items = String.concat "," items

let pp_print_commasp ff () =
pp_print_string ff "," ;
Expand Down
1 change: 0 additions & 1 deletion src/util/fmtutil.mli
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

open Format

val join: string -> string list -> string
val comma: string list -> string

(** [pp_print_commasp ff ()] is equivalent to [pp_print_string ff "," ; pp_print_space ff ()] *)
Expand Down

0 comments on commit 3b69928

Please sign in to comment.