diff options
author | yossyJ <28825627+yossyJ@users.noreply.github.com> | 2019-01-08 23:15:39 +0900 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2019-01-08 15:56:07 +0100 |
commit | 99596c41f8b6f09b67427ba15e40a7fe3130e459 (patch) | |
tree | ec37c99d21f1907b652da2edb05f03f27e32bccf /askama_derive/src/parser.rs | |
parent | ed47f17f3c0d9155be51964e377790a29d254a21 (diff) | |
download | askama-99596c41f8b6f09b67427ba15e40a7fe3130e459.tar.gz askama-99596c41f8b6f09b67427ba15e40a7fe3130e459.tar.bz2 askama-99596c41f8b6f09b67427ba15e40a7fe3130e459.zip |
Add support for #![feature(non_ascii_idents)]
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/parser.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/askama_derive/src/parser.rs b/askama_derive/src/parser.rs index c5e610e..27a9ed0 100644 --- a/askama_derive/src/parser.rs +++ b/askama_derive/src/parser.rs @@ -178,14 +178,14 @@ fn take_content<'a>( } fn identifier(input: Input) -> Result<(Input, &str), nom::Err<Input>> { - if !nom::is_alphabetic(input[0]) && input[0] != b'_' { + if !nom::is_alphabetic(input[0]) && input[0] != b'_' && !non_ascii(input[0]) { return Err(nom::Err::Error(error_position!( input, nom::ErrorKind::Custom(0) ))); } for (i, ch) in input.iter().enumerate() { - if i == 0 || nom::is_alphanumeric(*ch) || *ch == b'_' { + if i == 0 || nom::is_alphanumeric(*ch) || *ch == b'_' || non_ascii(*ch) { continue; } return Ok((Input(&input[i..]), str::from_utf8(&input[..i]).unwrap())); @@ -193,6 +193,11 @@ fn identifier(input: Input) -> Result<(Input, &str), nom::Err<Input>> { Ok((Input(&input[1..]), str::from_utf8(&input[..1]).unwrap())) } +#[inline] +fn non_ascii(chr: u8) -> bool { + chr >= 0x80 && chr <= 0xFD +} + named!(num_lit<Input, &str>, map!(nom::digit, |s| str::from_utf8(s.0).unwrap() )); |