MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / parse_struct_decl

Method parse_struct_decl

crates/hll-to-ir/src/parser.rs:365–397  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

363 loop {
364 // A virtual `>` still belongs to the enclosing generic type. Suffixes
365 // after `>>` therefore apply only after that outer close is consumed.
366 if self.pending_gt_from_shr {
367 break;
368 }
369
370 if self.match_star() {
371 ty = Type::Pointer(Box::new(ty));
372 continue;
373 }
374
375 if self.match_lbracket() {
376 // T[] is a slice; T[N] is a fixed array.
377 if self.match_rbracket() {
378 ty = Type::Slice(Box::new(ty));
379 continue;
380 }
381 let size = self.parse_array_length()?;
382 self.expect_rbracket()?;
383 ty = Type::Array(size, Box::new(ty));
384 continue;
385 }
386
387 break;
388 }
389
390 Ok(ty)
391 }
392
393 fn parse_variable_decl(&mut self) -> Result<DeclNode, ParserError> {
394 let name = self.expect_ident()?;
395 self.expect_colon()?;
396 let ty = self.parse_type()?;
397 let init = if self.match_assign() {
398 Some(self.parse_expression()?)
399 } else {
400 return Err(self

Callers 1

parse_declarationMethod · 0.80

Calls 11

expect_identMethod · 0.80
parse_generic_paramsMethod · 0.80
expect_lbraceMethod · 0.80
consume_terminatorsMethod · 0.80
check_rbraceMethod · 0.80
expect_colonMethod · 0.80
parse_typeMethod · 0.80
pushMethod · 0.80
match_commaMethod · 0.80
expect_rbraceMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected