diff options
| author | 2023-07-21 14:35:35 +0200 | |
|---|---|---|
| committer | 2023-08-03 00:02:04 +0200 | |
| commit | d4fbad1db221e780586d1849720e5bb6d70e982c (patch) | |
| tree | 9f43c5f513d2b2b9240bdf3bf4d4ebb96749af5a /askama_parser/src | |
| parent | 95ff27c087f9fd77e76ed069220d7b32d150a84e (diff) | |
| download | askama-d4fbad1db221e780586d1849720e5bb6d70e982c.tar.gz askama-d4fbad1db221e780586d1849720e5bb6d70e982c.tar.bz2 askama-d4fbad1db221e780586d1849720e5bb6d70e982c.zip | |
Optimize parsing boolean literals, too
Diffstat (limited to '')
| -rw-r--r-- | askama_parser/src/expr.rs | 14 | 
1 files changed, 5 insertions, 9 deletions
| diff --git a/askama_parser/src/expr.rs b/askama_parser/src/expr.rs index 248bc19..ca1dc9b 100644 --- a/askama_parser/src/expr.rs +++ b/askama_parser/src/expr.rs @@ -10,8 +10,7 @@ use nom::sequence::{pair, preceded, terminated, tuple};  use nom::{error_position, IResult};  use super::{ -    bool_lit, char_lit, identifier, not_ws, num_lit, path_or_identifier, str_lit, ws, -    PathOrIdentifier, +    char_lit, identifier, not_ws, num_lit, path_or_identifier, str_lit, ws, PathOrIdentifier,  };  macro_rules! expr_prec_layer { @@ -140,11 +139,10 @@ impl<'a> Expr<'a> {      fn single(i: &'a str) -> IResult<&'a str, Self> {          alt(( -            Self::bool,              Self::num,              Self::str,              Self::char, -            Self::path_or_var, +            Self::path_var_bool,              Self::array,              Self::group,          ))(i) @@ -188,9 +186,11 @@ impl<'a> Expr<'a> {          )(i)      } -    fn path_or_var(i: &'a str) -> IResult<&'a str, Self> { +    fn path_var_bool(i: &'a str) -> IResult<&'a str, Self> {          map(path_or_identifier, |v| match v {              PathOrIdentifier::Path(v) => Self::Path(v), +            PathOrIdentifier::Identifier(v @ "true") => Self::BoolLit(v), +            PathOrIdentifier::Identifier(v @ "false") => Self::BoolLit(v),              PathOrIdentifier::Identifier(v) => Self::Var(v),          })(i)      } @@ -206,10 +206,6 @@ impl<'a> Expr<'a> {      fn char(i: &'a str) -> IResult<&'a str, Self> {          map(char_lit, Self::CharLit)(i)      } - -    fn bool(i: &'a str) -> IResult<&'a str, Self> { -        map(bool_lit, Self::BoolLit)(i) -    }  }  enum Suffix<'a> { | 
