diff --git a/mers/Cargo.toml b/mers/Cargo.toml index 7bfc3c4..3c30102 100644 --- a/mers/Cargo.toml +++ b/mers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mers" -version = "0.9.9" +version = "0.9.10" edition = "2021" license = "MIT OR Apache-2.0" description = "dynamically typed but type-checked programming language" @@ -15,7 +15,7 @@ default = ["colored-output"] colored-output = ["mers_lib/ecolor-term", "mers_lib/pretty-print", "dep:colored"] [dependencies] -mers_lib = "0.9.9" +mers_lib = "0.9.10" # mers_lib = { path = "../mers_lib" } clap = { version = "4.3.19", features = ["derive"] } colored = { version = "2.1.0", optional = true } diff --git a/mers_lib/Cargo.toml b/mers_lib/Cargo.toml index c7a21bb..9ea9923 100755 --- a/mers_lib/Cargo.toml +++ b/mers_lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mers_lib" -version = "0.9.9" +version = "0.9.10" edition = "2021" license = "MIT OR Apache-2.0" description = "library to use the mers language in other projects" diff --git a/mers_lib/src/program/configs/with_base.rs b/mers_lib/src/program/configs/with_base.rs index b9eb4a9..67373cd 100755 --- a/mers_lib/src/program/configs/with_base.rs +++ b/mers_lib/src/program/configs/with_base.rs @@ -92,9 +92,6 @@ impl Config { std::thread::sleep(sleep_dur); Ok(()) })) - .add_var("exit", func_end(|code: IntR, _| { - std::process::exit(code.0.try_into().unwrap_or(255)); - })) .add_var("panic", func_err(|message: &str, _| { CheckError::from(message) })) diff --git a/mers_lib/src/program/configs/with_stdio.rs b/mers_lib/src/program/configs/with_stdio.rs index 935f1a4..fb5a762 100755 --- a/mers_lib/src/program/configs/with_stdio.rs +++ b/mers_lib/src/program/configs/with_stdio.rs @@ -4,12 +4,19 @@ use std::{ }; use crate::{ - data::{self, Data, MersDataWInfo, Type}, + data::{ + self, + int::{INT_MAX, INT_MIN}, + Data, MersDataWInfo, Type, + }, program::{self, run::CheckInfo}, }; use super::{ - gen::{function::func, OneOrNone}, + gen::{ + function::{func, func_end}, + IntR, OneOrNone, + }, Config, }; @@ -20,6 +27,7 @@ impl Config { /// `eprint: fn` prints to stderr /// `debug: fn` debug-prints any value /// `read_line: fn` reads a line from stdin and returns it + /// `exit: fn` exits the program with the given exit code. returns ``, just like `panic` pub fn with_stdio(self) -> Self { self // .add_var( @@ -50,6 +58,12 @@ impl Config { // inner_statements: None, // }, // ) + .add_var( + "exit", + func_end(|code: IntR, _| { + std::process::exit(code.0.try_into().unwrap_or(255)); + }), + ) .add_var( "read_line", func(|_: (), _| {