From 99596c41f8b6f09b67427ba15e40a7fe3130e459 Mon Sep 17 00:00:00 2001
From: yossyJ <28825627+yossyJ@users.noreply.github.com>
Date: Tue, 8 Jan 2019 23:15:39 +0900
Subject: Add support for #![feature(non_ascii_idents)]
---
askama_derive/src/parser.rs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
(limited to 'askama_derive/src')
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> {
- 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> {
Ok((Input(&input[1..]), str::from_utf8(&input[..1]).unwrap()))
}
+#[inline]
+fn non_ascii(chr: u8) -> bool {
+ chr >= 0x80 && chr <= 0xFD
+}
+
named!(num_lit, map!(nom::digit,
|s| str::from_utf8(s.0).unwrap()
));
--
cgit