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