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