Skip to content

Commit 6f8d727

Browse files
authored
Merge pull request #861 from Matafou/fix-named-goals
Fixing support for named goal.
2 parents c3895ab + 86a5757 commit 6f8d727

File tree

6 files changed

+40
-8
lines changed

6 files changed

+40
-8
lines changed

ci/coq-tests.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ For example, COMMENT could be (*test-definition*)"
518518
(while (setq type (funcall proof-script-parse-function))
519519
(setq cpt (+ 1 cpt))
520520
(should (equal type 'cmd)))
521-
(should (equal cpt 17))))))
521+
(should (equal cpt 31))))))
522522

523523

524524
(provide 'coq-tests)

ci/test-indent/indent-commands-boxed.v

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ Module Mod.
252252
idtac.
253253
idtac.
254254
}
255+
[foo.bar]:{
256+
idtac.
257+
- idtac.
258+
idtac. {
259+
idtac.
260+
idtac.
261+
}
262+
idtac.
263+
}
255264
[foo]:{
256265
idtac.
257266
- idtac.

ci/test-indent/indent-commands.v

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ Module Mod.
249249
idtac.
250250
idtac.
251251
}
252+
[foo.bar]:{
253+
idtac.
254+
- idtac.
255+
idtac. {
256+
idtac.
257+
idtac.
258+
}
259+
idtac.
260+
}
252261
[foo]:{
253262
idtac.
254263
- idtac.

ci/test_command_parsing.v

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,32 @@ Definition Bar := nat.
44
From elpi Require Import elpi.
55

66

7-
Lemma le_prop: forall n m p:entier, le n m -> le m p -> le n p.
7+
Lemma le_prop: forall n m p:nat, le n m -> le m p -> le n p.
88
Proof.
99
intros n m p.
1010
intro H.
1111
revert p.
1212
induction H;intros.
1313
- assumption.
1414
- { + apply IHle.
15-
apply le_Suuc_a_gauche.
15+
apply le_S_n.
16+
apply le_S.
1617
assumption. }
1718
Qed.
1819

19-
20+
(* named goals are in rocq >= 9.2, *)
21+
Open Scope bool_scope.
22+
Set Generate Goal Names.
23+
Goal forall a b, a && b = b && a.
24+
Proof.
25+
intros a b.
26+
destruct a,b.
27+
[true.true]: {
28+
cbn. reflexivity. }
29+
[true.false]: {
30+
cbn. reflexivity.
31+
}
32+
Admitted.
2033

2134
Elpi Tactic show.
2235
Elpi Accumulate lp:{{

coq/coq-indent.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ No context checking.")
4444

4545
;; goal selectors are of two forms;
4646
;; 2:
47-
;; [goalname]:
48-
(defconst coq-goal-selector-regexp "\\(?:[0-9]+\\|\\[\\w+\\]\\)\\s-*:\\s-*"
47+
;; [goalname]: where goalname may contain "." (at least)
48+
(defconst coq-goal-selector-regexp "\\(?:[0-9]+\\|\\[[^]]+\\]\\)\\s-*:\\s-*"
4949
"regexp of goal selector in coq.")
5050

5151
;;;;;;;;;;;;;;; FORWARD / BACKWARD REGEXP ;;;;;;;;;;;;;;;;;
@@ -385,6 +385,7 @@ Comments are ignored, of course."
385385
;; TODO: looking-back is supposed to be slow. Find something else?
386386
((or (and (looking-at "{")(looking-back "[0-9]+\\s-*:\\s-*" nil t))
387387
(and (looking-at ":\\s-*{")(looking-back "[0-9]+\\s-*" nil t))
388+
(and (looking-at ":\\s-*{")(looking-back "\[[^]]+\]\\s-*" nil t))
388389
(and (looking-at "[0-9]+:\\s-*{") nil t))
389390
(goto-char (match-beginning 0)) ; swallow goal selector
390391
(coq-empty-command-p))

coq/coq-smie.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,14 +776,14 @@ The point should be at the beginning of the command name."
776776
(save-excursion
777777
(forward-char -1)
778778
(if (and (looking-at "{")
779-
(looking-back "\\(\\[?\\w+\\]?\\s-*:\\s-*\\)" nil t))
779+
(looking-back coq-goal-selector-regexp nil t))
780780
(goto-char (match-beginning 0)))
781781
(let ((nxttok (coq-smie-backward-token))) ;; recursive call
782782
(coq-is-cmdend-token nxttok))))
783783
(forward-char -1)
784784
(if (looking-at "}") "} subproof"
785785
(if (and (looking-at "{")
786-
(looking-back "\\(\\[?\\w+\\]?\\s-*:\\s-*\\)" nil t))
786+
(looking-back coq-goal-selector-regexp nil t))
787787
(goto-char (match-beginning 0)))
788788
"{ subproof"
789789
))

0 commit comments

Comments
 (0)