Skip to main content

oak_jasm/language/
mod.rs

1#![doc = include_str!("readme.md")]
2use oak_core::language::{Language, LanguageCategory};
3
4/// JASM language binding and configuration.
5#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7pub struct JasmLanguage {
8    /// Whether to enable extended instructions (e.g., invokedynamic, etc.).
9    pub extended: bool,
10    /// Whether to allow comments.
11    pub comments: bool,
12}
13
14impl JasmLanguage {
15    /// Creates a new JASM language configuration.
16    pub fn new() -> Self {
17        Self::default()
18    }
19
20    /// Creates a standard JASM language configuration.
21    pub fn standard() -> Self {
22        Self { extended: true, comments: true }
23    }
24
25    /// Creates a minimal JASM language configuration.
26    pub fn minimal() -> Self {
27        Self { extended: false, comments: false }
28    }
29}
30
31impl Language for JasmLanguage {
32    const NAME: &'static str = "jasm";
33    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
34
35    type TokenType = crate::lexer::token_type::JasmTokenType;
36    type ElementType = crate::parser::element_type::JasmElementType;
37    type TypedRoot = crate::ast::JasmRoot;
38}