From 3603d437619abb9b41a7e846d6f8d5fcbc0a7fc6 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 2 Jul 2023 10:59:50 +0200 Subject: parser: move single-use functions into caller --- askama_parser/src/lib.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'askama_parser') diff --git a/askama_parser/src/lib.rs b/askama_parser/src/lib.rs index 336004e..e7c387b 100644 --- a/askama_parser/src/lib.rs +++ b/askama_parser/src/lib.rs @@ -196,21 +196,21 @@ fn keyword<'a>(k: &'a str) -> impl FnMut(&'a str) -> IResult<&'a str, &'a str> { } fn identifier(input: &str) -> IResult<&str, &str> { - recognize(pair(identifier_start, opt(identifier_tail)))(input) -} + fn start(s: &str) -> IResult<&str, &str> { + s.split_at_position1_complete( + |c| !(c.is_alpha() || c == '_' || c >= '\u{0080}'), + nom::error::ErrorKind::Alpha, + ) + } -fn identifier_start(s: &str) -> IResult<&str, &str> { - s.split_at_position1_complete( - |c| !(c.is_alpha() || c == '_' || c >= '\u{0080}'), - nom::error::ErrorKind::Alpha, - ) -} + fn tail(s: &str) -> IResult<&str, &str> { + s.split_at_position1_complete( + |c| !(c.is_alphanum() || c == '_' || c >= '\u{0080}'), + nom::error::ErrorKind::Alpha, + ) + } -fn identifier_tail(s: &str) -> IResult<&str, &str> { - s.split_at_position1_complete( - |c| !(c.is_alphanum() || c == '_' || c >= '\u{0080}'), - nom::error::ErrorKind::Alpha, - ) + recognize(pair(start, opt(tail)))(input) } fn bool_lit(i: &str) -> IResult<&str, &str> { -- cgit