summaryrefslogtreecommitdiff
path: root/src/diagnostics/non_alphabetic_attribute_name.rs
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2026-07-12 19:49:14 -0400
committerMica White <botahamec@outlook.com>2026-07-12 19:49:14 -0400
commit8399983fd45bc0f11eac9def280c0833ffb93c04 (patch)
treef84173ca30a3c62db7abb92a0d869ff5d5199c51 /src/diagnostics/non_alphabetic_attribute_name.rs
initial commitHEADmain
Diffstat (limited to 'src/diagnostics/non_alphabetic_attribute_name.rs')
-rw-r--r--src/diagnostics/non_alphabetic_attribute_name.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/diagnostics/non_alphabetic_attribute_name.rs b/src/diagnostics/non_alphabetic_attribute_name.rs
new file mode 100644
index 0000000..1cb31d9
--- /dev/null
+++ b/src/diagnostics/non_alphabetic_attribute_name.rs
@@ -0,0 +1,37 @@
+use miette::Diagnostic;
+use thiserror::Error;
+
+use crate::{
+ diagnostics::TokenDiagnostic,
+ tokenize::{AttributeToken, AttributeTokenType, Span},
+};
+
+#[derive(Error, Debug, Diagnostic)]
+#[error("Attribute names must be alphabetic")]
+#[diagnostic(code(NonAlphabeticAttributeName), severity(Error))]
+pub struct NonAlphabeticAttributeName {
+ #[label(
+ primary,
+ "attribute names must only contain uppercase and lowercase letters"
+ )]
+ attribute_name: Span,
+}
+
+impl TokenDiagnostic for NonAlphabeticAttributeName {
+ fn handle_attribute_token(token: &AttributeToken<'_>) -> Option<Self> {
+ let AttributeTokenType::Identifier { lowercase_name, .. } = token.ty else {
+ return None;
+ };
+
+ if lowercase_name
+ .chars()
+ .all(|char| char.is_ascii_alphabetic())
+ {
+ return None;
+ }
+
+ Some(Self {
+ attribute_name: token.span,
+ })
+ }
+}