unbreak starting from embedded files
This commit is contained in:
parent
1290d0a0c3
commit
7b3e0129f8
5 changed files with 16 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "spl"
|
name = "spl"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Stack Pogramming Language: A simple, concise scripting language."
|
description = "Stack Pogramming Language: A simple, concise scripting language."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -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().
|
/// Include the standard library in a runtime-stack-pair, where the runtime has been .set().
|
||||||
pub fn add_std(stack: &mut Stack) -> OError {
|
pub fn add_std(stack: &mut Stack) -> OError {
|
||||||
let f = find_in_splpath("std.spl");
|
let f = find_in_splpath("std.spl");
|
||||||
let words = f
|
let words = match f {
|
||||||
.map_err(|x| stack.error(ErrorKind::LexError(format!("{x}"))))
|
Ok(f) => lex(f.ends_with(".isbpl"), fs::read_to_string(f).unwrap()),
|
||||||
.and_then(|f| {
|
Err(content) => lex(false, content),
|
||||||
lex(f.ends_with(".isbpl"), fs::read_to_string(f).unwrap())
|
}
|
||||||
.map_err(|x| stack.error(ErrorKind::LexError(format!("{x:?}"))))
|
.map_err(|x| stack.error(ErrorKind::LexError(format!("{x:?}"))))?;
|
||||||
})?;
|
|
||||||
words.exec(stack)
|
words.exec(stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
use spl::{
|
use spl::{lex, oxidizer::RustAppBuilder, start_file_in_runtime, Runtime, SetRuntime};
|
||||||
find_in_splpath, lex, oxidizer::RustAppBuilder, start_file_in_runtime, Runtime, SetRuntime,
|
|
||||||
};
|
|
||||||
|
|
||||||
use std::{env::args, fs};
|
use std::{env::args, fs};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Runtime::new().set();
|
Runtime::new().set();
|
||||||
let mut args = args().skip(1);
|
let mut args = args().skip(1);
|
||||||
let arg = &args
|
let arg = &args.next().unwrap_or("#repl.spl".to_owned());
|
||||||
.next()
|
|
||||||
.unwrap_or_else(|| find_in_splpath("repl.spl").expect("no file to be run"));
|
|
||||||
if arg == "--build" || arg == "--run" || arg == "--buildrun" {
|
if arg == "--build" || arg == "--run" || arg == "--buildrun" {
|
||||||
let file = args.next().unwrap();
|
let file = args.next().unwrap();
|
||||||
let data = fs::read_to_string(file.clone()).expect("unable to read specified file");
|
let data = fs::read_to_string(file.clone()).expect("unable to read specified file");
|
||||||
|
|
|
@ -171,13 +171,17 @@ impl RustAppBuilder {
|
||||||
if let Err(x) = start_file_in_runtime(
|
if let Err(x) = start_file_in_runtime(
|
||||||
&args()
|
&args()
|
||||||
.nth(1)
|
.nth(1)
|
||||||
.unwrap_or_else(|| find_in_splpath("default_file").expect("no file to be run")),
|
.unwrap_or("default_file".to_owned()),
|
||||||
) {
|
) {
|
||||||
println!("{x:?}");
|
println!("{x:?}");
|
||||||
}
|
}
|
||||||
Runtime::reset();
|
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")
|
Command::new("cargo")
|
||||||
.arg("build")
|
.arg("build")
|
||||||
|
|
3
std.spl
3
std.spl
|
@ -513,7 +513,8 @@ func _ { |
|
||||||
|
|
||||||
func call-main-on-file { | with file ;
|
func call-main-on-file { | with file ;
|
||||||
catch {
|
catch {
|
||||||
"@" file concat import
|
"@" (0 (file _array):get 0 ("#" _array):get eq) if { pop "" } file concat
|
||||||
|
import
|
||||||
update-types
|
update-types
|
||||||
argv main exit
|
argv main exit
|
||||||
} { with err ;
|
} { with err ;
|
||||||
|
|
Loading…
Add table
Reference in a new issue