Add eval_expression_tree_raw.

This commit is contained in:
Stephen Chung
2022-07-06 12:56:15 +08:00
parent b4dbc7619a
commit dda7bc7b85
7 changed files with 104 additions and 12 deletions

View File

@@ -52,7 +52,13 @@ fn test_custom_syntax() -> Result<(), Box<EvalAltResult>> {
break;
}
context.eval_expression_tree(stmt)?;
// Do not rewind if the variable is upper-case
if var_name.to_uppercase() == var_name {
context.eval_expression_tree_raw(stmt, false)?;
} else {
context.eval_expression_tree(stmt)?;
}
count += 1;
context
@@ -125,6 +131,26 @@ fn test_custom_syntax() -> Result<(), Box<EvalAltResult>> {
)?,
144
);
assert_eq!(
engine.eval::<INT>(
"
let foo = 123;
exec [x<15] -> { let foo = x; x += 1; } while x < 42;
foo
"
)?,
123
);
assert_eq!(
engine.eval::<INT>(
"
let foo = 123;
exec [ABC<15] -> { let foo = ABC; ABC += 1; } while ABC < 42;
foo
"
)?,
14
);
// The first symbol must be an identifier
assert_eq!(