allow calling SPL from rust

This commit is contained in:
TudbuT 2023-08-04 23:40:02 +02:00
parent 62fb4d0f91
commit d7b3c0d430
3 changed files with 10 additions and 2 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "spl" name = "spl"
version = "0.1.6" version = "0.1.7"
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"

View file

@ -2,9 +2,14 @@ func main { |
1 rusty-test _str println 1 rusty-test _str println
0 0
} }
func sply-test { mega |
1
}
func rusty-test @rust !{ func rusty-test @rust !{
println!("hii"); println!("hii");
let v = #pop:Mega#; let v = #pop:Mega#;
#push(v + 1)#; #call(sply-test)#
let v2 = #pop:Mega#;
#push(v + v2)#
} }

View file

@ -22,6 +22,9 @@ fn parse_hash_expr(s: String, name: &str) -> String {
if let Some(s) = readf1("push({})", &s) { if let Some(s) = readf1("push({})", &s) {
return format!("stack.push(({s}).spl());"); return format!("stack.push(({s}).spl());");
} }
if let Some(s) = readf1("call({})", &s) {
return format!("stack.call(&stack.get_func({s:?}.to_owned())?)?;");
}
panic!("invalid #-expr - this error will be handled in the future") panic!("invalid #-expr - this error will be handled in the future")
} }