oak_csv/kind/
mod.rs

1#![allow(non_camel_case_types)]
2
3use oak_core::SyntaxKind;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6#[repr(u16)]
7pub enum CsvSyntaxKind {
8    // Trivia
9    Whitespace = 0,
10    Newline,
11
12    // CSV-specific tokens
13    Field,         // A field value (quoted or unquoted)
14    QuotedField,   // A quoted field value
15    UnquotedField, // An unquoted field value
16    Comma,         // Field separator ,
17    Quote,         // Quote character "
18    EscapedQuote,  // Escaped quote ""
19
20    // Special cases
21    EmptyField, // Empty field (between commas or at start/end)
22
23    // Compound nodes
24    Record,     // A complete CSV record (row)
25    SourceFile, // The entire CSV file
26    Error,      // Error kind
27    Eof,        // End of file
28}
29
30impl SyntaxKind for CsvSyntaxKind {
31    fn is_trivia(&self) -> bool {
32        matches!(self, Self::Whitespace | Self::Newline)
33    }
34
35    fn is_comment(&self) -> bool {
36        false // CSV doesn't have comments
37    }
38
39    fn is_whitespace(&self) -> bool {
40        matches!(self, Self::Whitespace)
41    }
42
43    fn is_token_type(&self) -> bool {
44        matches!(
45            self,
46            Self::Field
47                | Self::QuotedField
48                | Self::UnquotedField
49                | Self::Comma
50                | Self::Quote
51                | Self::EscapedQuote
52                | Self::EmptyField
53                | Self::Whitespace
54                | Self::Newline
55                | Self::Eof
56        )
57    }
58
59    fn is_element_type(&self) -> bool {
60        matches!(self, Self::Record | Self::SourceFile)
61    }
62}