| 719 | } |
| 720 | |
| 721 | std::any ParserVisitor::visit(antlr4::tree::ParseTree* tree) { |
| 722 | ScopedIncrement inc(recursion_depth_); |
| 723 | if (recursion_depth_ > max_recursion_depth_) { |
| 724 | return ExprToAny(factory_.ReportError( |
| 725 | absl::StrFormat("Exceeded max recursion depth of %d when parsing.", |
| 726 | max_recursion_depth_))); |
| 727 | } |
| 728 | tree = UnnestContext(tree); |
| 729 | if (auto* ctx = tree_as<CelParser::StartContext>(tree)) { |
| 730 | return visitStart(ctx); |
| 731 | } else if (auto* ctx = tree_as<CelParser::ExprContext>(tree)) { |
| 732 | return visitExpr(ctx); |
| 733 | } else if (auto* ctx = tree_as<CelParser::ConditionalAndContext>(tree)) { |
| 734 | return visitConditionalAnd(ctx); |
| 735 | } else if (auto* ctx = tree_as<CelParser::ConditionalOrContext>(tree)) { |
| 736 | return visitConditionalOr(ctx); |
| 737 | } else if (auto* ctx = tree_as<CelParser::RelationContext>(tree)) { |
| 738 | return visitRelation(ctx); |
| 739 | } else if (auto* ctx = tree_as<CelParser::CalcContext>(tree)) { |
| 740 | return visitCalc(ctx); |
| 741 | } else if (auto* ctx = tree_as<CelParser::LogicalNotContext>(tree)) { |
| 742 | return visitLogicalNot(ctx); |
| 743 | } else if (auto* ctx = tree_as<CelParser::PrimaryExprContext>(tree)) { |
| 744 | return visitPrimaryExpr(ctx); |
| 745 | } else if (auto* ctx = tree_as<CelParser::MemberExprContext>(tree)) { |
| 746 | return visitMemberExpr(ctx); |
| 747 | } else if (auto* ctx = tree_as<CelParser::SelectContext>(tree)) { |
| 748 | return visitSelect(ctx); |
| 749 | } else if (auto* ctx = tree_as<CelParser::MemberCallContext>(tree)) { |
| 750 | return visitMemberCall(ctx); |
| 751 | } else if (auto* ctx = tree_as<CelParser::MapInitializerListContext>(tree)) { |
| 752 | return visitMapInitializerList(ctx); |
| 753 | } else if (auto* ctx = tree_as<CelParser::NegateContext>(tree)) { |
| 754 | return visitNegate(ctx); |
| 755 | } else if (auto* ctx = tree_as<CelParser::IndexContext>(tree)) { |
| 756 | return visitIndex(ctx); |
| 757 | } else if (auto* ctx = tree_as<CelParser::UnaryContext>(tree)) { |
| 758 | return visitUnary(ctx); |
| 759 | } else if (auto* ctx = tree_as<CelParser::CreateListContext>(tree)) { |
| 760 | return visitCreateList(ctx); |
| 761 | } else if (auto* ctx = tree_as<CelParser::CreateMessageContext>(tree)) { |
| 762 | return visitCreateMessage(ctx); |
| 763 | } else if (auto* ctx = tree_as<CelParser::CreateMapContext>(tree)) { |
| 764 | return visitCreateMap(ctx); |
| 765 | } |
| 766 | |
| 767 | if (tree) { |
| 768 | return ExprToAny( |
| 769 | factory_.ReportError(SourceRangeFromParserRuleContext( |
| 770 | tree_as<antlr4::ParserRuleContext>(tree)), |
| 771 | "unknown parsetree type")); |
| 772 | } |
| 773 | return ExprToAny(factory_.ReportError("<<nil>> parsetree")); |
| 774 | } |
| 775 | |
| 776 | std::any ParserVisitor::visitPrimaryExpr(CelParser::PrimaryExprContext* pctx) { |
| 777 | CelParser::PrimaryContext* primary = pctx->primary(); |
no test coverage detected