if i >= len then failwith "Unexpected end of string" else if s.[i] = '[' then failwith "Invalid \"[\" inside character class" else if s.[i] = ']' then (i + 1, cs) else let (i1, c1) = parse_char i in if i1 < len && s.[i1] = '-' then let (i2, c2) = parse_char (i1 + 1) in cs#add_range c1 c2; else () parse_inner_charclass i2 cs else ( cs#add c1; parse_inner_charclass i1 cs )