move exit: fn from base to stdio

This commit is contained in:
Mark 2024-10-12 01:00:23 +02:00
parent d83f6f942f
commit 4e73ec0201
4 changed files with 19 additions and 8 deletions

View File

@ -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 }

View File

@ -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"

View File

@ -92,9 +92,6 @@ impl Config {
std::thread::sleep(sleep_dur);
Ok(())
}))
.add_var("exit", func_end(|code: IntR<INT_MIN, INT_MAX>, _| {
std::process::exit(code.0.try_into().unwrap_or(255));
}))
.add_var("panic", func_err(|message: &str, _| {
CheckError::from(message)
}))

View File

@ -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 `<unreachable>`, 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<INT_MIN, INT_MAX>, _| {
std::process::exit(code.0.try_into().unwrap_or(255));
}),
)
.add_var(
"read_line",
func(|_: (), _| {