ass_core/tokenizer/state/level.rs
1//! Issue severity levels for tokenizer diagnostics.
2//!
3//! Defines [`IssueLevel`], which categorizes tokenization issues by severity
4//! to enable appropriate error handling and recovery strategies.
5
6/// Token issue severity levels
7///
8/// Categorizes tokenization issues by severity to enable appropriate
9/// error handling and recovery strategies.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
11pub enum IssueLevel {
12 /// Warning that doesn't prevent tokenization
13 ///
14 /// Indicates potential problems that don't break parsing but may
15 /// indicate authoring errors or compatibility issues.
16 Warning,
17
18 /// Error that may affect parsing
19 ///
20 /// Indicates problems that could cause incorrect parsing but allow
21 /// tokenization to continue with error recovery.
22 Error,
23
24 /// Critical error requiring recovery
25 ///
26 /// Indicates severe problems that require special handling to
27 /// continue tokenization safely.
28 Critical,
29}
30
31impl IssueLevel {
32 /// Check if issue level indicates an error condition
33 #[must_use]
34 pub const fn is_error(self) -> bool {
35 matches!(self, Self::Error | Self::Critical)
36 }
37
38 /// Check if issue level should stop tokenization
39 #[must_use]
40 pub const fn should_abort(self) -> bool {
41 matches!(self, Self::Critical)
42 }
43
44 /// Get string representation for display
45 #[must_use]
46 pub const fn as_str(self) -> &'static str {
47 match self {
48 Self::Warning => "warning",
49 Self::Error => "error",
50 Self::Critical => "critical",
51 }
52 }
53}