Skip to main content

oak_jasm/language/
mod.rs

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