mirror of https://github.com/kdl-org/kdl-rs.git
deps: remove phf dep
This commit is contained in:
parent
1a8eb35168
commit
5846bea079
|
|
@ -13,5 +13,4 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
miette = "4.6.0"
|
miette = "4.6.0"
|
||||||
nom = { version = "7.1.1", default-features = false }
|
nom = { version = "7.1.1", default-features = false }
|
||||||
phf = { version = "0.8.0", features = ["macros"] }
|
|
||||||
thiserror = "1.0.22"
|
thiserror = "1.0.22"
|
||||||
|
|
|
||||||
|
|
@ -342,30 +342,21 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates a (map, inverse map) tuple
|
|
||||||
macro_rules! bimap {
|
|
||||||
($($x:expr => $y:expr),+) => {
|
|
||||||
(phf::phf_map!($($x => $y),+), phf::phf_map!($($y => $x),+))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// a map and its inverse of escape-sequence<->char
|
|
||||||
pub(crate) static ESCAPE_CHARS: (phf::Map<char, char>, phf::Map<char, char>) = bimap! {
|
|
||||||
'"' => '"',
|
|
||||||
'\\' => '\\',
|
|
||||||
'/' => '/',
|
|
||||||
'b' => '\u{08}',
|
|
||||||
'f' => '\u{0C}',
|
|
||||||
'n' => '\n',
|
|
||||||
'r' => '\r',
|
|
||||||
't' => '\t'
|
|
||||||
};
|
|
||||||
|
|
||||||
/// `escape := ["\\/bfnrt] | 'u{' hex-digit{1, 6} '}'`
|
/// `escape := ["\\/bfnrt] | 'u{' hex-digit{1, 6} '}'`
|
||||||
fn escape(input: &str) -> IResult<&str, char, KdlParseError<&str>> {
|
fn escape(input: &str) -> IResult<&str, char, KdlParseError<&str>> {
|
||||||
alt((
|
alt((
|
||||||
delimited(tag("u{"), cut(unicode), char('}')),
|
delimited(tag("u{"), cut(unicode), char('}')),
|
||||||
map_opt(anychar, |c| ESCAPE_CHARS.0.get(&c).copied()),
|
map_opt(anychar, |c| match c {
|
||||||
|
'"' => Some('"'),
|
||||||
|
'\\' => Some('\\'),
|
||||||
|
'/' => Some('/'),
|
||||||
|
'b' => Some('\u{08}'),
|
||||||
|
'f' => Some('\u{0C}'),
|
||||||
|
'n' => Some('\n'),
|
||||||
|
'r' => Some('\r'),
|
||||||
|
't' => Some('\t'),
|
||||||
|
_ => None,
|
||||||
|
}),
|
||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue