Node-ify lifetimes

This commit is contained in:
Lukas Wirth 2020-12-15 19:23:51 +01:00
parent d34611633b
commit dd496223f5
63 changed files with 420 additions and 274 deletions

View file

@ -295,7 +295,7 @@ impl<'a> TtIter<'a> {
impl<'a> TreeSink for OffsetTokenSink<'a> {
fn token(&mut self, kind: SyntaxKind, mut n_tokens: u8) {
if kind == SyntaxKind::LIFETIME {
if kind == SyntaxKind::LIFETIME_IDENT {
n_tokens = 2;
}
for _ in 0..n_tokens {

View file

@ -84,7 +84,11 @@ impl<'a> SubtreeTokenSource<'a> {
}
if let Some((curr, text)) = is_lifetime(cursor) {
cached.push(Some(TtToken { kind: LIFETIME, is_joint_to_next: false, text }));
cached.push(Some(TtToken {
kind: LIFETIME_IDENT,
is_joint_to_next: false,
text,
}));
self.cached_cursor.set(curr);
continue;
}
@ -172,7 +176,7 @@ fn convert_ident(ident: &tt::Ident) -> TtToken {
let kind = match ident.text.as_ref() {
"true" => T![true],
"false" => T![false],
i if i.starts_with('\'') => LIFETIME,
i if i.starts_with('\'') => LIFETIME_IDENT,
_ => SyntaxKind::from_keyword(ident.text.as_str()).unwrap_or(IDENT),
};

View file

@ -380,7 +380,7 @@ trait TokenConvertor {
IDENT => make_leaf!(Ident),
k if k.is_keyword() => make_leaf!(Ident),
k if k.is_literal() => make_leaf!(Literal),
LIFETIME => {
LIFETIME_IDENT => {
let char_unit = TextSize::of('\'');
let r = TextRange::at(range.start(), char_unit);
let apostrophe = tt::Leaf::from(tt::Punct {
@ -620,7 +620,7 @@ impl<'a> TreeSink for TtTreeSink<'a> {
self.cursor = self.cursor.bump_subtree();
return;
}
if kind == LIFETIME {
if kind == LIFETIME_IDENT {
n_tokens = 2;
}