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

Method parse_lambda

scribe-parser/src/parser/expressions.rs:381–457  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

379 cursor.advance();
380 if cursor.peek() != TokenKind::Gt {
381 loop {
382 match Self::parse_type_impl(self.bump.clone(), &mut cursor, &mut pending) {
383 Ok(arg) => arg,
384 Err(_) => return false,
385 };
386 if !cursor.consume(TokenKind::Comma) {
387 break;
388 }
389 }
390 } else {
391 todo!("Handle error when trying to call like `hello<>()` ...")
392 }
393 if !Self::try_consume_close_angle(&mut cursor, &mut pending) {
394 return false;
395 }
396 matches!(
397 cursor.peek(),
398 TokenKind::LParen | TokenKind::LBrace | TokenKind::Dot | TokenKind::ColonColon
399 )
400 }
401
402 fn parse_prefix(&mut self) -> Result<Expr<'a, 'bump>, DiagnosticError<'a>> {
403 let tok = self.cursor.peek_token();
404
405 match tok.kind {
406 TokenKind::If => self.parse_if_expr(),
407 TokenKind::Match => self.parse_match_expr(),
408 TokenKind::Unsafe => {
409 self.cursor.advance();
410 let block = self.parse_block()?;
411 Ok(Expr::UnsafeBlock(self.bump.alloc_value_immutable(
412 UnsafeBlock {
413 block: self.bump.alloc_value_immutable(block),
414 span: tok.span,
415 },
416 )))
417 }
418
419 TokenKind::Hexadecimal => {
420 self.cursor.advance();
421 let text = tok.text.unwrap_or_default();
422 let value = Self::parse_radix_literal(text.as_str(), 2, 16);
423 Ok(Expr::Number {
424 value,
425 span: tok.span,
426 })
427 }
428 TokenKind::Octal => {
429 self.cursor.advance();
430 let text = tok.text.unwrap_or_default();
431 let value = Self::parse_radix_literal(text.as_str(), 2, 8);
432 Ok(Expr::Number {
433 value,
434 span: tok.span,
435 })
436 }
437 TokenKind::Binary => {
438 self.cursor.advance();

Callers 1

parse_prefixMethod · 0.80

Calls 11

peek_tokenMethod · 0.80
peekMethod · 0.80
advanceMethod · 0.80
expectMethod · 0.80
expect_identMethod · 0.80
consumeMethod · 0.80
parse_typeMethod · 0.80
parse_blockMethod · 0.80
mergeMethod · 0.80
alloc_slice_copyMethod · 0.80
alloc_value_immutableMethod · 0.45

Tested by

no test coverage detected