Skip to main content

oak_nginx/language/
mod.rs

1#![doc = include_str!("readme.md")]
2use oak_core::{Language, LanguageCategory};
3
4/// Configuration for the Nginx language support.
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub struct NginxLanguage {
8    /// Whether to allow extended directives.
9    pub allow_extensions: bool,
10    /// Whether to enable strict mode.
11    pub strict_mode: bool,
12}
13
14impl Default for NginxLanguage {
15    fn default() -> Self {
16        Self { allow_extensions: false, strict_mode: false }
17    }
18}
19
20impl Language for NginxLanguage {
21    const NAME: &'static str = "nginx";
22    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
23
24    type TokenType = crate::lexer::token_type::NginxTokenType;
25    type ElementType = crate::parser::element_type::NginxElementType;
26    type TypedRoot = crate::ast::NginxRoot;
27}
28
29impl NginxLanguage {
30    /// Creates a new `NginxLanguage` with default settings.
31    pub fn new() -> Self {
32        Self::default()
33    }
34
35    /// Creates a new `NginxLanguage` with standard settings (strict mode enabled).
36    pub fn standard() -> Self {
37        Self { allow_extensions: false, strict_mode: true }
38    }
39
40    /// Creates a new `NginxLanguage` with extended settings (extensions allowed).
41    pub fn extended() -> Self {
42        Self { allow_extensions: true, strict_mode: false }
43    }
44}