From 7c67612b8a894187fa3b64725531a5459f9211bf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 10 Aug 2018 22:33:29 +0300 Subject: organizize --- crates/libsyntax2/src/grammar/items/consts.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 crates/libsyntax2/src/grammar/items/consts.rs (limited to 'crates/libsyntax2/src/grammar/items/consts.rs') diff --git a/crates/libsyntax2/src/grammar/items/consts.rs b/crates/libsyntax2/src/grammar/items/consts.rs new file mode 100644 index 000000000..b11949b49 --- /dev/null +++ b/crates/libsyntax2/src/grammar/items/consts.rs @@ -0,0 +1,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); + types::ascription(p); + if p.eat(EQ) { + expressions::expr(p); + } + p.expect(SEMI); +} -- cgit v1.2.3