Crate sdml_parse

source ·
Expand description

This library provides a parser for the Simple Domain Modeling Language (SDML) and produces an in-memory representation using the crate sdml-core.

The [ModuleLoader] trait from, sdml-core, provides the interface for finding, parsing, and loading modules and the [load::ModuleLoader] implementation is provided in this crate for file-system based module definitions.

§Example

The following example demonstrates the [ModuleLoader] to resolve a module name to a file and parse it.

use sdml_core::model::identifiers::Identifier;
use sdml_core::cache::{ModuleCache, ModuleStore};
use sdml_core::load::ModuleLoader;
use sdml_parse::load::FsModuleLoader;
use std::str::FromStr;

let mut cache = ModuleCache::default().with_stdlib();
let mut loader = FsModuleLoader::default();

let name = Identifier::from_str("example").unwrap();

let module_name = loader.load(&name, None, &mut cache, true);
assert!(module_name.is_ok());

let module = cache.get(&module_name.unwrap()).unwrap();

Modules§

  • Provides the project-wide Error and Result types as well as helper functions.