summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-05-29 15:14:01 +0200
committerGitHub <noreply@github.com>2024-05-29 13:14:01 +0000
commit06433bc95f9ca6d26ced8dc35cb2ecc5da3082dc (patch)
tree5a5eb963f2f5f6a40d851a12490d56495af49a0a /crates
parent2946cde6fa1b9039fe5de1cded2e0c697575b81d (diff)
Reorder syntax kinds (#4287)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst-syntax/src/kind.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/crates/typst-syntax/src/kind.rs b/crates/typst-syntax/src/kind.rs
index 96d4df44..4c3d178f 100644
--- a/crates/typst-syntax/src/kind.rs
+++ b/crates/typst-syntax/src/kind.rs
@@ -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",
}
}
}