From a40b715ce1cae4db1b4c3b4c383ee7517d4202c4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 4 Feb 2018 13:39:24 +0300 Subject: G: unsafe impl & trait --- src/parser/event_parser/grammar/items/mod.rs | 18 ++++++++++++++++++ src/parser/event_parser/grammar/items/traits.rs | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/parser/event_parser/grammar/items/traits.rs (limited to 'src/parser/event_parser') diff --git a/src/parser/event_parser/grammar/items/mod.rs b/src/parser/event_parser/grammar/items/mod.rs index 6d6fabbd7..3612802e1 100644 --- a/src/parser/event_parser/grammar/items/mod.rs +++ b/src/parser/event_parser/grammar/items/mod.rs @@ -3,6 +3,7 @@ use super::*; mod structs; mod use_item; mod consts; +mod traits; pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { attributes::inner_attributes(p); @@ -80,6 +81,22 @@ fn item(p: &mut Parser) { CONST_ITEM } }, + // TODO: auto trait + // test unsafe_trait + // unsafe trait T {} + UNSAFE_KW if la == TRAIT_KW => { + p.bump(); + traits::trait_item(p); + TRAIT_ITEM + } + // TODO: default impl + // test unsafe_impl + // unsafe impl Foo {} + UNSAFE_KW if la == IMPL_KW => { + p.bump(); + traits::impl_item(p); + IMPL_ITEM + } MOD_KW => { mod_item(p); MOD_ITEM @@ -131,6 +148,7 @@ fn extern_block(p: &mut Parser) { p.bump(); p.expect(R_CURLY); } + fn mod_item(p: &mut Parser) { assert!(p.at(MOD_KW)); p.bump(); diff --git a/src/parser/event_parser/grammar/items/traits.rs b/src/parser/event_parser/grammar/items/traits.rs new file mode 100644 index 000000000..3bef9639f --- /dev/null +++ b/src/parser/event_parser/grammar/items/traits.rs @@ -0,0 +1,17 @@ +use super::*; + +pub(super) fn trait_item(p: &mut Parser) { + assert!(p.at(TRAIT_KW)); + p.bump(); + p.expect(IDENT); + p.expect(L_CURLY); + p.expect(R_CURLY); +} + +pub(super) fn impl_item(p: &mut Parser) { + assert!(p.at(IMPL_KW)); + p.bump(); + p.expect(IDENT); + p.expect(L_CURLY); + p.expect(R_CURLY); +} -- cgit v1.2.3