| 1105 | } |
| 1106 | |
| 1107 | std::vector<StructExprField> ParserVisitor::visitFields( |
| 1108 | CelParser::FieldInitializerListContext* ctx) { |
| 1109 | std::vector<StructExprField> res; |
| 1110 | if (!ctx || ctx->fields.empty()) { |
| 1111 | return res; |
| 1112 | } |
| 1113 | |
| 1114 | res.reserve(ctx->fields.size()); |
| 1115 | for (size_t i = 0; i < ctx->fields.size(); ++i) { |
| 1116 | if (i >= ctx->cols.size() || i >= ctx->values.size()) { |
| 1117 | // This is the result of a syntax error detected elsewhere. |
| 1118 | return res; |
| 1119 | } |
| 1120 | auto* f = ctx->fields[i]; |
| 1121 | if (!f->escapeIdent()) { |
| 1122 | ABSL_DCHECK(HasErrored()); |
| 1123 | // This is the result of a syntax error detected elsewhere. |
| 1124 | return res; |
| 1125 | } |
| 1126 | |
| 1127 | std::string id = NormalizeIdentifier(f->escapeIdent()); |
| 1128 | |
| 1129 | int64_t init_id = factory_.NextId(SourceRangeFromToken(ctx->cols[i])); |
| 1130 | if (!enable_optional_syntax_ && f->opt) { |
| 1131 | factory_.ReportError(SourceRangeFromParserRuleContext(ctx), |
| 1132 | "unsupported syntax '?'"); |
| 1133 | continue; |
| 1134 | } |
| 1135 | auto value = ExprFromAny(visit(ctx->values[i])); |
| 1136 | res.push_back(factory_.NewStructField(init_id, std::move(id), |
| 1137 | std::move(value), f->opt != nullptr)); |
| 1138 | } |
| 1139 | |
| 1140 | return res; |
| 1141 | } |
| 1142 | |
| 1143 | std::any ParserVisitor::visitIdent(CelParser::IdentContext* ctx) { |
| 1144 | std::string ident_name; |
nothing calls this directly
no test coverage detected