aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar/items/consts.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-02-04 10:53:47 +0000
committerAleksey Kladov <[email protected]>2018-02-04 10:53:47 +0000
commitd94124e3b4a4380ad23c1a317fd3943664b7182a (patch)
treec11b5a548bac9dae6e77bead8f24db98dbea9dc8 /src/parser/grammar/items/consts.rs
parenta40b715ce1cae4db1b4c3b4c383ee7517d4202c4 (diff)
Somewhat more san directory structure
Diffstat (limited to 'src/parser/grammar/items/consts.rs')
-rw-r--r--src/parser/grammar/items/consts.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/parser/grammar/items/consts.rs b/src/parser/grammar/items/consts.rs
new file mode 100644
index 000000000..c9881d681
--- /dev/null
+++ b/src/parser/grammar/items/consts.rs
@@ -0,0 +1,21 @@
1use super::*;
2
3pub(super) fn static_item(p: &mut Parser) {
4 const_or_static(p, STATIC_KW)
5}
6
7pub(super) fn const_item(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 p.expect(IDENT);
16 p.expect(COLON);
17 types::type_ref(p);
18 p.expect(EQ);
19 expressions::expr(p);
20 p.expect(SEMI);
21}