Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
name_convention.ml
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
(* Elements and attributes are technically utf8, but ascii is enough for now. see <http://www.w3.org/TR/html51/syntax.html#syntax> *) (* In the ocaml parser: let identchar = ['A'-'Z' 'a'-'z' '_' '\'' '0'-'9'] *) let is_identchar = function | 'A'..'Z' | 'a'..'z' | '_' | '\'' | '0'..'9' -> true | _ -> false let to_ocaml_bytes s = let f c = if is_identchar c then c else '_' in Bytes.init (String.length s) (fun i -> f s.[i]) let to_ocaml s = Bytes.to_string (to_ocaml_bytes s) let ident s = let s = to_ocaml_bytes s in let s = Bytes.mapi (fun i c -> if i = 0 then Char.lowercase_ascii c else c) s in Bytes.to_string s let attrib s = "a_" ^ to_ocaml s let polyvar s = let s = to_ocaml_bytes s in let s = Bytes.mapi (fun i c -> if i = 0 then Char.uppercase_ascii c else c) s in "`" ^ Bytes.to_string s