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::FsModuleLoader implementation is provided in this crate for file-system based module definitions.

§Example

The following example demonstrates the FsModuleLoader to resolve a module name to a file and parse it.

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

let mut cache = InMemoryModuleCache::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§

error
Provides the project-wide Error and Result types as well as helper functions.
load
This module contains implementations of the ModuleResolver and ModuleLoader traits for file-system based modules.