MCPcopy Create free account
hub / github.com/Voxon-Development/zeta-lang / parse_enum_decl

Method parse_enum_decl

scribe-parser/src/parser/declarations.rs:379–404  ·  view source on GitHub ↗
(
        &mut self,
        visibility: Visibility,
    )

Source from the content-addressed store, hash-verified

377 }
378 }
379
380 Ok(self.bump.alloc_value_immutable(ir::ast::PermitsExpr {
381 types: self.bump.alloc_slice_immutable(&types),
382 span: token.span,
383 }))
384 }
385
386 pub fn parse_enum_decl(
387 &mut self,
388 visibility: Visibility,
389 ) -> Result<Stmt<'a, 'bump>, DiagnosticError<'a>> {
390 let token = self.cursor.expect(TokenKind::Enum)?;
391 let (name, _span) = self.cursor.expect_ident()?;
392 let generics = self.parse_generics()?;
393
394 let mut variants = Vec::new();
395
396 self.cursor.expect(TokenKind::LBrace)?;
397 while self.cursor.peek() != TokenKind::RBrace && self.cursor.peek() != TokenKind::EOF {
398 variants.push(self.parse_variant()?);
399 if !self.cursor.consume(TokenKind::Comma) {
400 break;
401 }
402 }
403 self.cursor.expect(TokenKind::RBrace)?;
404 Ok(Stmt::EnumDecl(self.bump.alloc_value_immutable(EnumDecl {
405 name,
406 visibility,
407 generics,

Callers 1

parse_stmtMethod · 0.80

Calls 9

EnumDeclClass · 0.85
expectMethod · 0.80
expect_identMethod · 0.80
parse_genericsMethod · 0.80
peekMethod · 0.80
parse_variantMethod · 0.80
consumeMethod · 0.80
alloc_slice_copyMethod · 0.80
alloc_value_immutableMethod · 0.45

Tested by

no test coverage detected