From b5021411a84822cb3f1e3aeffad9550dd15bdeb6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 16 Sep 2018 12:54:24 +0300 Subject: rename all things --- crates/ra_syntax/src/grammar/items/consts.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 crates/ra_syntax/src/grammar/items/consts.rs (limited to 'crates/ra_syntax/src/grammar/items/consts.rs') diff --git a/crates/ra_syntax/src/grammar/items/consts.rs b/crates/ra_syntax/src/grammar/items/consts.rs new file mode 100644 index 000000000..5a5852f83 --- /dev/null +++ b/crates/ra_syntax/src/grammar/items/consts.rs @@ -0,0 +1,21 @@ +use super::*; + +pub(super) fn static_def(p: &mut Parser) { + const_or_static(p, STATIC_KW) +} + +pub(super) fn const_def(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); + types::ascription(p); + if p.eat(EQ) { + expressions::expr(p); + } + p.expect(SEMI); +} -- cgit v1.2.3