diff options
| -rw-r--r-- | _CoqProject | 1 | ||||
| -rw-r--r-- | src/tac2core.ml | 29 | ||||
| -rw-r--r-- | theories/Ident.v | 17 | ||||
| -rw-r--r-- | theories/Ltac2.v | 1 |
4 files changed, 48 insertions, 0 deletions
diff --git a/_CoqProject b/_CoqProject index 6d3470cfa7..2561b7b6ec 100644 --- a/_CoqProject +++ b/_CoqProject @@ -23,6 +23,7 @@ src/ltac2_plugin.mlpack theories/Init.v theories/Int.v theories/String.v +theories/Ident.v theories/Array.v theories/Control.v theories/Message.v diff --git a/src/tac2core.ml b/src/tac2core.ml index 2ccc49b043..f29cc8c89e 100644 --- a/src/tac2core.ml +++ b/src/tac2core.ml @@ -267,6 +267,31 @@ let prm_array_get : ml_tactic = function else wrap (fun () -> v.(n)) | _ -> assert false +(** Ident *) + +let prm_ident_equal : ml_tactic = function +| [id1; id2] -> + let id1 = Value.to_ident id1 in + let id2 = Value.to_ident id2 in + return (Value.of_bool (Id.equal id1 id2)) +| _ -> assert false + +let prm_ident_to_string : ml_tactic = function +| [id] -> + let id = Value.to_ident id in + return (Value.of_string (Id.to_string id)) +| _ -> assert false + +let prm_ident_of_string : ml_tactic = function +| [s] -> + let s = Value.to_string s in + let id = + try Value.of_option (Some (Value.of_ident (Id.of_string s))) + with _ -> Value.of_option None + in + return id +| _ -> assert false + (** Int *) let prm_int_equal : ml_tactic = function @@ -624,6 +649,10 @@ let () = Tac2env.define_primitive (pname "int_add") prm_int_add let () = Tac2env.define_primitive (pname "int_sub") prm_int_sub let () = Tac2env.define_primitive (pname "int_mul") prm_int_mul +let () = Tac2env.define_primitive (pname "ident_equal") prm_ident_equal +let () = Tac2env.define_primitive (pname "ident_to_string") prm_ident_to_string +let () = Tac2env.define_primitive (pname "ident_of_string") prm_ident_of_string + let () = Tac2env.define_primitive (pname "throw") prm_throw let () = Tac2env.define_primitive (pname "zero") prm_zero diff --git a/theories/Ident.v b/theories/Ident.v new file mode 100644 index 0000000000..55456afbe2 --- /dev/null +++ b/theories/Ident.v @@ -0,0 +1,17 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016 *) +(* \VV/ **************************************************************) +(* // * This file is distributed under the terms of the *) +(* * GNU Lesser General Public License Version 2.1 *) +(************************************************************************) + +Require Import Ltac2.Init. + +Ltac2 Type t := ident. + +Ltac2 @ external equal : t -> t -> bool := "ltac2" "ident_equal". + +Ltac2 @ external of_string : string -> t option := "ltac2" "ident_of_string". + +Ltac2 @ external to_string : t -> string := "ltac2" "ident_to_string". diff --git a/theories/Ltac2.v b/theories/Ltac2.v index 4cd3fafcb2..0d6c8f232a 100644 --- a/theories/Ltac2.v +++ b/theories/Ltac2.v @@ -10,6 +10,7 @@ Require Export Ltac2.Init. Require Ltac2.Int. Require Ltac2.String. +Require Ltac2.Ident. Require Ltac2.Array. Require Ltac2.Message. Require Ltac2.Constr. |
