Make usage of the $side metavariable
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
722e61cc85
commit
605798674f
1 changed files with 18 additions and 18 deletions
|
|
@ -655,32 +655,32 @@ fn parse_expression<'input>(
|
||||||
input: &mut Input<'input>,
|
input: &mut Input<'input>,
|
||||||
) -> Result<TemplateAstExpr<'input>, AstError> {
|
) -> Result<TemplateAstExpr<'input>, AstError> {
|
||||||
macro_rules! infix {
|
macro_rules! infix {
|
||||||
($parser:expr => [ $($side:ident $val:tt => $prec:expr),* $(,)? ]) => {
|
($parser:expr => [ $($side:tt $val:tt => $prec:expr),* $(,)? ]) => {
|
||||||
dispatch! { surrounded(ws, parse_operator);
|
dispatch! { surrounded(ws, parse_operator);
|
||||||
$(
|
$(
|
||||||
TokenOperator::$val => Left($prec, |_, lhs, rhs| Ok(TemplateAstExpr::Operation { op: TokenOperator::$val, lhs: Box::new(lhs), rhs: Box::new(rhs) }))
|
TokenOperator::$val => $side($prec, |_, lhs, rhs| Ok(TemplateAstExpr::Operation { op: TokenOperator::$val, lhs: Box::new(lhs), rhs: Box::new(rhs) }))
|
||||||
),*
|
),*
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
trace(
|
trace(
|
||||||
"expression",
|
"expression",
|
||||||
expression(surrounded(ws, parse_operand)).infix(
|
expression(surrounded(ws, parse_operand)).infix(infix! {
|
||||||
infix! { surrounded(ws, parse_operator) => [
|
surrounded(ws, parse_operator) => [
|
||||||
left Plus => 18,
|
Left Plus => 18,
|
||||||
left Minus => 18,
|
Left Minus => 18,
|
||||||
left Times => 20,
|
Left Times => 20,
|
||||||
left Divide => 20,
|
Left Divide => 20,
|
||||||
left And => 10,
|
Left And => 10,
|
||||||
left Or => 7,
|
Left Or => 7,
|
||||||
left Equal => 12,
|
Left Equal => 12,
|
||||||
left NotEqual => 12,
|
Left NotEqual => 12,
|
||||||
left Greater => 15,
|
Left Greater => 15,
|
||||||
left GreaterOrEqual => 15,
|
Left GreaterOrEqual => 15,
|
||||||
left Lesser => 15,
|
Left Lesser => 15,
|
||||||
left LesserOrEqual => 15,
|
Left LesserOrEqual => 15,
|
||||||
] },
|
]
|
||||||
),
|
}),
|
||||||
)
|
)
|
||||||
.parse_next(input)
|
.parse_next(input)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue