From 8c598d3d8a9d6fe0b8303250c88c252ff98883fd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 8 Aug 2018 22:09:47 +0300 Subject: Support crate vis --- src/grammar/mod.rs | 55 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'src/grammar') diff --git a/src/grammar/mod.rs b/src/grammar/mod.rs index b6da0d013..1e7d04ce9 100644 --- a/src/grammar/mod.rs +++ b/src/grammar/mod.rs @@ -55,34 +55,43 @@ impl BlockLike { } fn visibility(p: &mut Parser) { - if p.at(PUB_KW) { - let vis = p.start(); - p.bump(); - if p.at(L_PAREN) { - match p.nth(1) { - // test crate_visibility - // pub(crate) struct S; - // pub(self) struct S; - // pub(self) struct S; - // pub(self) struct S; - CRATE_KW | SELF_KW | SUPER_KW => { - p.bump(); - p.bump(); - p.expect(R_PAREN); - } - IN_KW => { - p.bump(); - p.bump(); - paths::use_path(p); - p.expect(R_PAREN); + match p.current() { + PUB_KW => { + let m = p.start(); + p.bump(); + if p.at(L_PAREN) { + match p.nth(1) { + // test crate_visibility + // pub(crate) struct S; + // pub(self) struct S; + // pub(self) struct S; + // pub(self) struct S; + CRATE_KW | SELF_KW | SUPER_KW => { + p.bump(); + p.bump(); + p.expect(R_PAREN); + } + IN_KW => { + p.bump(); + p.bump(); + paths::use_path(p); + p.expect(R_PAREN); + } + _ => (), } - _ => (), } + m.complete(p, VISIBILITY); } - vis.complete(p, VISIBILITY); + // test crate_keyword_vis + // crate fn main() { } + CRATE_KW => { + let m = p.start(); + p.bump(); + m.complete(p, VISIBILITY); + } + _ => (), } } - fn alias(p: &mut Parser) -> bool { if p.at(AS_KW) { let alias = p.start(); -- cgit v1.2.3