mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Rename raw_lookahead -> nth
This commit is contained in:
parent
60725def49
commit
2141888782
@ -14,7 +14,7 @@ fn item(p: &mut Parser) {
|
||||
let item = p.start();
|
||||
attributes::outer_attributes(p);
|
||||
visibility(p);
|
||||
let la = p.raw_lookahead(1);
|
||||
let la = p.nth(1);
|
||||
let item_kind = match p.current() {
|
||||
EXTERN_KW if la == CRATE_KW => {
|
||||
extern_crate_item(p);
|
||||
@ -171,7 +171,7 @@ fn use_item(p: &mut Parser) {
|
||||
p.expect(SEMI);
|
||||
|
||||
fn use_tree(p: &mut Parser) {
|
||||
let la = p.raw_lookahead(1);
|
||||
let la = p.nth(1);
|
||||
let m = p.start();
|
||||
match (p.current(), la) {
|
||||
(STAR, _) => {
|
||||
|
@ -20,7 +20,7 @@ fn visibility(p: &mut Parser) {
|
||||
let vis = p.start();
|
||||
p.bump();
|
||||
if p.at(L_PAREN) {
|
||||
match p.raw_lookahead(1) {
|
||||
match p.nth(1) {
|
||||
CRATE_KW | SELF_KW | SUPER_KW | IN_KW => {
|
||||
p.bump();
|
||||
if p.bump() == IN_KW {
|
||||
@ -87,13 +87,13 @@ impl Lookahead for SyntaxKind {
|
||||
|
||||
impl Lookahead for [SyntaxKind; 2] {
|
||||
fn is_ahead(self, p: &Parser) -> bool {
|
||||
p.current() == self[0] && p.raw_lookahead(1) == self[1]
|
||||
p.current() == self[0] && p.nth(1) == self[1]
|
||||
}
|
||||
}
|
||||
|
||||
impl Lookahead for [SyntaxKind; 3] {
|
||||
fn is_ahead(self, p: &Parser) -> bool {
|
||||
p.current() == self[0] && p.raw_lookahead(1) == self[1] && p.raw_lookahead(2) == self[2]
|
||||
p.current() == self[0] && p.nth(1) == self[1] && p.nth(2) == self[2]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ pub(crate) fn use_path(p: &mut Parser) {
|
||||
path_segment(p, true);
|
||||
let mut qual = path.complete(p, PATH);
|
||||
loop {
|
||||
if p.at(COLONCOLON) && !items::is_use_tree_start(p.raw_lookahead(1)) {
|
||||
if p.at(COLONCOLON) && !items::is_use_tree_start(p.nth(1)) {
|
||||
let path = qual.precede(p);
|
||||
p.bump();
|
||||
path_segment(p, false);
|
||||
|
@ -164,12 +164,12 @@ impl<'t> Parser<'t> {
|
||||
kind
|
||||
}
|
||||
|
||||
pub(crate) fn raw_lookahead(&self, n: usize) -> SyntaxKind {
|
||||
pub(crate) fn nth(&self, n: usize) -> SyntaxKind {
|
||||
self.tokens.get(self.pos + n).map(|t| t.kind).unwrap_or(EOF)
|
||||
}
|
||||
|
||||
pub(crate) fn current(&self) -> SyntaxKind {
|
||||
self.raw_lookahead(0)
|
||||
self.nth(0)
|
||||
}
|
||||
|
||||
fn event(&mut self, event: Event) {
|
||||
|
Loading…
Reference in New Issue
Block a user