Got compilation working again
This commit is contained in:
parent
a6c86d6447
commit
745afe981a
@ -814,9 +814,9 @@ impl Parser {
|
|||||||
fn if_expr(&mut self) -> ParseResult<Expression> {
|
fn if_expr(&mut self) -> ParseResult<Expression> {
|
||||||
expect!(self, Keyword(Kw::If));
|
expect!(self, Keyword(Kw::If));
|
||||||
let discriminator = if let LCurlyBrace = self.token_handler.peek_kind() {
|
let discriminator = if let LCurlyBrace = self.token_handler.peek_kind() {
|
||||||
Some(Box::new(self.expression()?))
|
|
||||||
} else {
|
|
||||||
None
|
None
|
||||||
|
} else {
|
||||||
|
Some(Box::new(self.expression()?))
|
||||||
};
|
};
|
||||||
let body = Box::new(self.if_expr_body()?);
|
let body = Box::new(self.if_expr_body()?);
|
||||||
Ok(Expression::new(self.id_store.fresh(), ExpressionKind::IfExpression { discriminator, body }))
|
Ok(Expression::new(self.id_store.fresh(), ExpressionKind::IfExpression { discriminator, body }))
|
||||||
@ -902,7 +902,7 @@ impl Parser {
|
|||||||
self.token_handler.next();
|
self.token_handler.next();
|
||||||
Condition::Pattern(self.pattern()?)
|
Condition::Pattern(self.pattern()?)
|
||||||
},
|
},
|
||||||
tok if BinOp::from_sigil_token(&tok).is_some() => {
|
ref tok if BinOp::from_sigil_token(tok).is_some() => {
|
||||||
let op = BinOp::from_sigil_token(&self.token_handler.next().kind).unwrap();
|
let op = BinOp::from_sigil_token(&self.token_handler.next().kind).unwrap();
|
||||||
let expr = self.expression()?;
|
let expr = self.expression()?;
|
||||||
Condition::TruncatedOp(op, expr)
|
Condition::TruncatedOp(op, expr)
|
||||||
|
@ -237,27 +237,27 @@ impl<'a> Reducer<'a> {
|
|||||||
let symbol_table = self.symbol_table;
|
let symbol_table = self.symbol_table;
|
||||||
let cond = Box::new(match discriminator {
|
let cond = Box::new(match discriminator {
|
||||||
Some(expr) => self.expression(expr),
|
Some(expr) => self.expression(expr),
|
||||||
None => Expr::Lit(Lit::Bool(true)),
|
None => return Expr::ReductionError(format!("blank cond if-expr not supported")),
|
||||||
});
|
});
|
||||||
|
|
||||||
match *body {
|
match body {
|
||||||
IfExpressionBody::SimpleConditional { then_case, else_case } => {
|
IfExpressionBody::SimpleConditional { then_case, else_case } => {
|
||||||
let then_clause = self.block(then_case);
|
let then_clause = self.block(&then_case);
|
||||||
let else_clause = match else_case {
|
let else_clause = match else_case.as_ref() {
|
||||||
None => vec![],
|
None => vec![],
|
||||||
Some(stmts) => self.block(stmts),
|
Some(stmts) => self.block(&stmts),
|
||||||
};
|
};
|
||||||
Expr::Conditional { cond, then_clause, else_clause }
|
Expr::Conditional { cond, then_clause, else_clause }
|
||||||
},
|
},
|
||||||
IfExpressionBody::SimplePatternMatch(ref pat, ref then_clause, ref else_clause) => {
|
IfExpressionBody::SimplePatternMatch { pattern, then_case, else_case } => {
|
||||||
let then_clause = self.block(then_clause);
|
let then_clause = self.block(&then_case);
|
||||||
let else_clause = match else_clause {
|
let else_clause = match else_case.as_ref() {
|
||||||
None => vec![],
|
None => vec![],
|
||||||
Some(stmts) => self.block(stmts),
|
Some(stmts) => self.block(&stmts),
|
||||||
};
|
};
|
||||||
|
|
||||||
let alternatives = vec![
|
let alternatives = vec![
|
||||||
pat.to_alternative(then_clause, symbol_table),
|
pattern.to_alternative(then_clause, symbol_table),
|
||||||
Alternative {
|
Alternative {
|
||||||
matchable: Subpattern {
|
matchable: Subpattern {
|
||||||
tag: None,
|
tag: None,
|
||||||
@ -274,26 +274,22 @@ impl<'a> Reducer<'a> {
|
|||||||
alternatives,
|
alternatives,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
IfExpressionBody::GuardList(ref guard_arms) => {
|
IfExpressionBody::CondList(ref condition_arms) => {
|
||||||
let mut alternatives = vec![];
|
let mut alternatives = vec![];
|
||||||
for arm in guard_arms {
|
for arm in condition_arms {
|
||||||
match arm.guard {
|
match arm.condition {
|
||||||
Guard::None => {
|
Condition::Expression(ref _expr) => {
|
||||||
let item = self.block(&arm.body);
|
return Expr::UnimplementedSigilValue
|
||||||
let alt = Alternative {
|
|
||||||
item, matchable: Subpattern {
|
|
||||||
tag: None, subpatterns: vec![],
|
|
||||||
bound_vars: vec![], guard: None,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
alternatives.push(alt);
|
|
||||||
},
|
},
|
||||||
Guard::Pat(ref p) => {
|
Condition::Pattern(ref p) => {
|
||||||
let item = self.block(&arm.body);
|
let item = self.block(&arm.body);
|
||||||
let alt = p.to_alternative(item, symbol_table);
|
let alt = p.to_alternative(item, symbol_table);
|
||||||
alternatives.push(alt);
|
alternatives.push(alt);
|
||||||
},
|
},
|
||||||
Guard::HalfExpr(HalfExpr { op: _, expr: _ }) => {
|
Condition::TruncatedOp(_, _) => {
|
||||||
|
return Expr::UnimplementedSigilValue
|
||||||
|
},
|
||||||
|
Condition::Else => {
|
||||||
return Expr::UnimplementedSigilValue
|
return Expr::UnimplementedSigilValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user