|
1 | 1 | use nom::anychar; |
2 | 2 |
|
3 | | -#[cfg(feature="unicode-names")] |
| 3 | +#[cfg(feature = "unicode-names")] |
4 | 4 | use unicode_names2; |
5 | 5 |
|
6 | | -#[cfg(feature="wtf8")] |
| 6 | +#[cfg(feature = "wtf8")] |
7 | 7 | use wtf8; |
8 | 8 |
|
9 | | -use helpers::StrSpan; |
10 | | -use errors::PyParseError; |
11 | 9 | use ast::*; |
| 10 | +use errors::PyParseError; |
| 11 | +use helpers::StrSpan; |
12 | 12 |
|
13 | | -#[cfg(feature="wtf8")] |
| 13 | +#[cfg(feature = "wtf8")] |
14 | 14 | fn cp_from_char(c: char) -> wtf8::CodePoint { |
15 | 15 | wtf8::CodePoint::from_char(c) |
16 | 16 | } |
17 | | -#[cfg(feature="wtf8")] |
| 17 | +#[cfg(feature = "wtf8")] |
18 | 18 | fn cp_from_u32(n: u32) -> Option<wtf8::CodePoint> { |
19 | 19 | wtf8::CodePoint::from_u32(n) |
20 | 20 | } |
21 | | -#[cfg(not(feature="wtf8"))] |
| 21 | +#[cfg(not(feature = "wtf8"))] |
22 | 22 | fn cp_from_char(c: char) -> char { |
23 | 23 | c |
24 | 24 | } |
25 | | -#[cfg(not(feature="wtf8"))] |
| 25 | +#[cfg(not(feature = "wtf8"))] |
26 | 26 | fn cp_from_u32(n: u32) -> Option<char> { |
27 | 27 | ::std::char::from_u32(n) |
28 | 28 | } |
29 | 29 |
|
30 | | -#[cfg(feature="unicode-names")] |
| 30 | +#[cfg(feature = "unicode-names")] |
31 | 31 | named!(unicode_escaped_name<StrSpan, Option<PyStringCodePoint>>, |
32 | 32 | map!( |
33 | 33 | preceded!(char!('N'), delimited!(char!('{'), many1!(none_of!("}")), char!('}'))), |
34 | 34 | |name: Vec<char>| unicode_names2::character(&name.iter().collect::<String>()).map(cp_from_char) |
35 | 35 | ) |
36 | 36 | ); |
37 | 37 |
|
38 | | -#[cfg(not(feature="unicode-names"))] |
39 | | -pub fn unicode_escaped_name(i: StrSpan) -> Result<(StrSpan, Option<PyStringCodePoint>), ::nom::Err<StrSpan>> { |
40 | | - Err(::nom::Err::Error(::nom::Context::Code(i, ::nom::ErrorKind::Custom(PyParseError::DisabledFeature.into())))) |
| 38 | +#[cfg(not(feature = "unicode-names"))] |
| 39 | +pub fn unicode_escaped_name( |
| 40 | + i: StrSpan, |
| 41 | +) -> Result<(StrSpan, Option<PyStringCodePoint>), ::nom::Err<StrSpan>> { |
| 42 | + Err(::nom::Err::Error(::nom::Context::Code( |
| 43 | + i, |
| 44 | + ::nom::ErrorKind::Custom(PyParseError::DisabledFeature.into()), |
| 45 | + ))) |
41 | 46 | } |
42 | 47 |
|
43 | 48 | named!(escapedchar<StrSpan, Option<PyStringCodePoint>>, |
@@ -154,4 +159,3 @@ named!(pub string<StrSpan, PyString>, |
154 | 159 | ) >> (PyString { prefix: prefix.to_string(), content: content }) |
155 | 160 | ) |
156 | 161 | ); |
157 | | - |
|
0 commit comments