MCPcopy Create free account
hub / github.com/cel-rust/cel-rust / visit_calc

Method visit_calc

cel/src/parser/parser.rs:640–674  ·  view source on GitHub ↗
(&mut self, ctx: &CalcContext<'_>)

Source from the content-addressed store, hash-verified

638 }
639
640 fn visit_calc(&mut self, ctx: &CalcContext<'_>) -> Self::Return {
641 match &ctx.op {
642 None => match &ctx.unary() {
643 None => self.report_error::<ParseError, _>(
644 ctx.start().deref(),
645 None,
646 "No `UnaryContextAll`!",
647 ),
648 Some(unary) => self.visit(unary.as_ref()),
649 },
650 Some(op) => {
651 if let (Some(lhs), Some(rhs)) = (ctx.calc(0), ctx.calc(1)) {
652 let lhs = self.visit(lhs.as_ref());
653 let op_id = self.helper.next_id(op);
654 let rhs = self.visit(rhs.as_ref());
655 match operators::find_operator(op.get_text()) {
656 None => self.report_error::<ParseError, _>(
657 op,
658 None,
659 format!("Unknown `{}` operator!", op.get_text()),
660 ),
661 Some(op) => {
662 self.global_call_or_macro(op_id, op.to_string(), vec![lhs, rhs])
663 }
664 }
665 } else {
666 self.report_error::<ParseError, _>(
667 ctx.start().deref(),
668 None,
669 "Incomplete `CalcContext`!",
670 )
671 }
672 }
673 }
674 }
675
676 fn visit_MemberExpr(&mut self, ctx: &MemberExprContext<'_>) -> Self::Return {
677 match &ctx.member() {

Callers

nothing calls this directly

Calls 8

find_operatorFunction · 0.85
startMethod · 0.80
visitMethod · 0.80
next_idMethod · 0.80
global_call_or_macroMethod · 0.80
unaryMethod · 0.45
derefMethod · 0.45
calcMethod · 0.45

Tested by

no test coverage detected