ast: rename Let to Bind
This commit is contained in:
@@ -705,11 +705,11 @@ impl<'t> Parse<'t> for Fn {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'t> Parse<'t> for Let {
|
||||
type Prec = LetKind;
|
||||
impl<'t> Parse<'t> for Bind {
|
||||
type Prec = BindKind;
|
||||
|
||||
fn parse(p: &mut Parser<'t>, level: Self::Prec) -> PResult<Self> {
|
||||
if let LetKind::Match = level {
|
||||
if let BindKind::Match = level {
|
||||
// |? Pat => Expr
|
||||
p.next_if(TKind::Bar)?.ok(); // and discard
|
||||
return Ok(Self(
|
||||
@@ -800,8 +800,8 @@ fn parse_for<'t>(p: &mut Parser<'t>, _level: ()) -> PResult<Expr> {
|
||||
],
|
||||
)
|
||||
.anno(cspan),
|
||||
Expr::Let(Box::new(Let(
|
||||
LetKind::Match,
|
||||
Expr::Bind(Box::new(Bind(
|
||||
BindKind::Match,
|
||||
Pat::Name("#iter".into()),
|
||||
vec![
|
||||
Expr::Op(
|
||||
@@ -822,14 +822,14 @@ fn parse_for<'t>(p: &mut Parser<'t>, _level: ()) -> PResult<Expr> {
|
||||
],
|
||||
)
|
||||
.anno(cspan),
|
||||
Expr::Let(Box::new(Let(
|
||||
LetKind::Match,
|
||||
Expr::Bind(Box::new(Bind(
|
||||
BindKind::Match,
|
||||
Pat::Name("None".into()),
|
||||
vec![Expr::Op(Op::Break, vec![fail]).anno(fspan)],
|
||||
)))
|
||||
.anno(fspan),
|
||||
Expr::Let(Box::new(Let(
|
||||
LetKind::Match,
|
||||
Expr::Bind(Box::new(Bind(
|
||||
BindKind::Match,
|
||||
Pat::TupStruct(
|
||||
"Some".into(),
|
||||
Box::new(Pat::Op(PatOp::Tuple, vec![pat])),
|
||||
@@ -876,9 +876,9 @@ impl<'t> Parse<'t> for Expr {
|
||||
Ps::Id => Expr::Id(p.parse(())?),
|
||||
Ps::Mid => Expr::MetId(p.consume().next()?.lexeme.to_string()),
|
||||
Ps::Lit => Expr::Lit(p.parse(())?),
|
||||
Ps::Let => Expr::Let(p.parse(LetKind::Let)?),
|
||||
Ps::Const => Expr::Let(p.parse(LetKind::Const)?),
|
||||
Ps::Static => Expr::Let(p.parse(LetKind::Static)?),
|
||||
Ps::Let => Expr::Bind(p.parse(BindKind::Let)?),
|
||||
Ps::Const => Expr::Bind(p.parse(BindKind::Const)?),
|
||||
Ps::Static => Expr::Bind(p.parse(BindKind::Static)?),
|
||||
Ps::For => parse_for(p, ())?,
|
||||
Ps::Typedef => Expr::Struct(p.parse(())?),
|
||||
Ps::Mod => Expr::Mod(p.parse(())?),
|
||||
@@ -1024,9 +1024,9 @@ fn parse_match<'t>(p: &mut Parser<'t>) -> PResult<Expr> {
|
||||
|
||||
let arms = p
|
||||
.expect(TKind::LCurly)?
|
||||
.list(vec![], LetKind::Match, TKind::Comma, TKind::RCurly)?
|
||||
.list(vec![], BindKind::Match, TKind::Comma, TKind::RCurly)?
|
||||
.into_iter()
|
||||
.map(|Anno(arm, span)| Anno(Expr::Let(Box::new(arm)), span));
|
||||
.map(|Anno(arm, span)| Anno(Expr::Bind(Box::new(arm)), span));
|
||||
|
||||
let expr = Expr::Op(Op::Match, iter::once(scrutinee).chain(arms).collect());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user