Skip to main content

oak_nginx/language/
mod.rs

1use oak_core::{Language, LanguageCategory};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub struct NginxLanguage {
6    /// 是否允许扩展指令
7    pub allow_extensions: bool,
8    /// 是否严格模式
9    pub strict_mode: bool,
10}
11
12impl Default for NginxLanguage {
13    fn default() -> Self {
14        Self { allow_extensions: false, strict_mode: false }
15    }
16}
17
18impl Language for NginxLanguage {
19    const NAME: &'static str = "nginx";
20    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
21
22    type TokenType = crate::kind::NginxSyntaxKind;
23    type ElementType = crate::kind::NginxSyntaxKind;
24    type TypedRoot = crate::ast::NginxRoot;
25}
26
27impl NginxLanguage {
28    pub fn new() -> Self {
29        Self::default()
30    }
31
32    pub fn standard() -> Self {
33        Self { allow_extensions: false, strict_mode: true }
34    }
35
36    pub fn extended() -> Self {
37        Self { allow_extensions: true, strict_mode: false }
38    }
39}