oak_tailwind/language/
mod.rs1use crate::{ast::TwigRoot, lexer::TwigLexer, parser::TwigParser};
2use oak_core::{Language, LanguageCategory};
3
4#[derive(Debug, Clone, Copy)]
6pub enum TwigMode {
7 Template,
8 Expression,
9 }
11
12#[derive(Debug, Clone)]
14pub struct TwigLanguage {
15 pub allow_raw_blocks: bool,
16 pub allow_custom_tags: bool,
17 pub mode: TwigMode,
18}
19
20impl Language for TwigLanguage {
21 const NAME: &'static str = "twig";
22 const CATEGORY: LanguageCategory = LanguageCategory::Markup;
23
24 type TokenType = crate::kind::TwigSyntaxKind;
25 type ElementType = crate::kind::TwigSyntaxKind;
26 type TypedRoot = TwigRoot;
27}
28
29impl Default for TwigLanguage {
30 fn default() -> Self {
31 Self::standard()
32 }
33}
34
35impl TwigLanguage {
36 pub fn new() -> Self {
37 Self::standard()
38 }
39
40 pub fn standard() -> Self {
41 Self { allow_raw_blocks: true, allow_custom_tags: false, mode: TwigMode::Template }
42 }
43
44 pub fn lexer(&self) -> TwigLexer<'_> {
45 TwigLexer::new(self)
46 }
47
48 pub fn parser(&self) -> TwigParser<'_> {
49 TwigParser::new(self)
50 }
51}