Rename raw_lookahead -> nth

This commit is contained in:
Aleksey Kladov 2018-01-28 14:33:10 +03:00
parent 60725def49
commit 2141888782
4 changed files with 8 additions and 8 deletions

View file

@ -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, _) => {

View file

@ -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]
}
}

View file

@ -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);

View file

@ -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) {