Skip to content

Commit 01fa4a4

Browse files
committed
move the logic of left_closeds/tighters/left_opens to situation.ml
1 parent 7e2c081 commit 01fa4a4

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

lib/parser/scope.ml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,12 @@ module Situation = struct
9898
x
9999

100100
let left_closeds : unit -> (No.plus_omega, No.strict) Notation.entry =
101-
fun () ->
102-
let s = get () in
103-
(Situation.EntryMap.find_opt No.plus_omega s.tighters <|> Anomaly "missing left_closeds").strict
101+
fun () -> left_closeds (get ())
104102

105103
let tighters : type strict tight. (tight, strict) No.iinterval -> (tight, strict) Notation.entry =
106-
fun { strictness; endpoint } ->
107-
let ep = Situation.EntryMap.find_opt endpoint (get ()).tighters <|> Anomaly "missing tighters" in
108-
match strictness with
109-
| Nonstrict -> ep.nonstrict
110-
| Strict -> ep.strict
111-
112-
let left_opens : Token.t -> No.interval option =
113-
fun tok -> Notation.TokMap.find_opt tok (get ()).left_opens
104+
fun i -> tighters (get ()) i
105+
106+
let left_opens : Token.t -> No.interval option = fun tok -> left_opens (get ()) tok
114107

115108
let unparse : Situation.PrintKey.t -> User.notation option =
116109
fun c -> Situation.PrintMap.find_opt c (get ()).unparse

lib/parser/situation.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,15 @@ let add_user_to : User.prenotation -> t -> (User.notation * User.key list) * t =
123123
let notn = User.make_user user in
124124
let shadow = List.filter (fun key -> PrintMap.mem key sit.unparse) notn.keys in
125125
((notn, shadow), add_with_print notn sit)
126+
127+
let left_closeds : t -> (No.plus_omega, No.strict) entry =
128+
fun s -> (EntryMap.find_opt No.plus_omega s.tighters <|> Anomaly "missing left_closeds").strict
129+
130+
let tighters : type strict tight. t -> (tight, strict) No.iinterval -> (tight, strict) entry =
131+
fun s { strictness; endpoint } ->
132+
let ep = EntryMap.find_opt endpoint s.tighters <|> Anomaly "missing tighters" in
133+
match strictness with
134+
| Nonstrict -> ep.nonstrict
135+
| Strict -> ep.strict
136+
137+
let left_opens : t -> Token.t -> No.interval option = fun s tok -> TokMap.find_opt tok s.left_opens

0 commit comments

Comments
 (0)