diff --git a/cozo-core/src/cozoscript.pest b/cozo-core/src/cozoscript.pest index 37751840..d4c54d69 100644 --- a/cozo-core/src/cozoscript.pest +++ b/cozo-core/src/cozoscript.pest @@ -100,12 +100,13 @@ named_apply_pair = {underscore_ident ~ (":" ~ expr)?} grouped = _{"(" ~ rule_body ~ ")"} expr = {unary_op* ~ term ~ (operation ~ unary_op* ~ term)*} -operation = _{ (op_and | op_or | op_pow | op_concat | op_add | op_sub | op_mul | op_div | op_mod | +operation = _{ (op_and | op_or | op_pow | op_concat | op_add | op_field_access | op_sub | op_mul | op_div | op_mod | op_ge | op_le | op_gt | op_lt | op_eq | op_ne | op_coalesce )} op_or = { "||" } op_and = { "&&" } op_concat = { "++" } op_add = { "+" } +op_field_access = { "->" } op_sub = { "-" } op_mul = { "*" } op_div = { "/" } diff --git a/cozo-core/src/parse/expr.rs b/cozo-core/src/parse/expr.rs index afba1c73..ac2ed2b4 100644 --- a/cozo-core/src/parse/expr.rs +++ b/cozo-core/src/parse/expr.rs @@ -18,7 +18,8 @@ use thiserror::Error; use crate::data::expr::{get_op, Bytecode, Expr, NoImplementationError}; use crate::data::functions::{ OP_ADD, OP_AND, OP_COALESCE, OP_CONCAT, OP_DIV, OP_EQ, OP_GE, OP_GT, OP_JSON_OBJECT, OP_LE, - OP_LIST, OP_LT, OP_MINUS, OP_MOD, OP_MUL, OP_NEGATE, OP_NEQ, OP_OR, OP_POW, OP_SUB, + OP_LIST, OP_LT, OP_MAYBE_GET, OP_MINUS, OP_MOD, OP_MUL, OP_NEGATE, OP_NEQ, OP_OR, OP_POW, + OP_SUB, }; use crate::data::symb::Symbol; use crate::data::value::DataValue; @@ -45,6 +46,7 @@ lazy_static! { .op(Op::infix(Rule::op_coalesce, Left)) .op(Op::prefix(Rule::minus)) .op(Op::prefix(Rule::negate)) + .op(Op::infix(Rule::op_field_access, Left)) }; } @@ -160,6 +162,7 @@ fn build_expr_infix(lhs: Result, op: Pair<'_>, rhs: Result) -> Resul Rule::op_or => &OP_OR, Rule::op_and => &OP_AND, Rule::op_coalesce => &OP_COALESCE, + Rule::op_field_access => &OP_MAYBE_GET, _ => unreachable!(), }; let start = args[0].span().0;