| 1 |
From Coq Require Import List. |
| 2 |
From Coq Require Import Ascii. |
| 3 |
From Coq Require Import String. |
| 4 |
Require Import Crypto.Util.Strings.String. |
| 5 |
Import ListNotations. |
| 6 |
Local Open Scope list_scope. |
| 7 |
Local Open Scope char_scope. |
| 8 |
|
| 9 |
Definition superscript_map := |
| 10 |
Eval cbv in |
| 11 |
List.combine |
| 12 |
["("; ")"; "+"; "-"; |
| 13 |
"0"; "1"; "2"; "3"; "4"; "5"; "6"; "7"; "8"; "9"; |
| 14 |
"="; |
| 15 |
"A"; "B"; "C"; "D"; "E"; "F"; "G"; "H"; "I"; "J"; "K"; "L"; "M"; "N"; "O"; "P"; "R"; "S"; "T"; "U"; "V"; "W"; "X"; "Y"; "Z"; |
| 16 |
"a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "k"; "l"; "m"; "n"; "o"; "p"; "r"; "s"; "t"; "u"; "v"; "w"; "x"; "y"; "z"]%char |
| 17 |
["⁽"; "⁾"; "⁺"; "⁻"; |
| 18 |
"⁰"; "¹"; "²"; "³"; "⁴"; "⁵"; "⁶"; "⁷"; "⁸"; "⁹"; |
| 19 |
"⁼"; |
| 20 |
"ᴬ"; "ᴮ"; "ᶜ"; "ᴰ"; "ᴱ"; "ᶠ"; "ᴳ"; "ᴴ"; "ᴵ"; "ᴶ"; "ᴷ"; "ᴸ"; "ᴹ"; "ᴺ"; "ᴼ"; "ᴾ"; "ᴿ"; "ˢ"; "ᵀ"; "ᵁ"; "ⱽ"; "ᵂ"; "ˣ"; "ʸ"; "ᶻ"; |
| 21 |
"ᵃ"; "ᵇ"; "ᶜ"; "ᵈ"; "ᵉ"; "ᶠ"; "ᵍ"; "ʰ"; "ᶦ"; "ʲ"; "ᵏ"; "ˡ"; "ᵐ"; "ⁿ"; "ᵒ"; "ᵖ"; "ʳ"; "ˢ"; "ᵗ"; "ᵘ"; "ᵛ"; "ʷ"; "ˣ"; "ʸ"; "ᶻ"]%string. |
| 22 |
|
| 23 |
Module Ascii. |
| 24 |
Definition to_superscript_opt (c : ascii) : option string |
| 25 |
:= option_map snd (find (fun '(ch, _) => Ascii.eqb c ch) superscript_map). |
| 26 |
Definition to_superscript (c : ascii) : string |
| 27 |
:= match to_superscript_opt c with |
| 28 |
| Some s => s |
| 29 |
| None => String c EmptyString |
| 30 |
end. |
| 31 |
End Ascii. |
| 32 |
|
| 33 |
Module Export WORKAROUND_EXTRACTION_DONT_SHADOW_OCAML_STRING. |
| 34 |
Module String. |
| 35 |
Definition to_superscript (s : string) : string |
| 36 |
:= string_of_list_ascii (List.flat_map (fun a => list_ascii_of_string (Ascii.to_superscript a)) (list_ascii_of_string s)). |
| 37 |
End String. |
| 38 |
End WORKAROUND_EXTRACTION_DONT_SHADOW_OCAML_STRING. |