remove debug prints 2, minor fixes

This commit is contained in:
Daniella / Tove 2024-09-03 12:35:25 +02:00
parent 06a51a258b
commit 3a4105dc5d
6 changed files with 27 additions and 4 deletions

2
Cargo.lock generated
View file

@ -22,7 +22,7 @@ checksum = "b03f7fbd470aa8b3ad163c85cce8bccfc11cc9c44ef12da0a4eddd98bd307352"
[[package]] [[package]]
name = "spl" name = "spl"
version = "0.1.8" version = "0.2.1"
dependencies = [ dependencies = [
"multicall", "multicall",
"once_cell", "once_cell",

View file

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

@ -210,6 +210,7 @@ construct EnumerationIter {
; ;
construct { this | with origin this ; construct { this | with origin this ;
origin this:=origin origin this:=origin
0 this:=idx
this this
} }
next { [mega,any]|null | with this ; next { [mega,any]|null | with this ;

View file

@ -181,7 +181,6 @@ fn read_block(str_words: &[String], isfn: bool) -> Result<(Option<u32>, Words, u
} }
let blk = read_block(&str_words[i + 1..], false)?; let blk = read_block(&str_words[i + 1..], false)?;
i += 2 + blk.2; i += 2 + blk.2;
println!("{} {}", str_words[i], str_words[i+1]);
let ctch = read_block(&str_words[i + 1..], false)?; let ctch = read_block(&str_words[i + 1..], false)?;
i += 1 + ctch.2; i += 1 + ctch.2;
words.push(Word::Key(Keyword::Catch(types, blk.1, ctch.1))) words.push(Word::Key(Keyword::Catch(types, blk.1, ctch.1)))

View file

@ -447,7 +447,7 @@ pub fn to_str(stack: &mut Stack) -> OError {
)) ))
}), }),
_ => stack.err(ErrorKind::InvalidType( _ => stack.err(ErrorKind::InvalidType(
"int".to_owned(), "?".to_owned(),
"__str-element".to_owned(), "__str-element".to_owned(),
)), )),
}) })

23
std.spl
View file

@ -56,6 +56,29 @@ construct _str_ext {
] _str ] _str
} ] } ]
} }
replace { str | with replacee replacement this ;
def bytes replacee:to-bytes =bytes
def iter this:to-bytes:iter =iter
def item 0 =item
[ while { item null eq not } {
def match 0 =match
while { match bytes:len eq not } {
iter:next =item
item null eq if {
3 stop
}
item dup (match bytes:get) eq dup if {
match ++ =match
} not if {
0 =match
}
}
{ | pop pop } match:foreach
match bytes:len eq if {
replacement _array :to-stack
}
} ] _str
}
} include _str_ext in str } include _str_ext in str
construct _mega-ext { construct _mega-ext {