aboutsummaryrefslogtreecommitdiffstats
path: root/askama_parser/src/lib.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-02 10:59:50 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-31 10:27:15 +0200
commit3603d437619abb9b41a7e846d6f8d5fcbc0a7fc6 (patch)
tree955f348aaf3b54c86398dbc6322f998ebd53fc38 /askama_parser/src/lib.rs
parente40e93796f45d34d038c6a20c4b034eb3b384b12 (diff)
downloadaskama-3603d437619abb9b41a7e846d6f8d5fcbc0a7fc6.tar.gz
askama-3603d437619abb9b41a7e846d6f8d5fcbc0a7fc6.tar.bz2
askama-3603d437619abb9b41a7e846d6f8d5fcbc0a7fc6.zip
parser: move single-use functions into caller
Diffstat (limited to 'askama_parser/src/lib.rs')
-rw-r--r--askama_parser/src/lib.rs26
1 files changed, 13 insertions, 13 deletions
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> {