mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Fix parsing error if parentheses are padded with whitespace
This commit is contained in:
+16
-1
@@ -243,7 +243,7 @@ impl Condition {
|
||||
preceded!(fix_error!(ParsingError, ws!(tag!("not"))), call!(Function::parse)) => {
|
||||
|f| Condition::InvertedFunction(f)
|
||||
} |
|
||||
delimited!(fix_error!(ParsingError, tag!("(")), call!(parse_expression), fix_error!(ParsingError, tag!(")"))) => {
|
||||
delimited!(fix_error!(ParsingError, ws!(tag!("("))), call!(parse_expression), fix_error!(ParsingError, ws!(tag!(")")))) => {
|
||||
|e| Condition::Expression(e)
|
||||
}
|
||||
) >> (condition)
|
||||
@@ -585,6 +585,21 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn condition_parse_should_handle_an_expression_in_parentheses_with_whitespace() {
|
||||
let result = Condition::parse("( not file(\"Cargo.toml\") )".into())
|
||||
.unwrap()
|
||||
.1;
|
||||
|
||||
match result {
|
||||
Condition::Expression(_) => {}
|
||||
v => panic!(
|
||||
"Expected an expression with two compound conditions, got {:?}",
|
||||
v
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn condition_eval_should_return_function_eval_for_a_function_condition() {
|
||||
let state = state(".");
|
||||
|
||||
Reference in New Issue
Block a user