From c3e2dbc1b8e1977c6b7e2a9da37e6d46e1601087 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Fri, 15 Nov 2024 14:34:23 +0100 Subject: [PATCH] matching now less awkward --- src/lexer.rs | 6 +++--- test.spl | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lexer.rs b/src/lexer.rs index 40bc27a..c8e0f3e 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -260,11 +260,11 @@ fn read_block_dyn( "=" => { if str_words[i + 1] == ">" { i += 1; - let throwing = if str_words[i + 1] == "?" { + let throwing = if str_words[i + 1] == "!" { i += 1; - false - } else { true + } else { + false }; if str_words[i + 1] == "[" { i += 1; diff --git a/test.spl b/test.spl index 4226ac0..4f27358 100644 --- a/test.spl +++ b/test.spl @@ -302,10 +302,10 @@ func main { int | with args ; "[a b] => [=mtesta a] (0): " print [ "b" "a" ] [ "a" &=mtesta ] match _str println "-> mtesta = (b) " mtesta _str concat println - "^ok => ^ok (1): " print ^ok =>? ^ok _str println - "^bad => ^ok (0): " print ^bad =>? ^ok _str println - "[^bad a] => [^ok =mtestb] (0): " print [ ^bad "a" ] =>? [ ^ok &=mtestb ] _str println - "[^ok b] => [^ok =mtestb] (1): " print [ ^ok "b" ] =>? [ ^ok &=mtestb ] _str println + "^ok => ^ok (1): " print ^ok => ^ok _str println + "^bad => ^ok (0): " print ^bad => ^ok _str println + "[^bad a] => [^ok =mtestb] (0): " print [ ^bad "a" ] => [ ^ok &=mtestb ] _str println + "[^ok b] => [^ok =mtestb] (1): " print [ ^ok "b" ] => [ ^ok &=mtestb ] _str println "-> mtestb = (b) " mtestb _str concat println @@ -313,17 +313,17 @@ func main { int | with args ; [ ^ok "hello, world" ] =result - result => [ ^ok &=val ] + result =>! [ ^ok &=val ] val println [ ^error "bad" ] =result catch Custom { - result => [ ^ok &println ] + result =>! [ ^ok &println ] } { with e ; e:message "match unsuccessful" eq if { "err value: " print - result => [ ^error &println ] + result =>! [ ^error &println ] } }