message: debug: add utf8-ranges-rev
  Because I'm working on optimizing automata construction for Unicode
  character classes. It turns out that getting it right for the reverse
  direction is a bitch, so this helps visualize it.
diff: @@ -25,6 +25,7 @@ Usage:
  regex-debug [options] captures <pattern>
  regex-debug [options] compile <patterns> ...
  regex-debug [options] utf8-ranges <class>
  + regex-debug [options] utf8-ranges-rev <class>
  regex-debug --help
  Options:
  @@ -62,6 +63,7 @@ struct Args {
  cmd_captures: bool,
  cmd_compile: bool,
  cmd_utf8_ranges: bool,
  + cmd_utf8_ranges_rev: bool,
  arg_pattern: String,
  arg_patterns: Vec<String>,
  @@ -80,7 +82,7 @@ struct Args {
  flag_searcher: bool,
  }
  -type Result<T> = result::Result<T, Box<error::Error + Send + Sync>>;
  +type Result<T> = result::Result<T, Box<dyn error::Error + Send + Sync>>;
  fn main() {
  let mut args: Args = Docopt::new(USAGE)
  @@ -115,6 +117,8 @@ fn run(args: &Args) -> Result<()> {
  cmd_compile(args)
  } else if args.cmd_utf8_ranges {
  cmd_utf8_ranges(args)
  + } else if args.cmd_utf8_ranges_rev {
  + cmd_utf8_ranges_rev(args)
  } else {
  unreachable!()
  }
  @@ -247,6 +251,43 @@ fn cmd_utf8_ranges(args: &Args) -> Result<()> {
  Ok(())
  }
  +fn cmd_utf8_ranges_rev(args: &Args) -> Result<()> {
  + use syntax::hir::{self, HirKind};
  + use syntax::utf8::Utf8Sequences;
  + use syntax::ParserBuilder;
  +
  + let hir = ParserBuilder::new()
  + .build()
  + .parse(&format!("[{}]", args.arg_class))?;
  + let cls = match hir.into_kind() {
  + HirKind::Class(hir::Class::Unicode(cls)) => cls,
  + _ => {
  + return Err(
  + format!("unexpected HIR, expected Unicode class").into()
  + )
  + }
  + };
  + let mut char_count = 0;
  + let mut seqs = vec![];
  + for (_, range) in cls.iter().enumerate() {
  + char_count += (range.end() as u32) - (range.start() as u32) + 1;
  + for seq in Utf8Sequences::new(range.start(), range.end()) {
  + let mut seq = seq.as_slice().to_vec();
  + seq.reverse();
  + seqs.push(seq);
  + }
  + }
  + seqs.sort();
  + for seq in seqs {
  + for utf8_range in seq.into_iter() {
  + print!("[{:02X}-{:02X}]", utf8_range.start, utf8_range.end);
  + }
  + println!();
  + }
  + println!("codepoint count: {}", char_count);
  + Ok(())
  +}
  +
  impl Args {
  fn parse_one(&self) -> Result<Hir> {
  parse(&self.arg_pattern)
  