Skip to main content

oak_cpp/language/
mod.rs

1#![doc = include_str!("readme.md")]
2use crate::{ast::CppRoot, lexer::CppLexer};
3use oak_core::{Language, LanguageCategory};
4#[cfg(feature = "serde")]
5use serde::{Deserialize, Serialize};
6
7/// C++ language implementation for the Oaks framework.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10pub struct CppLanguage {}
11
12impl Language for CppLanguage {
13    const NAME: &'static str = "cpp";
14    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
15
16    type TokenType = crate::lexer::CppTokenType;
17    type ElementType = crate::parser::CppElementType;
18    type TypedRoot = CppRoot;
19}
20
21impl CppLanguage {
22    /// Creates a new `CppLanguage` instance.
23    pub fn new() -> Self {
24        Self {}
25    }
26
27    /// Creates a C++ lexer using this language configuration.
28    pub fn lexer(&self) -> CppLexer<'_> {
29        CppLexer::new(self)
30    }
31}
32
33impl Default for CppLanguage {
34    fn default() -> Self {
35        Self {}
36    }
37}