oak_tailwind/language/
mod.rs1#![doc = include_str!("readme.md")]
2use crate::{ast::TailwindRoot, lexer::TailwindLexer, parser::TailwindParser};
3use oak_core::{Language, LanguageCategory};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub enum TailwindMode {
9 #[default]
11 Template,
12 Expression,
14}
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
18#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19pub struct TailwindLanguage {
20 pub allow_raw_blocks: bool,
22 pub allow_custom_tags: bool,
24 pub mode: TailwindMode,
26}
27
28impl Language for TailwindLanguage {
29 const NAME: &'static str = "tailwind";
30 const CATEGORY: LanguageCategory = LanguageCategory::Markup;
31
32 type TokenType = crate::lexer::token_type::TailwindTokenType;
33 type ElementType = crate::parser::element_type::TailwindElementType;
34 type TypedRoot = TailwindRoot;
35}
36
37impl TailwindLanguage {
38 pub fn new() -> Self {
40 Self::standard()
41 }
42
43 pub fn standard() -> Self {
45 Self { allow_raw_blocks: true, allow_custom_tags: false, mode: TailwindMode::Template }
46 }
47
48 pub fn lexer(&self) -> TailwindLexer<'_> {
50 TailwindLexer::new(self)
51 }
52
53 pub fn parser(&self) -> TailwindParser<'_> {
55 TailwindParser::new(self)
56 }
57}