aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar/items/consts.rs
blob: 5f3cf58c2a6752e576fbd2f8684fff9b2ad9bb85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use super::*;

pub(super) fn static_item(p: &mut Parser) {
    const_or_static(p, STATIC_KW)
}

pub(super) fn const_item(p: &mut Parser) {
    const_or_static(p, CONST_KW)
}

fn const_or_static(p: &mut Parser, kw: SyntaxKind) {
    assert!(p.at(kw));
    p.bump();
    p.eat(MUT_KW); // TODO: validator to forbid const mut
    name(p);
    p.expect(COLON);
    types::ty(p);
    p.expect(EQ);
    expressions::expr(p);
    p.expect(SEMI);
}