unbreak starting from embedded files

This commit is contained in:
Daniella 2024-09-06 21:29:40 +02:00
parent 1290d0a0c3
commit 7b3e0129f8
5 changed files with 16 additions and 16 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "spl"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
description = "Stack Pogramming Language: A simple, concise scripting language."
license = "MIT"

View file

@ -76,12 +76,11 @@ pub fn start_file_in_runtime(path: &str) -> Result<Stack, Error> {
/// Include the standard library in a runtime-stack-pair, where the runtime has been .set().
pub fn add_std(stack: &mut Stack) -> OError {
let f = find_in_splpath("std.spl");
let words = f
.map_err(|x| stack.error(ErrorKind::LexError(format!("{x}"))))
.and_then(|f| {
lex(f.ends_with(".isbpl"), fs::read_to_string(f).unwrap())
.map_err(|x| stack.error(ErrorKind::LexError(format!("{x:?}"))))
})?;
let words = match f {
Ok(f) => lex(f.ends_with(".isbpl"), fs::read_to_string(f).unwrap()),
Err(content) => lex(false, content),
}
.map_err(|x| stack.error(ErrorKind::LexError(format!("{x:?}"))))?;
words.exec(stack)
}

View file

@ -1,15 +1,11 @@
use spl::{
find_in_splpath, lex, oxidizer::RustAppBuilder, start_file_in_runtime, Runtime, SetRuntime,
};
use spl::{lex, oxidizer::RustAppBuilder, start_file_in_runtime, Runtime, SetRuntime};
use std::{env::args, fs};
fn main() {
Runtime::new().set();
let mut args = args().skip(1);
let arg = &args
.next()
.unwrap_or_else(|| find_in_splpath("repl.spl").expect("no file to be run"));
let arg = &args.next().unwrap_or("#repl.spl".to_owned());
if arg == "--build" || arg == "--run" || arg == "--buildrun" {
let file = args.next().unwrap();
let data = fs::read_to_string(file.clone()).expect("unable to read specified file");

View file

@ -171,13 +171,17 @@ impl RustAppBuilder {
if let Err(x) = start_file_in_runtime(
&args()
.nth(1)
.unwrap_or_else(|| find_in_splpath("default_file").expect("no file to be run")),
.unwrap_or("default_file".to_owned()),
) {
println!("{x:?}");
}
Runtime::reset();
}
}.to_owned().replace("default_file", &self.default_file).replace("runtime_init", &runtime_init) + &code,
}
.to_owned()
.replace("default_file", &self.default_file)
.replace("runtime_init", &runtime_init)
+ &code,
)?;
Command::new("cargo")
.arg("build")

View file

@ -513,7 +513,8 @@ func _ { |
func call-main-on-file { | with file ;
catch {
"@" file concat import
"@" (0 (file _array):get 0 ("#" _array):get eq) if { pop "" } file concat
import
update-types
argv main exit
} { with err ;