MCPcopy Create free account
hub / github.com/davidblewett/rure-python / cmd_utf8_ranges

Function cmd_utf8_ranges

regex/regex-debug/src/main.rs:211–240  ·  view source on GitHub ↗
(args: &Args)

Source from the content-addressed store, hash-verified

209}
210
211fn cmd_utf8_ranges(args: &Args) -> Result<()> {
212 use syntax::ParserBuilder;
213 use syntax::hir::{self, HirKind};
214 use utf8_ranges::Utf8Sequences;
215
216 let hir = ParserBuilder::new()
217 .build()
218 .parse(&format!("[{}]", args.arg_class))?;
219 let cls = match hir.into_kind() {
220 HirKind::Class(hir::Class::Unicode(cls)) => cls,
221 _ => return Err(
222 format!("unexpected HIR, expected Unicode class").into(),
223 ),
224 };
225 let mut char_count = 0;
226 for (i, range) in cls.iter().enumerate() {
227 if i > 0 {
228 println!("----------------------------");
229 }
230 char_count += (range.end() as u32) - (range.start() as u32) + 1;
231 for seq in Utf8Sequences::new(range.start(), range.end()) {
232 for utf8_range in seq.into_iter() {
233 print!("[{:02X}-{:02X}]", utf8_range.start, utf8_range.end);
234 }
235 println!();
236 }
237 }
238 println!("codepoint count: {}", char_count);
239 Ok(())
240}
241
242impl Args {
243 fn parse_one(&self) -> Result<Hir> {

Callers 1

runFunction · 0.85

Calls 7

into_kindMethod · 0.80
parseMethod · 0.45
buildMethod · 0.45
iterMethod · 0.45
endMethod · 0.45
startMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected