refactor ascription

This commit is contained in:
Aleksey Kladov 2018-07-31 15:35:59 +03:00
parent f843f23aba
commit 2a2815266b
3 changed files with 8 additions and 4 deletions

View File

@ -13,8 +13,7 @@ fn const_or_static(p: &mut Parser, kw: SyntaxKind) {
p.bump();
p.eat(MUT_KW); // TODO: validator to forbid const mut
name(p);
p.expect(COLON);
types::type_(p);
types::ascription(p);
p.expect(EQ);
expressions::expr(p);
p.expect(SEMI);

View File

@ -279,8 +279,8 @@ fn let_stmt(p: &mut Parser) {
let m = p.start();
p.bump();
patterns::pattern(p);
if p.eat(COLON) {
types::type_(p);
if p.at(COLON) {
types::ascription(p);
}
if p.eat(EQ) {
expressions::expr(p);

View File

@ -17,6 +17,11 @@ pub(super) fn type_(p: &mut Parser) {
}
}
pub(super) fn ascription(p: &mut Parser) {
p.expect(COLON);
type_(p)
}
fn type_no_plus(p: &mut Parser) {
type_(p);
}