| 1 | #!/bin/sh |
| 2 | usage() |
| 3 | { |
| 4 | cat 1>&2 <<EOF |
| 5 | Usage: $0 FILE VERSION NOTE |
| 6 | |
| 7 | Write deprecation attributes in a Rocq source file for all commands that |
| 8 | support it. |
| 9 | Example: $0 Heap.v 8.3 "Use mergesort.v" |
| 10 | EOF |
| 11 | } |
| 12 | |
| 13 | case $# in |
| 14 | 3) ;; |
| 15 | *) usage; exit 1 |
| 16 | esac |
| 17 | |
| 18 | file=$1 |
| 19 | vers=$2 |
| 20 | note=$3 |
| 21 | |
| 22 | if ! [ -f "$file" ]; then |
| 23 | printf '%s: %s: No such file\n' "$0" "$file" 1>&2 |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
| 27 | attr="((Local|Global|Program|Canonical)[[:space:]]+)" |
| 28 | |
| 29 | deprable="Theorem|Lemma|Fact|Corollary|Proposition|Property|\ |
| 30 | Definition|Example|Fixpoint|\ |
| 31 | Instance|Axiom|Parameter|Notation|Coercion" |
| 32 | |
| 33 | annot="#[deprecated(since=\"$vers\", note=\"$note\")]" |
| 34 | |
| 35 | tmp="$file".depr |
| 36 | |
| 37 | sed -E "s/(^[[:space:]]*)(($attr)*($deprable).*\$)/\\1$annot\\n\\1\\2/" \ |
| 38 | "$file" >"$tmp" |
| 39 | mv "$tmp" "$file" |