Skip to content

Commit 8ab9efe

Browse files
committed
parser: Rewrite parse_path_without_tps so it knows beforehand which is the last ident
Needed to centralize all keyword-as-value parsing in parse_value_ident
1 parent beece25 commit 8ab9efe

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/librustsyntax/parse/parser.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,18 @@ fn parse_path_without_tps(p: parser) -> @ast::path {
511511
let lo = p.span.lo;
512512
let global = eat(p, token::MOD_SEP);
513513
let mut ids = [];
514-
do {
514+
loop {
515+
let is_not_last =
516+
p.look_ahead(2u) != token::LT
517+
&& p.look_ahead(1u) == token::MOD_SEP;
518+
515519
ids += [parse_ident(p)];
516-
} while p.look_ahead(1u) != token::LT && eat(p, token::MOD_SEP);
520+
if is_not_last {
521+
expect(p, token::MOD_SEP);
522+
} else {
523+
break;
524+
}
525+
}
517526
@{span: mk_sp(lo, p.last_span.hi), global: global,
518527
idents: ids, rp: none, types: []}
519528
}

0 commit comments

Comments
 (0)