WIP: switch to fully decomposed tokens internally

This commit is contained in:
Aleksey Kladov 2019-09-09 14:52:31 +03:00
parent e2ebb467bd
commit 40170885e7
12 changed files with 422 additions and 279 deletions

View file

@ -1,7 +1,7 @@
use super::*;
pub(super) const PATH_FIRST: TokenSet =
token_set![IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLONCOLON, L_ANGLE];
token_set![IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLON, L_ANGLE];
pub(super) fn is_path_start(p: &Parser) -> bool {
is_use_path_start(p) || p.at(T![<])
@ -9,7 +9,8 @@ pub(super) fn is_path_start(p: &Parser) -> bool {
pub(super) fn is_use_path_start(p: &Parser) -> bool {
match p.current() {
IDENT | T![self] | T![super] | T![crate] | T![::] => true,
IDENT | T![self] | T![super] | T![crate] => true,
T![:] if p.at(T![::]) => true,
_ => false,
}
}
@ -38,13 +39,13 @@ fn path(p: &mut Parser, mode: Mode) {
path_segment(p, mode, true);
let mut qual = path.complete(p, PATH);
loop {
let use_tree = match p.nth(1) {
let use_tree = match p.nth(2) {
T![*] | T!['{'] => true,
_ => false,
};
if p.at(T![::]) && !use_tree {
let path = qual.precede(p);
p.bump_any();
p.bump(T![::]);
path_segment(p, mode, false);
let path = path.complete(p, PATH);
qual = path;