Skip to main content

oak_delphi/language/
mod.rs

1#![doc = include_str!("readme.md")]
2use crate::ast::DelphiRoot;
3use oak_core::{Language, LanguageCategory};
4#[cfg(feature = "serde")]
5use serde::{Deserialize, Serialize};
6
7/// Language definition for Delphi programming language
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10pub struct DelphiLanguage {
11    /// Whether to enable strict syntax checking
12    pub strict_syntax: bool,
13    /// Whether to support Unicode strings
14    pub unicode_strings: bool,
15}
16
17impl DelphiLanguage {
18    /// Creates a new `DelphiLanguage` configuration.
19    pub fn new() -> Self {
20        Self::default()
21    }
22}
23
24impl Default for DelphiLanguage {
25    fn default() -> Self {
26        Self { strict_syntax: false, unicode_strings: true }
27    }
28}
29
30impl Language for DelphiLanguage {
31    const NAME: &'static str = "delphi";
32    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
33
34    type TokenType = crate::lexer::token_type::DelphiTokenType;
35    type ElementType = crate::parser::element_type::DelphiElementType;
36    type TypedRoot = DelphiRoot;
37}