Rename raw_lookahead -> nth
This commit is contained in:
parent
60725def49
commit
2141888782
4 changed files with 8 additions and 8 deletions
|
@ -14,7 +14,7 @@ fn item(p: &mut Parser) {
|
||||||
let item = p.start();
|
let item = p.start();
|
||||||
attributes::outer_attributes(p);
|
attributes::outer_attributes(p);
|
||||||
visibility(p);
|
visibility(p);
|
||||||
let la = p.raw_lookahead(1);
|
let la = p.nth(1);
|
||||||
let item_kind = match p.current() {
|
let item_kind = match p.current() {
|
||||||
EXTERN_KW if la == CRATE_KW => {
|
EXTERN_KW if la == CRATE_KW => {
|
||||||
extern_crate_item(p);
|
extern_crate_item(p);
|
||||||
|
@ -171,7 +171,7 @@ fn use_item(p: &mut Parser) {
|
||||||
p.expect(SEMI);
|
p.expect(SEMI);
|
||||||
|
|
||||||
fn use_tree(p: &mut Parser) {
|
fn use_tree(p: &mut Parser) {
|
||||||
let la = p.raw_lookahead(1);
|
let la = p.nth(1);
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
match (p.current(), la) {
|
match (p.current(), la) {
|
||||||
(STAR, _) => {
|
(STAR, _) => {
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn visibility(p: &mut Parser) {
|
||||||
let vis = p.start();
|
let vis = p.start();
|
||||||
p.bump();
|
p.bump();
|
||||||
if p.at(L_PAREN) {
|
if p.at(L_PAREN) {
|
||||||
match p.raw_lookahead(1) {
|
match p.nth(1) {
|
||||||
CRATE_KW | SELF_KW | SUPER_KW | IN_KW => {
|
CRATE_KW | SELF_KW | SUPER_KW | IN_KW => {
|
||||||
p.bump();
|
p.bump();
|
||||||
if p.bump() == IN_KW {
|
if p.bump() == IN_KW {
|
||||||
|
@ -87,13 +87,13 @@ impl Lookahead for SyntaxKind {
|
||||||
|
|
||||||
impl Lookahead for [SyntaxKind; 2] {
|
impl Lookahead for [SyntaxKind; 2] {
|
||||||
fn is_ahead(self, p: &Parser) -> bool {
|
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] {
|
impl Lookahead for [SyntaxKind; 3] {
|
||||||
fn is_ahead(self, p: &Parser) -> bool {
|
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);
|
path_segment(p, true);
|
||||||
let mut qual = path.complete(p, PATH);
|
let mut qual = path.complete(p, PATH);
|
||||||
loop {
|
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);
|
let path = qual.precede(p);
|
||||||
p.bump();
|
p.bump();
|
||||||
path_segment(p, false);
|
path_segment(p, false);
|
||||||
|
|
|
@ -164,12 +164,12 @@ impl<'t> Parser<'t> {
|
||||||
kind
|
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)
|
self.tokens.get(self.pos + n).map(|t| t.kind).unwrap_or(EOF)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn current(&self) -> SyntaxKind {
|
pub(crate) fn current(&self) -> SyntaxKind {
|
||||||
self.raw_lookahead(0)
|
self.nth(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event(&mut self, event: Event) {
|
fn event(&mut self, event: Event) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue