aboutsummaryrefslogtreecommitdiffhomepage
path: root/parsing/extrawit.ml
blob: 8332bd49f9a394ecd39f2fed3011e37be02a0021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2012     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

open Pp
open Genarg

(* This file defines extra argument types *)

(* Tactics as arguments *)

let tactic_main_level = 5

let wit_tactic0 = create_arg None "tactic0"
let wit_tactic1 = create_arg None "tactic1"
let wit_tactic2 = create_arg None "tactic2"
let wit_tactic3 = create_arg None "tactic3"
let wit_tactic4 = create_arg None "tactic4"
let wit_tactic5 = create_arg None "tactic5"

let wit_tactic = function
  | 0 -> wit_tactic0
  | 1 -> wit_tactic1
  | 2 -> wit_tactic2
  | 3 -> wit_tactic3
  | 4 -> wit_tactic4
  | 5 -> wit_tactic5
  | n -> Errors.anomaly (str "Unavailable tactic level:" ++ spc () ++ int n)

let tactic_genarg_level s =
  if Int.equal (String.length s) 7 && String.sub s 0 6 = "tactic" then
    let c = s.[6] in if '5' >= c && c >= '0' then Some (Char.code c - 48)
    else None
  else None

let is_tactic_genarg = function
| ExtraArgType s -> tactic_genarg_level s <> None
| _ -> false