Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ucd-generate: add joining-type sub-command #24

Merged
merged 1 commit into from
Jan 16, 2020

Conversation

wezm
Copy link
Contributor

@wezm wezm commented Jan 14, 2020

This PR makes use of the ability to parse ArabicShaping.txt to implement joining type table generation. To do this it also needs to do general category lookups, so I extracted a expand_into_categories method from the general_category command in order for it to be able to do this.

Sample output:

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

#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
pub enum JoiningType {
  DualJoining, JoinCausing, LeftJoining, NonJoining, RightJoining,
  Transparent,
}

pub const JOINING_TYPE: &'static [(u32, u32, JoiningType)] = &[
  (0, 172, JoiningType::NonJoining), (173, 173, JoiningType::Transparent),
  (174, 767, JoiningType::NonJoining), (768, 879, JoiningType::Transparent),
  (880, 1154, JoiningType::NonJoining),
  (1155, 1161, JoiningType::Transparent),
  (1162, 1424, JoiningType::NonJoining),
  (1425, 1469, JoiningType::Transparent),
  (1470, 1470, JoiningType::NonJoining),
  (1471, 1471, JoiningType::Transparent),
  (1472, 1472, JoiningType::NonJoining),
  (1473, 1474, JoiningType::Transparent),(918000, 1114111, JoiningType::NonJoining),
];

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all LGTM with one minor nit, unless I'm mistaken!

Error::Other(format!(
"Unable to find general category '{}'",
name
))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be inclined to panic here, no? That is, this error should never be reached. The only way it could be reached, I think, is with a programmer error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right. An invalid value needs to make it though canonicalization successfully too before hitting this branch. I've changed it.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more nit!

use ucd_parse::{self, ArabicShaping};

use args::ArgMatches;
use error::{Error, Result};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is an unused import here?

Also, I would just squash this back into the original commit. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh dang it, sorry about that. Fixed now.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, thanks!

@BurntSushi BurntSushi merged commit d88aa1a into BurntSushi:master Jan 16, 2020
@BurntSushi
Copy link
Owner

This PR is on crates.io in ucd-generate 0.2.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants