23 lines
541 B
Rust
Raw Normal View History

2018-02-03 12:05:25 +03:00
use super::*;
pub(super) fn static_def(p: &mut Parser, m: Marker) {
const_or_static(p, m, STATIC_KW, STATIC_DEF)
2018-02-03 12:05:25 +03:00
}
pub(super) fn const_def(p: &mut Parser, m: Marker) {
const_or_static(p, m, CONST_KW, CONST_DEF)
2018-02-03 12:05:25 +03:00
}
fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) {
2018-02-03 12:05:25 +03:00
assert!(p.at(kw));
p.bump();
2019-03-23 10:53:48 +03:00
p.eat(MUT_KW); // FIXME: validator to forbid const mut
2018-02-10 14:08:46 +03:00
name(p);
2018-07-31 15:35:59 +03:00
types::ascription(p);
2018-08-08 00:53:03 +03:00
if p.eat(EQ) {
expressions::expr(p);
}
2018-02-03 12:05:25 +03:00
p.expect(SEMI);
m.complete(p, def);
2018-02-03 12:05:25 +03:00
}