MCPcopy Create free account
hub / github.com/agenticsorg/lean-agentic / parse_let_expr

Method parse_let_expr

leanr-syntax/src/parser.rs:431–461  ·  view source on GitHub ↗

Parse let expression

(&mut self)

Source from the content-addressed store, hash-verified

429
430 /// Parse let expression
431 fn parse_let_expr(&mut self) -> crate::Result<Expr> {
432 if self.check(&TokenKind::Let) {
433 let start = self.advance().span;
434 let name = self.parse_ident()?;
435
436 let type_ = if self.check(&TokenKind::Colon) {
437 self.advance();
438 Some(Box::new(self.parse_expr()?))
439 } else {
440 None
441 };
442
443 self.expect(TokenKind::ColonEq)?;
444 let value = Box::new(self.parse_expr()?);
445
446 self.expect(TokenKind::In)?;
447 let body = Box::new(self.parse_expr()?);
448
449 let span = start.to(body.span());
450
451 Ok(Expr::Let {
452 span,
453 name,
454 type_,
455 value,
456 body,
457 })
458 } else {
459 self.parse_match_expr()
460 }
461 }
462
463 /// Parse match expression
464 fn parse_match_expr(&mut self) -> crate::Result<Expr> {

Callers 1

parse_lambda_exprMethod · 0.80

Calls 8

parse_identMethod · 0.80
parse_exprMethod · 0.80
expectMethod · 0.80
toMethod · 0.80
spanMethod · 0.80
parse_match_exprMethod · 0.80
checkMethod · 0.45
advanceMethod · 0.45

Tested by

no test coverage detected