Skip to main content

oak_valkyrie/language/
mod.rs

1use crate::{ast::ValkyrieRoot, lexer::ValkyrieTokenType, parser::ValkyrieElementType};
2use oak_core::{Language, LanguageCategory};
3use oak_dejavu::language::{DejavuLanguage, SyntaxMode};
4
5/// Valkyrie language configuration and metadata.
6#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub struct ValkyrieLanguage {
9    /// The base Dejavu language configuration.
10    pub base: DejavuLanguage,
11}
12
13impl ValkyrieLanguage {
14    /// Creates a new Valkyrie language configuration.
15    pub fn new() -> Self {
16        Self { base: DejavuLanguage::default() }
17    }
18}
19
20impl Default for ValkyrieLanguage {
21    fn default() -> Self {
22        Self::new()
23    }
24}
25
26impl Language for ValkyrieLanguage {
27    const NAME: &'static str = "valkyrie";
28    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
29
30    type TokenType = ValkyrieTokenType;
31    type ElementType = ValkyrieElementType;
32    type TypedRoot = ValkyrieRoot;
33}
34
35impl ValkyrieLanguage {
36    /// Gets the syntax mode.
37    pub fn syntax_mode(&self) -> SyntaxMode {
38        self.base.syntax_mode
39    }
40
41    /// Gets the template configuration.
42    pub fn template(&self) -> &oak_dejavu::language::TemplateConfig {
43        &self.base.template
44    }
45}