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

Method parse_function_decl

crates/hll-to-ir/src/parser.rs:446–484  ·  view source on GitHub ↗
(
        &mut self,
        is_extern: bool,
        is_import_interface: bool,
    )

Source from the content-addressed store, hash-verified

444 });
445
446 let newline_separated = matches!(self.peek(), Some(Token::StatementTerminator));
447 self.consume_terminators();
448 if self.match_comma() {
449 self.consume_terminators();
450 } else if !newline_separated && !self.check_rbrace() {
451 return Err(self.error("expected `,` or newline between struct fields"));
452 }
453 }
454
455 self.expect_rbrace()?;
456 Ok(DeclNode::Struct {
457 name,
458 generics,
459 bounds,
460 fields,
461 })
462 }
463
464 fn parse_enum_decl(&mut self) -> Result<DeclNode, ParserError> {
465 let name = self.expect_ident()?;
466 let (generics, bounds) = self.parse_generic_params_with_bounds()?;
467 self.expect_lbrace()?;
468 let mut variants = Vec::new();
469 self.consume_terminators();
470
471 while !self.check_rbrace() {
472 let variant_name = self.expect_ident()?;
473 let mut payload = Vec::new();
474 if self.match_lparen() {
475 if !self.check_rparen() {
476 loop {
477 payload.push(self.parse_type()?);
478 if self.match_comma() {
479 if self.check_rparen() {
480 break;
481 }
482 continue;
483 }
484 break;
485 }
486 }
487 self.expect_rparen()?;

Callers 2

parse_declarationMethod · 0.80
parse_impl_blockMethod · 0.80

Calls 11

expect_identMethod · 0.80
expect_colonMethod · 0.80
parse_generic_paramsMethod · 0.80
parse_param_listMethod · 0.80
match_arrowMethod · 0.80
peekMethod · 0.80
peek_nMethod · 0.80
parse_return_typeMethod · 0.80
check_lbraceMethod · 0.80
parse_blockMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected