Expand description
Provides the public API for interacting with the MON core library, including parsing, analysis, and serialization functions.
§Public API for MON Core
This module provides the primary high-level interface for the mon-core library. It is the
recommended entry point for most users who want to parse, resolve, and validate MON source code
in a single, streamlined operation.
§Architectural Overview
The api module acts as a facade over the entire compilation pipeline, orchestrating the
lexer, parser, and resolver
to provide a simple and powerful analysis function. Its main purpose is to abstract away the
complexities of the individual stages.
§Use Cases
The central use case is to take a MON source string and get a fully processed, validated, and serializable result.
- Analyzing a MON file: The
analyzefunction is the workhorse of this module. - Serializing the result: Once analysis is complete, the
AnalysisResultcan be easily converted to other formats like JSON or YAML. - Powering Language Tools: For more advanced use cases like Language Server Protocol (LSP)
implementations, the
AnalysisResultprovides methods for “go to definition”, “hover”, and “find references” when thelspfeature is enabled.
§Example: Analyze and Serialize
use mon_core::api::analyze;
let source = r#"{ version: 1.0, features: ["a", "b"] }"#;
// 1. Analyze the source string.
let result = analyze(source, "my_config.mon")?;
// 2. Convert the result to a YAML string.
let yaml_output = result.to_yaml().unwrap();
println!("{}", yaml_output);
assert!(yaml_output.contains("version: 1.0"));Structs§
- Analysis
Result - The result of a successful analysis of a MON document.
Functions§
- analyze
- Analyzes a MON source string, parsing, resolving, and validating it.