2019-09-30 11:58:53 +03:00
|
|
|
//! FIXME: write short doc here
|
|
|
|
|
2018-02-03 12:05:25 +03:00
|
|
|
use super::*;
|
|
|
|
|
2020-08-13 17:58:35 +02:00
|
|
|
pub(super) fn static_(p: &mut Parser, m: Marker) {
|
2020-07-30 18:02:20 +02:00
|
|
|
const_or_static(p, m, T![static], STATIC)
|
2018-02-03 12:05:25 +03:00
|
|
|
}
|
|
|
|
|
2020-08-13 17:58:35 +02:00
|
|
|
pub(super) fn konst(p: &mut Parser, m: Marker) {
|
2020-07-30 18:02:20 +02:00
|
|
|
const_or_static(p, m, T![const], CONST)
|
2018-02-03 12:05:25 +03:00
|
|
|
}
|
|
|
|
|
2019-03-18 14:34:08 +09: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));
|
2019-09-19 15:51:46 -04:00
|
|
|
p.bump(kw);
|
2019-05-15 15:35:47 +03:00
|
|
|
p.eat(T![mut]); // FIXME: validator to forbid const mut
|
2019-09-14 15:59:24 -07:00
|
|
|
|
|
|
|
// Allow `_` in place of an identifier in a `const`.
|
|
|
|
let is_const_underscore = kw == T![const] && p.eat(T![_]);
|
|
|
|
if !is_const_underscore {
|
|
|
|
name(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// test_err static_underscore
|
|
|
|
// static _: i32 = 5;
|
|
|
|
|
2018-07-31 15:35:59 +03:00
|
|
|
types::ascription(p);
|
2019-05-15 15:35:47 +03:00
|
|
|
if p.eat(T![=]) {
|
2018-08-08 00:53:03 +03:00
|
|
|
expressions::expr(p);
|
|
|
|
}
|
2019-05-15 15:35:47 +03:00
|
|
|
p.expect(T![;]);
|
2019-03-18 14:34:08 +09:00
|
|
|
m.complete(p, def);
|
2018-02-03 12:05:25 +03:00
|
|
|
}
|