aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/parsing/grammar/items/consts.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-02-20 13:50:29 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-02-20 13:50:29 +0000
commit96899f8278b787280bd07d9ac9dce29a610ce40d (patch)
treed02a22f02908fd3c89e50845a06a89b997220fc2 /crates/ra_syntax/src/parsing/grammar/items/consts.rs
parent5b617e3bf8252887a3eb1ce76d4b62cbee74e551 (diff)
parent86a67dce25f11ba9803a5727f77c02fd1f49e2c0 (diff)
Merge #861
861: Move parsing to a separate module r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/parsing/grammar/items/consts.rs')
-rw-r--r--crates/ra_syntax/src/parsing/grammar/items/consts.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/parsing/grammar/items/consts.rs b/crates/ra_syntax/src/parsing/grammar/items/consts.rs
new file mode 100644
index 000000000..5a5852f83
--- /dev/null
+++ b/crates/ra_syntax/src/parsing/grammar/items/consts.rs
@@ -0,0 +1,21 @@
1use super::*;
2
3pub(super) fn static_def(p: &mut Parser) {
4 const_or_static(p, STATIC_KW)
5}
6
7pub(super) fn const_def(p: &mut Parser) {
8 const_or_static(p, CONST_KW)
9}
10
11fn const_or_static(p: &mut Parser, kw: SyntaxKind) {
12 assert!(p.at(kw));
13 p.bump();
14 p.eat(MUT_KW); // TODO: validator to forbid const mut
15 name(p);
16 types::ascription(p);
17 if p.eat(EQ) {
18 expressions::expr(p);
19 }
20 p.expect(SEMI);
21}