summaryrefslogtreecommitdiff
path: root/src/syntax/kind.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-22 14:48:08 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-22 14:53:03 +0100
commitb476de87b7cea1405bf3c051ff8e0ac7c473dbae (patch)
tree5d780846c0f3540eaa4c57fd604ee5aa0984b15e /src/syntax/kind.rs
parent2ce727fc958d9b83f7d2f46f73e4f295594b48a6 (diff)
Rename two syntax types
Diffstat (limited to 'src/syntax/kind.rs')
-rw-r--r--src/syntax/kind.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/syntax/kind.rs b/src/syntax/kind.rs
index c973632c..58e2b915 100644
--- a/src/syntax/kind.rs
+++ b/src/syntax/kind.rs
@@ -6,10 +6,9 @@ use crate::util::EcoString;
/// All syntactical building blocks that can be part of a Typst document.
///
-/// Can be emitted as a token by the tokenizer or as part of a syntax node by
-/// the parser.
+/// Can be created by the tokenizer or by the parser.
#[derive(Debug, Clone, PartialEq)]
-pub enum NodeKind {
+pub enum SyntaxKind {
/// A line comment: `// ...`.
LineComment,
/// A block comment: `/* ... */`.
@@ -254,7 +253,7 @@ pub enum NodeKind {
Error(ErrorPos, EcoString),
}
-/// Fields of a [`Raw`](NodeKind::Raw) node.
+/// Fields of the raw syntax kind.
#[derive(Debug, Clone, PartialEq, Hash)]
pub struct RawFields {
/// An optional identifier specifying the language to syntax-highlight in.
@@ -293,7 +292,7 @@ pub enum ErrorPos {
End,
}
-impl NodeKind {
+impl SyntaxKind {
/// Whether this is trivia.
pub fn is_trivia(&self) -> bool {
self.is_space() || matches!(self, Self::LineComment | Self::BlockComment)
@@ -311,18 +310,18 @@ impl NodeKind {
/// Whether this is an error.
pub fn is_error(&self) -> bool {
- matches!(self, NodeKind::Error(_, _))
+ matches!(self, SyntaxKind::Error(_, _))
}
/// Does this node need termination through a semicolon or linebreak?
pub fn is_stmt(&self) -> bool {
matches!(
self,
- NodeKind::LetBinding
- | NodeKind::SetRule
- | NodeKind::ShowRule
- | NodeKind::ModuleImport
- | NodeKind::ModuleInclude
+ SyntaxKind::LetBinding
+ | SyntaxKind::SetRule
+ | SyntaxKind::ShowRule
+ | SyntaxKind::ModuleImport
+ | SyntaxKind::ModuleInclude
)
}
@@ -445,7 +444,7 @@ impl NodeKind {
}
}
-impl Hash for NodeKind {
+impl Hash for SyntaxKind {
fn hash<H: Hasher>(&self, state: &mut H) {
std::mem::discriminant(self).hash(state);
match self {