diff options
author | Aleksey Kladov <[email protected]> | 2018-01-28 11:33:10 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-28 11:33:10 +0000 |
commit | 2141888782a74de4a655fee585c99163a3e75e5c (patch) | |
tree | 044832f0c569f54ca92bdf618c6cc4b3b68940e9 | |
parent | 60725def49834bb7dfd46c1a7b84d86f810e1d03 (diff) |
Rename raw_lookahead -> nth
-rw-r--r-- | src/parser/event_parser/grammar/items.rs | 4 | ||||
-rw-r--r-- | src/parser/event_parser/grammar/mod.rs | 6 | ||||
-rw-r--r-- | src/parser/event_parser/grammar/paths.rs | 2 | ||||
-rw-r--r-- | src/parser/event_parser/parser.rs | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index 812e407d1..7fed5e83b 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs | |||
@@ -14,7 +14,7 @@ fn item(p: &mut Parser) { | |||
14 | let item = p.start(); | 14 | let item = p.start(); |
15 | attributes::outer_attributes(p); | 15 | attributes::outer_attributes(p); |
16 | visibility(p); | 16 | visibility(p); |
17 | let la = p.raw_lookahead(1); | 17 | let la = p.nth(1); |
18 | let item_kind = match p.current() { | 18 | let item_kind = match p.current() { |
19 | EXTERN_KW if la == CRATE_KW => { | 19 | EXTERN_KW if la == CRATE_KW => { |
20 | extern_crate_item(p); | 20 | extern_crate_item(p); |
@@ -171,7 +171,7 @@ fn use_item(p: &mut Parser) { | |||
171 | p.expect(SEMI); | 171 | p.expect(SEMI); |
172 | 172 | ||
173 | fn use_tree(p: &mut Parser) { | 173 | fn use_tree(p: &mut Parser) { |
174 | let la = p.raw_lookahead(1); | 174 | let la = p.nth(1); |
175 | let m = p.start(); | 175 | let m = p.start(); |
176 | match (p.current(), la) { | 176 | match (p.current(), la) { |
177 | (STAR, _) => { | 177 | (STAR, _) => { |
diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs index 79a4c10d3..931193b5f 100644 --- a/src/parser/event_parser/grammar/mod.rs +++ b/src/parser/event_parser/grammar/mod.rs | |||
@@ -20,7 +20,7 @@ fn visibility(p: &mut Parser) { | |||
20 | let vis = p.start(); | 20 | let vis = p.start(); |
21 | p.bump(); | 21 | p.bump(); |
22 | if p.at(L_PAREN) { | 22 | if p.at(L_PAREN) { |
23 | match p.raw_lookahead(1) { | 23 | match p.nth(1) { |
24 | CRATE_KW | SELF_KW | SUPER_KW | IN_KW => { | 24 | CRATE_KW | SELF_KW | SUPER_KW | IN_KW => { |
25 | p.bump(); | 25 | p.bump(); |
26 | if p.bump() == IN_KW { | 26 | if p.bump() == IN_KW { |
@@ -87,13 +87,13 @@ impl Lookahead for SyntaxKind { | |||
87 | 87 | ||
88 | impl Lookahead for [SyntaxKind; 2] { | 88 | impl Lookahead for [SyntaxKind; 2] { |
89 | fn is_ahead(self, p: &Parser) -> bool { | 89 | fn is_ahead(self, p: &Parser) -> bool { |
90 | p.current() == self[0] && p.raw_lookahead(1) == self[1] | 90 | p.current() == self[0] && p.nth(1) == self[1] |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | impl Lookahead for [SyntaxKind; 3] { | 94 | impl Lookahead for [SyntaxKind; 3] { |
95 | fn is_ahead(self, p: &Parser) -> bool { | 95 | fn is_ahead(self, p: &Parser) -> bool { |
96 | p.current() == self[0] && p.raw_lookahead(1) == self[1] && p.raw_lookahead(2) == self[2] | 96 | p.current() == self[0] && p.nth(1) == self[1] && p.nth(2) == self[2] |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs index 4e028073a..6c8a89f6c 100644 --- a/src/parser/event_parser/grammar/paths.rs +++ b/src/parser/event_parser/grammar/paths.rs | |||
@@ -12,7 +12,7 @@ pub(crate) fn use_path(p: &mut Parser) { | |||
12 | path_segment(p, true); | 12 | path_segment(p, true); |
13 | let mut qual = path.complete(p, PATH); | 13 | let mut qual = path.complete(p, PATH); |
14 | loop { | 14 | loop { |
15 | if p.at(COLONCOLON) && !items::is_use_tree_start(p.raw_lookahead(1)) { | 15 | if p.at(COLONCOLON) && !items::is_use_tree_start(p.nth(1)) { |
16 | let path = qual.precede(p); | 16 | let path = qual.precede(p); |
17 | p.bump(); | 17 | p.bump(); |
18 | path_segment(p, false); | 18 | path_segment(p, false); |
diff --git a/src/parser/event_parser/parser.rs b/src/parser/event_parser/parser.rs index 2507af6bf..a15d0b633 100644 --- a/src/parser/event_parser/parser.rs +++ b/src/parser/event_parser/parser.rs | |||
@@ -164,12 +164,12 @@ impl<'t> Parser<'t> { | |||
164 | kind | 164 | kind |
165 | } | 165 | } |
166 | 166 | ||
167 | pub(crate) fn raw_lookahead(&self, n: usize) -> SyntaxKind { | 167 | pub(crate) fn nth(&self, n: usize) -> SyntaxKind { |
168 | self.tokens.get(self.pos + n).map(|t| t.kind).unwrap_or(EOF) | 168 | self.tokens.get(self.pos + n).map(|t| t.kind).unwrap_or(EOF) |
169 | } | 169 | } |
170 | 170 | ||
171 | pub(crate) fn current(&self) -> SyntaxKind { | 171 | pub(crate) fn current(&self) -> SyntaxKind { |
172 | self.raw_lookahead(0) | 172 | self.nth(0) |
173 | } | 173 | } |
174 | 174 | ||
175 | fn event(&mut self, event: Event) { | 175 | fn event(&mut self, event: Event) { |