-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from dtolnay/ucdparse
Replace ucd-generate dependency with ucd-parse
- Loading branch information
Showing
9 changed files
with
100 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
generate/src/ucd.rs linguist-generated | ||
src/tables.rs linguist-generated | ||
tests/fst/xid_continue.fst linguist-generated | ||
tests/fst/xid_start.fst linguist-generated | ||
tests/tables/tables.rs linguist-generated | ||
tests/trie/trie.rs linguist-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ version = "0.0.0" | |
authors = ["David Tolnay <[email protected]>"] | ||
edition = "2018" | ||
publish = false | ||
|
||
[dependencies] | ||
anyhow = "1" | ||
ucd-parse = "0.1.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use anyhow::Result; | ||
use std::collections::BTreeSet as Set; | ||
use std::path::Path; | ||
use ucd_parse::CoreProperty; | ||
|
||
pub struct Properties { | ||
xid_start: Set<u32>, | ||
xid_continue: Set<u32>, | ||
} | ||
|
||
impl Properties { | ||
pub fn is_xid_start(&self, ch: char) -> bool { | ||
self.xid_start.contains(&(ch as u32)) | ||
} | ||
|
||
pub fn is_xid_continue(&self, ch: char) -> bool { | ||
self.xid_continue.contains(&(ch as u32)) | ||
} | ||
} | ||
|
||
pub fn parse_xid_properties(ucd_dir: &Path) -> Result<Properties> { | ||
let mut properties = Properties { | ||
xid_start: Set::new(), | ||
xid_continue: Set::new(), | ||
}; | ||
|
||
let prop_list: Vec<CoreProperty> = ucd_parse::parse(ucd_dir)?; | ||
for core in prop_list { | ||
let set = match core.property.as_str() { | ||
"XID_Start" => &mut properties.xid_start, | ||
"XID_Continue" => &mut properties.xid_continue, | ||
_ => continue, | ||
}; | ||
for codepoint in core.codepoints { | ||
set.insert(codepoint.value()); | ||
} | ||
} | ||
|
||
Ok(properties) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#![allow(clippy::module_inception)] | ||
|
||
#[allow(clippy::redundant_static_lifetimes)] | ||
#[rustfmt::skip] | ||
mod tables; | ||
|
||
pub(crate) use self::tables::*; |
File renamed without changes.