oak_core/kinds/
mod.rs

1/// Syntax kind definitions for tokens and nodes in the parsing system.
2///
3/// This module provides the [`SyntaxKind`] trait which serves as the foundation
4/// for defining different types of tokens and nodes in the parsing system.
5/// It enables categorization of kind elements and provides methods for
6/// identifying their roles in the language grammar.
7pub trait SyntaxKind: Copy + Eq + Send {
8    /// Returns true if this kind represents trivia (whitespace, comments, etc.).
9    ///
10    /// Trivia tokens are typically ignored during parsing but preserved for
11    /// formatting and tooling purposes.
12    fn is_trivia(&self) -> bool;
13
14    /// Returns true if this kind represents a comment.
15    ///
16    /// Comment tokens are a type of trivia that contain developer annotations
17    /// in the source code.
18    ///
19    /// # Examples
20    ///
21    /// ```rust,ignore
22    /// // Check if the current kind kind is a comment
23    /// if kind.is_comment() {
24    ///     // Handle comment-related logic
25    ///     handle_comment();
26    /// }
27    /// ```
28    fn is_comment(&self) -> bool;
29
30    /// Returns true if this kind represents whitespace.
31    fn is_whitespace(&self) -> bool;
32
33    /// Returns true if this kind represents a token type.
34    ///
35    /// Token types are the basic lexical units that form the building blocks
36    /// of the language grammar.
37    ///
38    /// # Examples
39    ///
40    /// ```rust,ignore
41    /// // Check if the current kind kind is a token type
42    /// if kind.is_token_type() {
43    ///     // Handle token-related logic
44    ///     process_token();
45    /// }
46    /// ```
47    fn is_token_type(&self) -> bool;
48
49    /// Returns true if this kind represents an element type.
50    ///
51    /// Element types represent higher-level syntactic structures composed
52    /// of multiple tokens.
53    ///
54    /// # Examples
55    ///
56    /// ```rust,ignore
57    /// // Check if the current kind kind is an element type
58    /// if kind.is_element_type() {
59    ///     // Handle element-related logic
60    ///     handle_element();
61    /// }
62    /// ```
63    fn is_element_type(&self) -> bool;
64}