From dee7046f7eefbaef1d8ab97517b14139fbf696ce Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 28 Jan 2018 14:58:01 +0300 Subject: Don't return SyntaxKind from bump --- src/parser/event_parser/grammar/items.rs | 4 +--- src/parser/event_parser/grammar/mod.rs | 12 ++++++++---- src/parser/event_parser/grammar/paths.rs | 8 ++------ src/parser/event_parser/parser.rs | 5 ++--- 4 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src/parser/event_parser') diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index 7fed5e83b..309e4f4de 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs @@ -174,9 +174,7 @@ fn use_item(p: &mut Parser) { let la = p.nth(1); let m = p.start(); match (p.current(), la) { - (STAR, _) => { - p.bump(); - } + (STAR, _) => p.bump(), (COLONCOLON, STAR) => { p.bump(); p.bump(); diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs index 931193b5f..92125acd1 100644 --- a/src/parser/event_parser/grammar/mod.rs +++ b/src/parser/event_parser/grammar/mod.rs @@ -21,11 +21,15 @@ fn visibility(p: &mut Parser) { p.bump(); if p.at(L_PAREN) { match p.nth(1) { - CRATE_KW | SELF_KW | SUPER_KW | IN_KW => { + CRATE_KW | SELF_KW | SUPER_KW => { p.bump(); - if p.bump() == IN_KW { - paths::use_path(p); - } + p.bump(); + p.expect(R_PAREN); + } + IN_KW => { + p.bump(); + p.bump(); + paths::use_path(p); p.expect(R_PAREN); } _ => (), diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs index 6c8a89f6c..a254ab05e 100644 --- a/src/parser/event_parser/grammar/paths.rs +++ b/src/parser/event_parser/grammar/paths.rs @@ -30,12 +30,8 @@ fn path_segment(p: &mut Parser, first: bool) { p.eat(COLONCOLON); } match p.current() { - IDENT | SELF_KW | SUPER_KW => { - p.bump(); - } - _ => { - p.error().message("expected identifier").emit(); - } + IDENT | SELF_KW | SUPER_KW => p.bump(), + _ => p.error().message("expected identifier").emit(), }; segment.complete(p, PATH_SEGMENT); } diff --git a/src/parser/event_parser/parser.rs b/src/parser/event_parser/parser.rs index a15d0b633..6cf6ac9b9 100644 --- a/src/parser/event_parser/parser.rs +++ b/src/parser/event_parser/parser.rs @@ -151,17 +151,16 @@ impl<'t> Parser<'t> { ErrorBuilder::new(self) } - pub(crate) fn bump(&mut self) -> SyntaxKind { + pub(crate) fn bump(&mut self) { let kind = self.current(); if kind == EOF { - return EOF; + return; } self.pos += 1; self.event(Event::Token { kind, n_raw_tokens: 1, }); - kind } pub(crate) fn nth(&self, n: usize) -> SyntaxKind { -- cgit v1.2.3