Skip to content

Commit

Permalink
Use loc for where a notation is invoked rather then where defined
Browse files Browse the repository at this point in the history
  • Loading branch information
jfehrle committed Sep 13, 2023
1 parent 10f9fe4 commit 150d175
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion plugins/ltac2/tac2entries.ml
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,26 @@ type krule =
(raw_tacexpr, _, 'act, Loc.t -> raw_tacexpr) Pcoq.Rule.t *
((Loc.t -> (Name.t * raw_tacexpr) list -> raw_tacexpr) -> 'act) -> krule

(* use the location where the notation is invoked rather than where it's defined *)
let fixup_notation_loc rv loc =
match rv.v with
| CTacLet (isrec, lc, e) ->
begin match e.v with
| CTacApp (f, args) ->
let args = List.map (fun arg -> CAst.make ~loc arg.v) args in
begin match f.v with
| CTacRef x ->
CAst.(make ~loc (CTacLet (isrec, lc,
make ~loc (CTacApp (
make ~loc (CTacRef x), args)))))
| _ -> rv
end
| _ -> rv
end
| _ -> rv

let rec get_rule (tok : scope_rule token list) : krule = match tok with
| [] -> KRule (Pcoq.Rule.stop, fun k loc -> k loc [])
| [] -> KRule (Pcoq.Rule.stop, fun k loc -> fixup_notation_loc (k loc []) loc)
| TacNonTerm (na, ScopeRule (scope, inj)) :: tok ->
let KRule (rule, act) = get_rule tok in
let rule = Pcoq.Rule.next rule scope in
Expand Down

0 comments on commit 150d175

Please sign in to comment.