Skip to main content

oak_jasm/language/
mod.rs

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