Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iris
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paolo G. Giarrusso
iris
Commits
76a6808a
Commit
76a6808a
authored
7 months ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Add `ident_to_string`, based on code by
@lepigre
.
parent
c7a48ded
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iris/proofmode/string_ident.v
+35
-1
35 additions, 1 deletion
iris/proofmode/string_ident.v
with
35 additions
and
1 deletion
iris/proofmode/string_ident.v
+
35
−
1
View file @
76a6808a
...
...
@@ -74,10 +74,44 @@ Module StringToIdent.
Ltac1
.
apply
r
[
Ltac1
.
of_ident
ident
]
Ltac1
.
run
)
.
End
StringToIdent
.
Module
IdentToString
.
Import
Ltac2
.
Ltac2
char_to_coq_byte
(
c
:
char
)
:
constr
:=
let
(
ind
,
inst
)
:=
match
Constr
.
Unsafe
.
kind
constr
:(
byte
)
with
|
Constr
.
Unsafe
.
Ind
ind
inst
=>
(
ind
,
inst
)
|
_
=>
Control
.
zero
(
Invalid_argument
None
)
end
in
let
c
:=
Constr
.
Unsafe
.
constructor
ind
(
Char
.
to_int
c
)
in
Constr
.
Unsafe
.
make
(
Constr
.
Unsafe
.
Constructor
c
inst
)
.
Ltac2
string_to_coq_string
(
s
:
string
)
:
constr
:=
let
len
:=
String
.
length
s
in
let
rec
to_string
acc
i
:=
if
Int
.
equal
i
-1
then
acc
else
let
c
:=
String
.
get
s
i
in
let
byte
:=
char_to_coq_byte
c
in
let
a
:=
compute
constr
:(
Ascii
.
ascii_of_byte
$
byte
)
in
to_string
constr
:(
String
$
a
$
acc
)
(
Int
.
sub
i
1
)
in
to_string
constr
:(
EmptyString
)
(
Int
.
sub
len
1
)
.
Ltac2
ident_to_string
(
id
:
ident
)
:
constr
:=
string_to_coq_string
(
Ident
.
to_string
id
)
.
Ltac
ident_to_string_cps
:=
ltac2
:(
id
r
|
-
let
id
:=
Option
.
get
(
Ltac1
.
to_ident
id
)
in
let
s
:=
ident_to_string
id
in
Ltac1
.
apply
r
[
Ltac1
.
of_constr
s
]
Ltac1
.
run
)
.
End
IdentToString
.
(** Finally we wrap everything up intro a tactic that renames a variable given
by ident [id] into the name given by string [s]. *)
Ltac
rename_by_string
id
s
:=
StringToIdent
.
string_to_ident_cps
s
ltac
:(
fun
x
=>
rename
id
into
x
)
.
(* We also directly expose the CPS primitive. *)
(* We also directly expose the CPS primitive
s
. *)
Ltac
string_to_ident_cps
:=
StringToIdent
.
string_to_ident_cps
.
Ltac
ident_to_string_cps
:=
IdentToString
.
ident_to_string_cps
.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment