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

Method field_initializer_list

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

Source from the content-addressed store, hash-verified

248 }
249
250 fn field_initializer_list(
251 &mut self,
252 ctx: &Field_initializer_listContext<'_>,
253 ) -> Vec<IdedEntryExpr> {
254 let mut fields = Vec::with_capacity(ctx.fields.len());
255 for (i, field) in ctx.fields.iter().enumerate() {
256 if i >= ctx.cols.len() || i >= ctx.values.len() {
257 return vec![];
258 }
259 let id = self.helper.next_id(&ctx.cols[i]);
260
261 match field.escapeIdent() {
262 None => {
263 self.report_error::<ParseError, _>(
264 field.start().deref(),
265 None,
266 "unsupported ident type",
267 );
268 continue;
269 }
270 Some(ident) => {
271 let field_name = ident.get_text().to_string();
272 let value = self.visit(ctx.values[i].as_ref());
273 let is_optional = match (&field.opt, self.enable_optional_syntax) {
274 (Some(opt), false) => {
275 self.report_error::<ParseError, _>(
276 opt.as_ref(),
277 None,
278 "unsupported syntax '?'",
279 );
280 continue;
281 }
282 (Some(_), true) => true,
283 (None, _) => false,
284 };
285 fields.push(IdedEntryExpr {
286 id,
287 expr: EntryExpr::StructField(StructFieldExpr {
288 field: field_name,
289 value,
290 optional: is_optional,
291 }),
292 });
293 }
294 }
295 }
296 fields
297 }
298
299 fn map_initializer_list(&mut self, ctx: &MapInitializerListContextAll) -> Vec<IdedEntryExpr> {
300 if ctx.keys.is_empty() {

Callers 1

visit_CreateMessageMethod · 0.45

Calls 7

next_idMethod · 0.80
startMethod · 0.80
visitMethod · 0.80
pushMethod · 0.80
iterMethod · 0.45
escapeIdentMethod · 0.45
derefMethod · 0.45

Tested by

no test coverage detected