From 0000f4f4f2f32c6ff67db6cbc27e3a49c85f4b99 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 2 Feb 2018 23:45:15 +0300 Subject: G: static items --- src/parser/event_parser/grammar/items/mod.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/parser') diff --git a/src/parser/event_parser/grammar/items/mod.rs b/src/parser/event_parser/grammar/items/mod.rs index 35825e7c4..9930de347 100644 --- a/src/parser/event_parser/grammar/items/mod.rs +++ b/src/parser/event_parser/grammar/items/mod.rs @@ -46,6 +46,10 @@ fn item(p: &mut Parser) { } } } + STATIC_KW => { + static_item(p); + STATIC_ITEM + } MOD_KW => { mod_item(p); MOD_ITEM @@ -92,6 +96,24 @@ fn extern_crate_item(p: &mut Parser) { p.expect(IDENT) && alias(p) && p.expect(SEMI); } +fn extern_block(p: &mut Parser) { + assert!(p.at(L_CURLY)); + p.bump(); + p.expect(R_CURLY); +} + +fn static_item(p: &mut Parser) { + assert!(p.at(STATIC_KW)); + p.bump(); + p.eat(MUT_KW); + p.expect(IDENT); + p.expect(COLON); + types::type_ref(p); + p.expect(EQ); + expressions::expr(p); + p.expect(SEMI); +} + fn mod_item(p: &mut Parser) { assert!(p.at(MOD_KW)); p.bump(); @@ -104,12 +126,6 @@ fn mod_item(p: &mut Parser) { } } -fn extern_block(p: &mut Parser) { - assert!(p.at(L_CURLY)); - p.bump(); - p.expect(R_CURLY); -} - fn abi(p: &mut Parser) { assert!(p.at(EXTERN_KW)); let abi = p.start(); -- cgit v1.2.3