mirror of
https://github.com/typst/typst
synced 2025-06-28 16:22:53 +08:00
Reorder syntax kinds (#4287)
This commit is contained in:
parent
2946cde6fa
commit
06433bc95f
@ -4,6 +4,16 @@
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
#[repr(u8)]
|
||||
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.
|
||||
Markup,
|
||||
/// Plain text without markup.
|
||||
@ -266,15 +276,6 @@ pub enum SyntaxKind {
|
||||
Destructuring,
|
||||
/// A destructuring assignment expression: `(x, y) = (1, 2)`.
|
||||
DestructAssignment,
|
||||
|
||||
/// A line comment: `// ...`.
|
||||
LineComment,
|
||||
/// A block comment: `/* ... */`.
|
||||
BlockComment,
|
||||
/// An invalid sequence of characters.
|
||||
Error,
|
||||
/// The end of token stream.
|
||||
End,
|
||||
}
|
||||
|
||||
impl SyntaxKind {
|
||||
@ -352,7 +353,7 @@ impl SyntaxKind {
|
||||
pub fn is_trivia(self) -> bool {
|
||||
matches!(
|
||||
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.
|
||||
pub fn name(self) -> &'static str {
|
||||
match self {
|
||||
Self::End => "end of tokens",
|
||||
Self::Error => "syntax error",
|
||||
Self::LineComment => "line comment",
|
||||
Self::BlockComment => "block comment",
|
||||
Self::Markup => "markup",
|
||||
Self::Text => "text",
|
||||
Self::Space => "space",
|
||||
@ -490,10 +495,6 @@ impl SyntaxKind {
|
||||
Self::FuncReturn => "`return` expression",
|
||||
Self::Destructuring => "destructuring pattern",
|
||||
Self::DestructAssignment => "destructuring assignment expression",
|
||||
Self::LineComment => "line comment",
|
||||
Self::BlockComment => "block comment",
|
||||
Self::Error => "syntax error",
|
||||
Self::End => "end of tokens",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user