oak-d 0.0.11

High-performance incremental D language parser for the oak ecosystem with flexible configuration, supporting systems programming and native development.
Documentation
#![doc = include_str!("readme.md")]
use crate::ast::DRoot;
use oak_core::{Language, LanguageCategory};

/// Language definition for D programming language
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DLanguage {
    /// Whether to enable D2 features
    pub d2_features: bool,
    /// Whether to allow inline assembly
    pub inline_asm: bool,
    /// Whether to enable contract programming
    pub contracts: bool,
}

impl DLanguage {
    /// Create a new D language instance
    pub fn new() -> Self {
        Self::default()
    }

    /// Create a standard D language instance
    pub fn standard() -> Self {
        Self { d2_features: true, inline_asm: true, contracts: true }
    }

    /// Create a minimal D language instance
    pub fn minimal() -> Self {
        Self { d2_features: false, inline_asm: false, contracts: false }
    }
}

impl Default for DLanguage {
    fn default() -> Self {
        Self { d2_features: true, inline_asm: false, contracts: true }
    }
}

impl Language for DLanguage {
    const NAME: &'static str = "d";
    const CATEGORY: LanguageCategory = LanguageCategory::Programming;

    type TokenType = crate::lexer::token_type::DTokenType;
    type ElementType = crate::parser::element_type::DElementType;
    type TypedRoot = DRoot;
}