BurntSushi / ucd-generate

A command line tool to generate Unicode tables as source code.
Apache License 2.0
95 stars 21 forks source link

Add support for generating Bidi_Class tables #22

Closed wezm closed 4 years ago

wezm commented 4 years ago

This PR adds a bidi-class command. Sample output:

// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY:
//
//  ucd-generate bidi-class --rust-enum /home/wmoore/Downloads/ucd-12.1
//
// ucd-generate is available on crates.io.

#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
pub enum BidiClass {
  ArabicLetter, ArabicNumber, BoundaryNeutral, CommonSeparator,
  EuropeanNumber, EuropeanSeparator, EuropeanTerminator, FirstStrongIsolate,
  LeftToRight, LeftToRightEmbedding, LeftToRightIsolate, LeftToRightOverride,
  NonspacingMark, OtherNeutral, ParagraphSeparator, PopDirectionalFormat,
  PopDirectionalIsolate, RightToLeft, RightToLeftEmbedding,
  RightToLeftIsolate, RightToLeftOverride, SegmentSeparator, WhiteSpace,
}

pub const BIDI_CLASS: &'static [(u32, u32, BidiClass)] = &[
  (0, 8, BidiClass::BoundaryNeutral), (9, 9, BidiClass::SegmentSeparator),
  (10, 10, BidiClass::ParagraphSeparator),
  (11, 11, BidiClass::SegmentSeparator), (12, 12, BidiClass::WhiteSpace),
  (13, 13, BidiClass::ParagraphSeparator),
  (14, 27, BidiClass::BoundaryNeutral),
  ⋮
];
wezm commented 4 years ago

Thanks for the quick review. I've addressed feedback. I'm not sure if you prefer fixes like to this to be applied and rebased or pushed as new commits. I've pushed the commit for now but happy to rebase it into the original commits if preferred.