Module api

Module api 

Source
Expand description

§MON Core (mon-core)

Crates.io Docs.rs License

mon-core is the reference Rust implementation of the MON (Mycel Object Notation) language — a human-focused configuration and data format designed to be readable, safe, and predictable.

This crate provides the parser, analyzer, validator, and core data model used by MON-based tooling, servers, CLIs, and compilers.

for more information please look at out website: www.mycel-lang.org


§Table of Contents


§Overview

MON aims to replace overly rigid formats (JSON) and overly permissive ones (YAML) with a syntax that stays readable without giving up safety or predictability.

mon-core implements:

  • A forgiving parser with clear, context-rich error messages
  • A semantic analyzer with anchor/alias resolution
  • Type checking via #struct, #enum, and validated bindings
  • An internal IR suitable for compilers and higher-level tooling

If you want to embed MON into your Rust application or build tooling around the language, this is the crate.

§For more information about mon docs are here :D

§Features

  • Clean syntax: unquoted keys, comments, trailing commas
  • Human-friendly booleans: on / off as well as true / false
  • Anchors & aliases: safe reuse with explicit copy semantics (&name, *name)
  • Deep merges: ...*anchor for structured overrides
  • Types built in: #struct, #enum, and :: for validation
  • Modular imports: import { A, B } from "./file.mon"
  • Detailed errors: location-aware, colorized, actionable

§Example

import { ServerSettings } from "./schemas.mon"

{
    &base: {
        host: "localhost",
        port: 8080,
    },

    User: #struct {
        id(Number),
        name(String),
        roles([String...]),
    },

    admin :: User = {
        id: 1,
        name: "Alice",
        roles: ["admin", "editor"],
    },

    dev: {
        ...*base,
        port: 9001,
        debug: on,
    },
}

§Rust Quick Start

Add to Cargo.toml:

[dependencies]
mon-core = "0.1"

Parse and analyze:

use mon_core::analyze;

fn main() {
    let text = r#"
        settings: {
            name: "Example",
            enabled: on,
        }
    "#;

    match analyze(text, "config.mon") {
        Ok(result) => {
            println!("JSON:\n{}", result.to_json().unwrap());
        }
        Err(err) => {
            eprintln!("MON error:\n{err}");
        }
    }
}

§Error Handling

MON is designed to fail loudly and helpfully.

Example error (format depends on your terminal capabilities):

error[E0012]: expected Number, got String
  --> config.mon:7:12
   |
 6 |   age: "twenty",
   |             ^^^ expected a Number here

Errors include:

  • the source span
  • the inferred and expected types
  • suggestions when applicable

§Development

Build:

cargo build

Test:

cargo test --all-features

Checks:

cargo check

The project follows standard Rust layout. Documentation lives in docs/. Any language or spec changes must be reflected there.


§Roadmap

  • Improved parser recovery modes
  • Type system stabilization
  • Performance pass on alias/anchor resolution
  • Better import graph validation
  • Tooling support (formatter, LSP)

§License

Licensed under the MIT license. See LICENSE for details.


for more information please look at out website: www.mycel-lang.org

Made with ❤️ Provides the public API for interacting with the MON core library, including parsing, analysis, and serialization functions.

Structs§

AnalysisResult
The result of a successful analysis of a MON document. This struct contains the fully resolved document and provides methods for serialization and further inspection, making it suitable for both direct consumption and for powering an LSP.

Functions§

analyze
Analyzes a MON source string, parsing, resolving, and validating it.