diff options
author | Aleksey Kladov <[email protected]> | 2018-02-03 09:05:25 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-02-03 09:05:57 +0000 |
commit | e5273d33d05196ca215db4b1c4e207328fa5df08 (patch) | |
tree | c7dc8cc7c4d8bfd21e64c5a946a23b2d00ca697e /src/parser/event_parser/grammar/items/consts.rs | |
parent | 5e7504b978c9b1365e0381691ef453e97603defa (diff) |
G: const item
Diffstat (limited to 'src/parser/event_parser/grammar/items/consts.rs')
-rw-r--r-- | src/parser/event_parser/grammar/items/consts.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/parser/event_parser/grammar/items/consts.rs b/src/parser/event_parser/grammar/items/consts.rs new file mode 100644 index 000000000..c9881d681 --- /dev/null +++ b/src/parser/event_parser/grammar/items/consts.rs | |||
@@ -0,0 +1,21 @@ | |||
1 | use super::*; | ||
2 | |||
3 | pub(super) fn static_item(p: &mut Parser) { | ||
4 | const_or_static(p, STATIC_KW) | ||
5 | } | ||
6 | |||
7 | pub(super) fn const_item(p: &mut Parser) { | ||
8 | const_or_static(p, CONST_KW) | ||
9 | } | ||
10 | |||
11 | fn 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 | } | ||