diff options
Diffstat (limited to 'askama_shared/src/parser.rs')
-rw-r--r-- | askama_shared/src/parser.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs index 8732f0e..8ff2063 100644 --- a/askama_shared/src/parser.rs +++ b/askama_shared/src/parser.rs @@ -229,15 +229,21 @@ named!(expr_filtered<Expr>, do_parse!( macro_rules! expr_prec_layer { ( $name:ident, $inner:ident, $( $op:expr ),* ) => { - named!($name<Expr>, alt!( + named!($name<Expr>, do_parse!( left: $inner >> - op: ws!(alt!($( tag_s!($op) )|*)) >> - right: $inner >> - (Expr::BinOp(str::from_utf8(op).unwrap(), + op_and_right: opt!(pair!(ws!(alt!($( tag_s!($op) )|*)), expr_any)) >> + ( + if op_and_right.is_some() { + let (op, right) = op_and_right.unwrap(); + (Expr::BinOp(str::from_utf8(op).unwrap(), Box::new(left), Box::new(right))) - ) | $inner - )); + } else { + left + } + ) + ) + ); } } |