From 06433bc95f9ca6d26ced8dc35cb2ecc5da3082dc Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 29 May 2024 15:14:01 +0200 Subject: [PATCH] Reorder syntax kinds (#4287) --- crates/typst-syntax/src/kind.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/crates/typst-syntax/src/kind.rs b/crates/typst-syntax/src/kind.rs index 96d4df44c..4c3d178f2 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", } } }