(
&mut self,
ctx: &Field_initializer_listContext<'_>,
)
| 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() { |
no test coverage detected