2023-07-28 15:20:02 +02:00
|
|
|
/// data and types in mers
|
2023-07-28 00:33:15 +02:00
|
|
|
pub mod data;
|
2023-11-16 14:50:09 +01:00
|
|
|
/// struct to represent errors the user may face
|
|
|
|
pub mod errors;
|
2023-07-28 15:20:02 +02:00
|
|
|
/// shared code handling scopes to guarantee that compiler and runtime scopes match
|
2023-07-28 00:33:15 +02:00
|
|
|
pub mod info;
|
2023-07-28 15:20:02 +02:00
|
|
|
/// parser implementation.
|
|
|
|
#[cfg(feature = "parse")]
|
2023-07-28 00:33:15 +02:00
|
|
|
pub mod parsing;
|
|
|
|
pub mod program;
|
|
|
|
|
2023-07-28 15:20:02 +02:00
|
|
|
#[cfg(feature = "parse")]
|
2023-07-28 00:33:15 +02:00
|
|
|
pub mod prelude_compile {
|
2024-03-22 15:38:09 +01:00
|
|
|
pub use crate::parsing::check;
|
|
|
|
pub use crate::parsing::compile;
|
2023-07-28 00:33:15 +02:00
|
|
|
pub use crate::parsing::parse;
|
|
|
|
pub use crate::parsing::Source;
|
|
|
|
pub use crate::program::configs::Config;
|
2024-03-22 15:38:09 +01:00
|
|
|
pub use crate::program::parsed::CompInfo;
|
2023-07-28 00:33:15 +02:00
|
|
|
}
|
2023-07-28 15:20:02 +02:00
|
|
|
|
|
|
|
/// can be used to extend the mers config.
|
|
|
|
/// with this, you can add values (usually functions),
|
|
|
|
/// or add your own types to the language:
|
|
|
|
///
|
2023-11-29 16:26:51 +01:00
|
|
|
/// use mers_lib::prelude_extend_config::Config;
|
2023-07-28 15:20:02 +02:00
|
|
|
/// fn add_thing(cfg: Config) -> Config {
|
2023-11-29 16:26:51 +01:00
|
|
|
/// // use the methods on Config to add things (see the Config source code for examples)
|
|
|
|
/// cfg.add_var("my_var".to_owned(), todo!())
|
2023-07-28 15:20:02 +02:00
|
|
|
/// }
|
|
|
|
///
|
|
|
|
/// then use the Config when compiling and running your code, and your customizations will be available.
|
|
|
|
pub mod prelude_extend_config {
|
|
|
|
pub use crate::program::configs::Config;
|
|
|
|
}
|
2023-11-29 16:26:51 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_examples() {
|
|
|
|
for example in std::fs::read_dir("../examples").unwrap() {
|
|
|
|
let path = example.unwrap().path();
|
|
|
|
eprintln!("Checking file {path:?}.");
|
|
|
|
let src = prelude_compile::Source::new_from_file(path).unwrap();
|
|
|
|
let (mut i1, _, mut i3) = prelude_compile::Config::new().bundle_std().infos();
|
|
|
|
prelude_compile::parse(&mut src.clone(), &std::sync::Arc::new(src))
|
|
|
|
.unwrap()
|
|
|
|
.compile(&mut i1, prelude_compile::CompInfo::default())
|
|
|
|
.unwrap()
|
|
|
|
.check(&mut i3, None)
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
}
|