oak_d/language/
mod.rs

1use crate::ast::DRoot;
2use oak_core::{Language, LanguageCategory};
3use serde::{Deserialize, Serialize};
4
5/// Language definition for D programming language
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct DLanguage {
8    /// Whether to enable D2 features
9    pub d2_features: bool,
10    /// Whether to allow inline assembly
11    pub inline_asm: bool,
12    /// Whether to enable contract programming
13    pub contracts: bool,
14}
15
16impl DLanguage {
17    /// Create a standard D language instance
18    pub fn standard() -> Self {
19        Self { d2_features: true, inline_asm: true, contracts: true }
20    }
21
22    /// Create a minimal D language instance
23    pub fn minimal() -> Self {
24        Self { d2_features: false, inline_asm: false, contracts: false }
25    }
26}
27
28impl Default for DLanguage {
29    fn default() -> Self {
30        Self { d2_features: true, inline_asm: false, contracts: true }
31    }
32}
33
34impl Language for DLanguage {
35    const NAME: &'static str = "d";
36    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
37
38    type TokenType = crate::kind::DSyntaxKind;
39    type ElementType = crate::kind::DSyntaxKind;
40    type TypedRoot = DRoot;
41}