cel-rust
cel-rust copied to clipboard
The library cannot handle "3-1"?
My code:
use cel_interpreter::Program;
fn main() {
Program::compile("3-1").unwrap();
}
I expect this code to run without any issue, but the actual result:
$ cargo run
Compiling pubsub v0.1.0 (/home/user/test)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.48s
Running `target/debug/test`
thread 'main' panicked at src/main.rs:5:29:
called `Result::unwrap()` on an `Err` value: ParseError { msg: "unrecognized token: '-1'", expected: ["\"!=\"", "\"%\"", "\"&&\"", "\"*\"", "\"+\"", "\"-\"", "\".\"", "\"/\"", "\"<\"", "\"<=\"", "\"==\"", "\">\"", "\">=\"", "\"?\"", "\"[\"", "\"in\"", "\"{\"", "\"||\""], span: Span { start: Some(Location { line: 0, column: 1, absolute: 1 }), end: Some(Location { line: 0, column: 3, absolute: 3 }) } }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Yes, it might be that the CEL parser is not handling the '-' sign properly.
Should be resolved by #136
#136 does indeed fix this. Looks like a parser issue indeed, now the resulting AST:
_-_(
3^#1:*expr.Constant_Int64Value#,
1^#3:*expr.Constant_Int64Value#
)^#2:*expr.Expr_CallExpr#