mirror of
https://github.com/Dummi26/mers.git
synced 2025-12-14 11:16:17 +01:00
mers_lib to 0.5.0, readme updated
This commit is contained in:
@@ -35,23 +35,14 @@ fn main() -> Result<(), CheckError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// example 00
|
||||
fn parse_compile_check_run(src: String) -> Result<(Type, Data), CheckError> {
|
||||
// prepare the string for parsing
|
||||
let mut source = Source::new_from_string(src);
|
||||
// this is used for error messages
|
||||
let srca = Arc::new(source.clone());
|
||||
// parse the code
|
||||
let parsed = parse(&mut source, &srca)?;
|
||||
// get infos
|
||||
let (mut i1, mut i2, mut i3) = Config::new().bundle_std().infos();
|
||||
// compile
|
||||
let compiled = parsed.compile(&mut i1, CompInfo::default())?;
|
||||
// check (this step is optional, but if it is skipped when it would have returned an error, `run` will likely panic)
|
||||
let output_type = compiled.check(&mut i3, None)?;
|
||||
// run
|
||||
let output_value = compiled.run(&mut i2);
|
||||
// check that the predicted output type was correct
|
||||
assert!(output_value.get().as_type().is_included_in(&output_type));
|
||||
// return the produced value
|
||||
Ok((output_type, output_value))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user