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