| 1 |
(************************************************************************) |
| 2 |
(* * The Rocq Prover / The Rocq Development Team *) |
| 3 |
(* v * Copyright INRIA, CNRS and contributors *) |
| 4 |
(* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 |
(* \VV/ **************************************************************) |
| 6 |
(* // * This file is distributed under the terms of the *) |
| 7 |
(* * GNU Lesser General Public License Version 2.1 *) |
| 8 |
(* * (see LICENSE file for the text of the license) *) |
| 9 |
(************************************************************************) |
| 10 |
|
| 11 |
DECLARE GLOBAL PLUGIN |
| 12 |
|
| 13 |
{ |
| 14 |
open Procq |
| 15 |
open Procq.Prim |
| 16 |
open Vernacexpr |
| 17 |
|
| 18 |
(* Vernaculars specific to the toplevel *) |
| 19 |
type vernac_toplevel = |
| 20 |
| VernacBackTo of int |
| 21 |
| VernacDrop |
| 22 |
| VernacQuit |
| 23 |
| VernacControl of vernac_control |
| 24 |
| VernacShowGoalAt of { gid : int; sid: int } |
| 25 |
| VernacShowGoal of Vernacexpr.goal_reference |
| 26 |
| VernacShowProofDiffs of Proof_diffs.diffOpt |
| 27 |
|
| 28 |
let vernac_toplevel = Entry.make "toplevel:vernac_toplevel" |
| 29 |
|
| 30 |
let test_show_goal = |
| 31 |
let open Procq.Lookahead in |
| 32 |
to_entry "test_show_goal" begin |
| 33 |
lk_kw "Show" >> lk_kw "Goal" >> lk_nat |
| 34 |
end |
| 35 |
|
| 36 |
let test_show_natural = |
| 37 |
let open Procq.Lookahead in |
| 38 |
to_entry "test_show_natural" begin |
| 39 |
lk_kw "Show" >> lk_nat |
| 40 |
end |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
GRAMMAR EXTEND Gram |
| 45 |
GLOBAL: vernac_toplevel; |
| 46 |
vernac_toplevel: FIRST |
| 47 |
[ [ IDENT "Drop"; "." -> { Some VernacDrop } |
| 48 |
| IDENT "Quit"; "." -> { Some VernacQuit } |
| 49 |
| IDENT "BackTo"; n = natural; "." -> |
| 50 |
{ Some (VernacBackTo n) } |
| 51 |
(* show a goal for the specified proof state *) |
| 52 |
| test_show_goal; IDENT "Show"; IDENT "Goal"; gid = natural; IDENT "at"; sid = natural; "." -> |
| 53 |
{ Some (VernacShowGoalAt {gid; sid}) } |
| 54 |
| IDENT "Show"; IDENT "Proof"; IDENT "Diffs"; removed = OPT [ IDENT "removed" -> { () } ]; "." -> |
| 55 |
{ Some (VernacShowProofDiffs |
| 56 |
(if removed = None then Proof_diffs.DiffOn else Proof_diffs.DiffRemoved)) } |
| 57 |
| IDENT "Show"; "."-> { Some (VernacShowGoal OpenSubgoals) } |
| 58 |
| test_show_natural; IDENT "Show"; n = natural; "." -> { Some (VernacShowGoal (NthGoal n)) } |
| 59 |
| IDENT "Show"; IDENT "Diffs"; id = qualid; "." -> { Some (VernacShowGoal (GoalId id)) } |
| 60 |
| cmd = Pvernac.Vernac_.main_entry -> |
| 61 |
{ match cmd with |
| 62 |
| None -> None |
| 63 |
| Some v -> Some (VernacControl v) } |
| 64 |
] |
| 65 |
] |
| 66 |
; |
| 67 |
END |
| 68 |
|
| 69 |
{ |
| 70 |
|
| 71 |
let vernac_toplevel pm = |
| 72 |
Pvernac.Unsafe.set_tactic_entry pm; |
| 73 |
vernac_toplevel |
| 74 |
|
| 75 |
} |