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.bump();
p.eat(MUT_KW); // TODO: validator to forbid const mut p.eat(MUT_KW); // TODO: validator to forbid const mut
name(p); name(p);
p.expect(COLON); types::ascription(p);
types::type_(p);
p.expect(EQ); p.expect(EQ);
expressions::expr(p); expressions::expr(p);
p.expect(SEMI); p.expect(SEMI);

View file

@ -279,8 +279,8 @@ fn fn_item(p: &mut Parser) {
let m = p.start(); let m = p.start();
p.bump(); p.bump();
patterns::pattern(p); patterns::pattern(p);
if p.eat(COLON) { if p.at(COLON) {
types::type_(p); types::ascription(p);
} }
if p.eat(EQ) { if p.eat(EQ) {
expressions::expr(p); 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) { fn type_no_plus(p: &mut Parser) {
type_(p); type_(p);
} }