From a728b2f31371154953cbfd59250a1b38d94fc30e Mon Sep 17 00:00:00 2001 From: Ed Page Date: Sat, 13 Jul 2019 19:26:37 -0600 Subject: [PATCH] feat(parser): Treat contractions as a word This should be safe. Rarely is `'` used as syntax in a language that separates literals. - `'` is used within hex literals in C++ but we want to treat them as one word - `'` is used for lifetimes in Rust but there are other symbols on the left side. --- src/tokens.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tokens.rs b/src/tokens.rs index 7841f2680..9d3727a73 100644 --- a/src/tokens.rs +++ b/src/tokens.rs @@ -42,7 +42,7 @@ impl<'t> Identifier<'t> { lazy_static::lazy_static! { // Getting false positives for this lint #[allow(clippy::invalid_regex)] - static ref SPLIT: regex::bytes::Regex = regex::bytes::Regex::new(r#"\b(\p{Alphabetic}|\d|_)+\b"#).unwrap(); + static ref SPLIT: regex::bytes::Regex = regex::bytes::Regex::new(r#"\b(\p{Alphabetic}|\d|_|')+\b"#).unwrap(); } SPLIT.find_iter(content).filter_map(|m| { let s = std::str::from_utf8(m.as_bytes()).ok();