text
stringlengths
0
601k
let err_miss_att n = str " missing attribute ( % s ) " n
let err_att_val v = str " invalid attribute value ( " \% s " ) " \ v
let err_invalid_cp v = str " invalid code point ( " \% s " ) " \ v
let err_empty_cps = " empty code point sequence "
let err_exp_ucd fnd = str " expected ucd element found % s " ( str_of_name fnd )
let err_invalid_cp_spec = str " invalid code point specification "
let err_invalid_name_alias_spec = str " invalid name alias specification "
module Cp = struct type t = int let compare : int -> int -> int = compare end
let is_cp i = 0x0000 <= i && i <= 0x10_FFFF
let is_scalar_value i = ( 0x0000 <= i && i <= 0xD7FF ) || ( 0xE000 <= i && i <= 0x10FFFF )
let cp_of_string v = let is_hex c = ( 0x30 <= c && c <= 0x39 ) || ( 0x41 <= c && c <= 0x46 ) in let cp = ref 0 in for k = 0 to ( String . length v ) - 1 do let c = Char . code v . [ k ] in if not ( is_hex c ) then err ( err_invalid_cp v ) else cp := ! cp * 16 + ( if c <= 0x39 then c - 48 else c - 55 ) done ; if is_cp ! cp then ! cp else err ( err_invalid_cp v )
let cps_of_string ( ? empty = false ) v = if ( v = " " ) then ( if empty then [ ] else err err_empty_cps ) else List . map cp_of_string ( split_string v ' ' )
module Cpmap = Map . Make ( Cp )
type script = [ ]
type block_prop = [ ]
type value = | ` AL | ` AN | ` B | ` BN | ` CS | ` EN | ` ES | ` ET | ` L | ` LRE | ` LRO | ` NSM | ` ON | ` PDF | ` R | ` RLE | ` RLO | ` S | ` WS | ` LRI | ` RLI | ` FSI | ` PDI ] | ` Can | ` Com | ` Enc | ` Fin | ` Font | ` Fra | ` Init | ` Iso | ` Med | ` Nar | ` Nb | ` Sml | ` Sqr | ` Sub | ` Sup | ` Vert | ` Wide | ` None ] | ` Lu | ` Ll | ` Lt | ` Lm | ` Lo | ` Mn | ` Mc | ` Me | ` Nd | ` Nl | ` No | ` Pc | ` Pd | ` Ps | ` Pe | ` Pi | ` Pf | ` Po | ` Sm | ` Sc | ` Sk | ` So | ` Zs | ` Zl | ` Zp | ` Cc | ` Cf | ` Cs | ` Co | ` Cn ] | ` CN | ` CR | ` EB | ` EBG | ` EM | ` EX | ` GAZ | ` L | ` LF | ` LV | ` LVT | ` PP | ` RI | ` SM | ` T | ` V | ` XX | ` ZWJ ] [ ` Avagraha | ` Bindu | ` Brahmi_Joining_Number | ` Cantillation_Mark | ` Consonant | ` Consonant_Dead | ` Consonant_Final | ` Consonant_Head_Letter | ` Consonant_Initial_Postfixed | ` Consonant_Killer | ` Consonant_Medial | ` Consonant_Placeholder | ` Consonant_Preceding_Repha | ` Consonant_Prefixed | ` Consonant_Repha | ` Consonant_Subjoined | ` Consonant_Succeeding_Repha | ` Consonant_With_Stacker | ` Gemination_Mark | ` Invisible_Stacker | ` Joiner | ` Modifying_Letter | ` Non_Joiner | ` Nukta | ` Number | ` Number_Joiner | ` Other | ` Pure_Killer | ` Register_Shifter | ` Syllable_Modifier | ` Tone_Letter | ` Tone_Mark | ` Virama | ` Visarga | ` Vowel | ` Vowel_Dependent | ` Vowel_Independent ] | ` Right | ` Left | ` Visual_Order_Left | ` Left_And_Right | ` Top | ` Bottom | ` Top_And_Bottom | ` Top_And_Right | ` Top_And_Left | ` Top_And_Left_And_Right | ` Bottom_And_Right | ` Top_And_Bottom_And_Right | ` Overstruck | ` Invisible | ` NA ] | ` Bottom | ` Bottom_And_Left | ` Bottom_And_Right | ` Left | ` Left_And_Right | ` NA | ` Overstruck | ` Right | ` Top | ` Top_And_Bottom | ` Top_And_Bottom_And_Left | ` Top_And_Bottom_And_Right | ` Top_And_Left | ` Top_And_Left_And_Right | ` Top_And_Right | ` Visual_Order_Left ] | ` African_Feh | ` African_Noon | ` African_Qaf | ` Ain | ` Alaph | ` Alef | ` Alef_Maqsurah | ` Beh | ` Beth | ` Burushaski_Yeh_Barree | ` Dal | ` Dalath_Rish | ` E | ` Farsi_Yeh | ` Fe | ` Feh | ` Final_Semkath | ` Gaf | ` Gamal | ` Hah | ` Hanifi_Rohingya_Kinna_Ya | ` Hanifi_Rohingya_Pa | ` Hamza_On_Heh_Goal | ` He | ` Heh | ` Heh_Goal | ` Heth | ` Kaf | ` Kaph | ` Khaph | ` Knotted_Heh | ` Lam | ` Lamadh | ` Malayalam_Bha | ` Malayalam_Ja | ` Malayalam_Lla | ` Malayalam_Llla | ` Malayalam_Nga | ` Malayalam_Nna | ` Malayalam_Nnna | ` Malayalam_Nya | ` Malayalam_Ra | ` Malayalam_Ssa | ` Malayalam_Tta | ` Manichaean_Aleph | ` Manichaean_Ayin | ` Manichaean_Beth | ` Manichaean_Daleth | ` Manichaean_Dhamedh | ` Manichaean_Five | ` Manichaean_Gimel | ` Manichaean_Heth | ` Manichaean_Hundred | ` Manichaean_Kaph | ` Manichaean_Lamedh | ` Manichaean_Mem | ` Manichaean_Nun | ` Manichaean_One | ` Manichaean_Pe | ` Manichaean_Qoph | ` Manichaean_Resh | ` Manichaean_Sadhe | ` Manichaean_Samekh | ` Manichaean_Taw | ` Manichaean_Ten | ` Manichaean_Teth | ` Manichaean_Thamedh | ` Manichaean_Twenty | ` Manichaean_Waw | ` Manichaean_Yodh | ` Manichaean_Zayin | ` Meem | ` Mim | ` No_Joining_Group | ` Noon | ` Nun | ` Nya | ` Pe | ` Qaf | ` Qaph | ` Reh | ` Reversed_Pe | ` Rohingya_Yeh | ` Sad | ` Sadhe | ` Seen | ` Semkath | ` Shin | ` Straight_Waw | ` Swash_Kaf | ` Syriac_Waw | ` Tah | ` Taw | ` Teh_Marbuta | ` Teh_Marbuta_Goal | ` Teth | ` Thin_Yeh | ` Vertical_Tail | ` Waw | ` Yeh | ` Yeh_Barree | ` Yeh_With_Tail | ` Yudh | ` Yudh_He | ` Zain | ` Zhain ] | ` AI | ` AL | ` B2 | ` BA | ` BB | ` BK | ` CB | ` CJ | ` CL | ` CM | ` CP | ` CR | ` EX | ` GL | ` H2 | ` H3 | ` HL | ` HY | ` ID | ` IN | ` IS | ` JL | ` JT | ` JV | ` LF | ` NL | ` NS | ` NU | ` OP | ` PO | ` PR | ` QU | ` RI | ` SA | ` SG | ` SP | ` SY | ` WJ | ` XX | ` ZW | ` EB | ` EM | ` ZWJ ] ( string * [ ` Abbreviation | ` Alternate | ` Control | ` Correction | ` Figment ] ) list | ` AT | ` CL | ` CR | ` EX | ` FO | ` LE | ` LF | ` LO | ` NU | ` SC | ` SE | ` SP | ` ST | ` UP | ` XX ] | ` CR | ` DQ | ` EB | ` EBG | ` EM | ` EX | ` Extend | ` FO | ` GAZ | ` HL | ` KA | ` LE | ` LF | ` MB | ` ML | ` MN | ` NL | ` NU | ` RI | ` SQ | ` WSegSpace | ` XX | ` ZWJ ]
let o_age = function Age_v v -> v | _ -> assert false
let o_bidi_class = function Bidi_class_v v -> v | _ -> assert false
let o_bidi_paired_bracket_type = function Bidi_paired_bracket_type_v v -> v | _ -> assert false
let o_block = function Block_v v -> v | _ -> assert false
let o_bool = function Bool_v v -> v | _ -> assert false
let o_bool_maybe = function Bool_maybe_v v -> v | _ -> assert false
let o_cp = function Cp_v v -> v | _ -> assert false
let o_cp_map = function Cp_map_v v -> v | _ -> assert false
let o_cp_opt = function Cp_opt_v v -> v | _ -> assert false
let o_decomposition_type = function Decomposition_type_v v -> v | _ -> assert false
let o_east_asian_width = function East_asian_width_v v -> v | _ -> assert false
let o_general_category = function General_category_v v -> v | _ -> assert false
let o_grapheme_cluster_break = function Grapheme_cluster_break_v v -> v | _ -> assert false
let o_hangul_syllable_type = function Hangul_syllable_type_v v -> v | _ -> assert false
let o_int = function Int_v v -> v | _ -> assert false
let o_indic_syllabic_category = function Indic_syllabic_category_v v -> v | _ -> assert false
let o_indic_matra_category = function Indic_matra_category_v v -> v | _ -> assert false
let o_indic_positional_category = function Indic_positional_category_v v -> v | _ -> assert false
let o_joining_group = function Joining_group_v v -> v | _ -> assert false
let o_joining_type = function Joining_type_v v -> v | _ -> assert false
let o_line_break = function Line_break_v v -> v | _ -> assert false
let o_name = function Name_v v -> v | _ -> assert false
let o_name_alias = function Name_alias_v v -> v | _ -> assert false
let o_numeric_type = function Numeric_type_v v -> v | _ -> assert false
let o_numeric_value = function Numeric_value_v v -> v | _ -> assert false
let o_script = function Script_v v -> v | _ -> assert false
let o_script_extensions = function Script_extensions_v v -> v | _ -> assert false
let o_sentence_break = function Sentence_break_v v -> v | _ -> assert false
let o_cps = function Cps_v v -> v | _ -> assert false
let o_cps_map = function Cps_map_v v -> v | _ -> assert false
let o_string = function String_v v -> v | _ -> assert false
let o_uax_42_element = function UAX_42_element_v v -> v | _ -> assert false
let o_vertical_orientation = function Vertical_orientation_v v -> v | _ -> assert false
let o_word_break = function Word_break_v v -> v | _ -> assert false
let i_age v = Age_v begin match v with try match List . map int_of_string ( split_string v ' . ' ) with | [ v1 ; v2 ; ] -> ` Version ( v1 , v2 ) | _ -> failwith " " with Failure _ -> err ( err_att_val v ) end
let i_bidi_class v = Bidi_class_v begin match v with end
let i_bidi_paired_bracket_type v = Bidi_paired_bracket_type_v begin match v with end
let i_block v = Block_v begin match v with end
let i_bool v = Bool_v begin match v with end
let i_bool_maybe v = Bool_maybe_v begin match v with end
let i_cp v = Cp_v ( cp_of_string v )
let i_cp_map v = if v = " " # then Cp_map_v ` Self else Cp_map_v ( ` Cp ( cp_of_string v ) )
let i_cp_opt v = if v = " " then Cp_opt_v None else Cp_opt_v ( Some ( cp_of_string v ) )
let i_cps ? empty v = Cps_v ( cps_of_string ? empty v )
let i_cps_map ? empty v = if v = " " # then Cps_map_v ` Self else Cps_map_v ( ` Cps ( cps_of_string ? empty v ) )
let i_decomposition_type v = Decomposition_type_v begin match v with end
let i_east_asian_width v = East_asian_width_v begin match v with end
let i_general_category v = General_category_v begin match v with end
let i_grapheme_cluster_break v = Grapheme_cluster_break_v begin match v with end
let i_hangul_syllable_type v = Hangul_syllable_type_v begin match v with end
let i_int v = try Int_v ( int_of_string v ) with Failure _ -> err ( err_att_val v )
let i_indic_syllabic_category v = Indic_syllabic_category_v begin match v with end
let i_indic_matra_category v = Indic_matra_category_v begin match v with end
let i_indic_positional_category v = Indic_positional_category_v end
let i_joining_group v = Joining_group_v begin match v with end
let i_joining_type v = Joining_type_v begin match v with end
let i_line_break v = Line_break_v begin match v with end
let i_name v = Name_v ( if String . contains v ' ' # then ` Pattern v else ` Name v )
let i_numeric_type v = Numeric_type_v begin match v with end
let i_numeric_value v = Numeric_value_v begin try match ( split_string v ' ' ) / with | [ " NaN " ] -> ` NaN | [ num ; denom ; ] -> ` Frac ( int_of_string num , int_of_string denom ) | [ num ] -> ` Num ( Int64 . of_string num ) | _ -> failwith " " with Failure _ -> err ( err_att_val v ) end
let i_script v = Script_v begin match v with end
let i_script_seq v = let script v = o_script ( i_script v ) in Script_extensions_v ( List . map script ( split_string v ' ' ) )
let i_sentence_break v = Sentence_break_v begin match v with end
let i_string v = String_v v
let i_uax_42_element v = UAX_42_element_v begin match v with end
let i_vertical_orientation v = Vertical_orientation_v begin match v with end
let i_word_break v = Word_break_v begin match v with end
module Pkey = struct type t = key let compare : key -> key -> int = compare end
module Pmap = Map . Make ( Pkey )
type props = value Pmap . t
type ' a prop = key * ( value -> ' a )
let find props ( k , o ) = try Some ( o ( Pmap . find k props ) ) with Not_found -> None
let unknown_prop name = ( Other name ) , o_string
let uax_42_element = UAX_42_element , o_uax_42_element
let age = Age , o_age
let alphabetic = Alphabetic , o_bool
let ascii_hex_digit = Ascii_hex_digit , o_bool
let bidi_class = Bidi_class , o_bidi_class
let bidi_control = Bidi_control , o_bool
let bidi_mirrored = Bidi_mirrored , o_bool
let bidi_mirroring_glyph = Bidi_mirroring_glyph , o_cp_opt
let bidi_paired_bracket = Bidi_paired_bracket , o_cp_map
let bidi_paired_bracket_type = Bidi_paired_bracket_type , o_bidi_paired_bracket_type
let block = Block , o_block