string is not a keyword

This commit is contained in:
Lukas Wirth 2024-07-17 11:11:30 +02:00
parent 7011094685
commit b8cac1bb6b
5 changed files with 13 additions and 5 deletions

View file

@ -19,6 +19,10 @@ impl Edition {
pub fn at_least_2024(self) -> bool { pub fn at_least_2024(self) -> bool {
self >= Edition::Edition2024 self >= Edition::Edition2024
} }
pub fn at_least_2018(self) -> bool {
self >= Edition::Edition2018
}
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -178,6 +178,12 @@ impl<'a> Converter<'a> {
rustc_lexer::TokenKind::Whitespace => WHITESPACE, rustc_lexer::TokenKind::Whitespace => WHITESPACE,
rustc_lexer::TokenKind::Ident if token_text == "_" => UNDERSCORE, rustc_lexer::TokenKind::Ident if token_text == "_" => UNDERSCORE,
rustc_lexer::TokenKind::Ident
if ["async", "await", "dyn", "try"].contains(&token_text)
&& !self.edition.at_least_2018() =>
{
IDENT
}
rustc_lexer::TokenKind::Ident rustc_lexer::TokenKind::Ident
if token_text == "gen" && !self.edition.at_least_2024() => if token_text == "gen" && !self.edition.at_least_2024() =>
{ {

File diff suppressed because one or more lines are too long

View file

@ -193,7 +193,7 @@ Fn =
(body:BlockExpr | ';') (body:BlockExpr | ';')
Abi = Abi =
'extern' 'string'? 'extern' '@string'?
ParamList = ParamList =
'('( '('(

View file

@ -484,6 +484,7 @@ fn generate_syntax_kinds(grammar: KindsSrc) -> String {
[lifetime_ident] => { $crate::SyntaxKind::LIFETIME_IDENT }; [lifetime_ident] => { $crate::SyntaxKind::LIFETIME_IDENT };
[int_number] => { $crate::SyntaxKind::INT_NUMBER }; [int_number] => { $crate::SyntaxKind::INT_NUMBER };
[ident] => { $crate::SyntaxKind::IDENT }; [ident] => { $crate::SyntaxKind::IDENT };
[string] => { $crate::SyntaxKind::STRING };
[shebang] => { $crate::SyntaxKind::SHEBANG }; [shebang] => { $crate::SyntaxKind::SHEBANG };
} }
}; };