1#![doc = include_str!("readme.md")]
2use crate::ast::DRoot;
3use oak_core::{Language, LanguageCategory};
4#[cfg(feature = "serde")]
5use serde::{Deserialize, Serialize};
6
7#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10pub struct DLanguage {
11 pub d2_features: bool,
13 pub inline_asm: bool,
15 pub contracts: bool,
17}
18
19impl DLanguage {
20 pub fn new() -> Self {
22 Self::default()
23 }
24
25 pub fn standard() -> Self {
27 Self { d2_features: true, inline_asm: true, contracts: true }
28 }
29
30 pub fn minimal() -> Self {
32 Self { d2_features: false, inline_asm: false, contracts: false }
33 }
34}
35
36impl Default for DLanguage {
37 fn default() -> Self {
38 Self { d2_features: true, inline_asm: false, contracts: true }
39 }
40}
41
42impl Language for DLanguage {
43 const NAME: &'static str = "d";
44 const CATEGORY: LanguageCategory = LanguageCategory::Programming;
45
46 type TokenType = crate::lexer::token_type::DTokenType;
47 type ElementType = crate::parser::element_type::DElementType;
48 type TypedRoot = DRoot;
49}