Reorder syntax kinds (#4287)

This commit is contained in:
Laurenz 2024-05-29 15:14:01 +02:00 committed by GitHub
parent 2946cde6fa
commit 06433bc95f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,16 @@
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[repr(u8)] #[repr(u8)]
pub enum SyntaxKind { pub enum SyntaxKind {
/// The end of token stream.
End,
/// An invalid sequence of characters.
Error,
/// A line comment: `// ...`.
LineComment,
/// A block comment: `/* ... */`.
BlockComment,
/// The contents of a file or content block. /// The contents of a file or content block.
Markup, Markup,
/// Plain text without markup. /// Plain text without markup.
@ -266,15 +276,6 @@ pub enum SyntaxKind {
Destructuring, Destructuring,
/// A destructuring assignment expression: `(x, y) = (1, 2)`. /// A destructuring assignment expression: `(x, y) = (1, 2)`.
DestructAssignment, DestructAssignment,
/// A line comment: `// ...`.
LineComment,
/// A block comment: `/* ... */`.
BlockComment,
/// An invalid sequence of characters.
Error,
/// The end of token stream.
End,
} }
impl SyntaxKind { impl SyntaxKind {
@ -352,7 +353,7 @@ impl SyntaxKind {
pub fn is_trivia(self) -> bool { pub fn is_trivia(self) -> bool {
matches!( matches!(
self, self,
Self::Space | Self::Parbreak | Self::LineComment | Self::BlockComment Self::LineComment | Self::BlockComment | Self::Space | Self::Parbreak
) )
} }
@ -364,6 +365,10 @@ impl SyntaxKind {
/// A human-readable name for the kind. /// A human-readable name for the kind.
pub fn name(self) -> &'static str { pub fn name(self) -> &'static str {
match self { match self {
Self::End => "end of tokens",
Self::Error => "syntax error",
Self::LineComment => "line comment",
Self::BlockComment => "block comment",
Self::Markup => "markup", Self::Markup => "markup",
Self::Text => "text", Self::Text => "text",
Self::Space => "space", Self::Space => "space",
@ -490,10 +495,6 @@ impl SyntaxKind {
Self::FuncReturn => "`return` expression", Self::FuncReturn => "`return` expression",
Self::Destructuring => "destructuring pattern", Self::Destructuring => "destructuring pattern",
Self::DestructAssignment => "destructuring assignment expression", Self::DestructAssignment => "destructuring assignment expression",
Self::LineComment => "line comment",
Self::BlockComment => "block comment",
Self::Error => "syntax error",
Self::End => "end of tokens",
} }
} }
} }