diff --git a/spl/std.spl b/spl/std.spl index abe0e3f..90b8931 100644 --- a/spl/std.spl +++ b/spl/std.spl @@ -716,6 +716,12 @@ func _'match-else-error { | } } +func _'match-else-push { | + if { + pop + } +} + def _'has-been-called 0 =_'has-been-called func _ { | _'has-been-called not if { diff --git a/src/lexer.rs b/src/lexer.rs index c8e0f3e..19b8045 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -260,6 +260,12 @@ fn read_block_dyn( "=" => { if str_words[i + 1] == ">" { i += 1; + let pushing = if str_words[i + 1] == "?" { + i += 1; + true + } else { + false + }; let throwing = if str_words[i + 1] == "!" { i += 1; true @@ -291,6 +297,9 @@ fn read_block_dyn( if throwing { words.push(Word::Call("_'match-else-error".to_owned(), false, 0)); } + if pushing { + words.push(Word::Call("_'match-else-push".to_owned(), false, 0)); + } } else { words.push(Word::Call("=".to_owned(), false, 0)); }