matching now less awkward
This commit is contained in:
parent
215b6f2748
commit
c3e2dbc1b8
2 changed files with 10 additions and 10 deletions
|
@ -260,11 +260,11 @@ fn read_block_dyn(
|
||||||
"=" => {
|
"=" => {
|
||||||
if str_words[i + 1] == ">" {
|
if str_words[i + 1] == ">" {
|
||||||
i += 1;
|
i += 1;
|
||||||
let throwing = if str_words[i + 1] == "?" {
|
let throwing = if str_words[i + 1] == "!" {
|
||||||
i += 1;
|
i += 1;
|
||||||
false
|
|
||||||
} else {
|
|
||||||
true
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
};
|
};
|
||||||
if str_words[i + 1] == "[" {
|
if str_words[i + 1] == "[" {
|
||||||
i += 1;
|
i += 1;
|
||||||
|
|
14
test.spl
14
test.spl
|
@ -302,10 +302,10 @@ func main { int | with args ;
|
||||||
"[a b] => [=mtesta a] (0): " print [ "b" "a" ] [ "a" &=mtesta ] match _str println
|
"[a b] => [=mtesta a] (0): " print [ "b" "a" ] [ "a" &=mtesta ] match _str println
|
||||||
"-> mtesta = (b) " mtesta _str concat println
|
"-> mtesta = (b) " mtesta _str concat println
|
||||||
|
|
||||||
"^ok => ^ok (1): " print ^ok =>? ^ok _str println
|
"^ok => ^ok (1): " print ^ok => ^ok _str println
|
||||||
"^bad => ^ok (0): " print ^bad =>? ^ok _str println
|
"^bad => ^ok (0): " print ^bad => ^ok _str println
|
||||||
"[^bad a] => [^ok =mtestb] (0): " print [ ^bad "a" ] =>? [ ^ok &=mtestb ] _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 b] => [^ok =mtestb] (1): " print [ ^ok "b" ] => [ ^ok &=mtestb ] _str println
|
||||||
|
|
||||||
"-> mtestb = (b) " mtestb _str concat println
|
"-> mtestb = (b) " mtestb _str concat println
|
||||||
|
|
||||||
|
@ -313,17 +313,17 @@ func main { int | with args ;
|
||||||
|
|
||||||
[ ^ok "hello, world" ] =result
|
[ ^ok "hello, world" ] =result
|
||||||
|
|
||||||
result => [ ^ok &=val ]
|
result =>! [ ^ok &=val ]
|
||||||
val println
|
val println
|
||||||
|
|
||||||
[ ^error "bad" ] =result
|
[ ^error "bad" ] =result
|
||||||
|
|
||||||
catch Custom {
|
catch Custom {
|
||||||
result => [ ^ok &println ]
|
result =>! [ ^ok &println ]
|
||||||
} { with e ;
|
} { with e ;
|
||||||
e:message "match unsuccessful" eq if {
|
e:message "match unsuccessful" eq if {
|
||||||
"err value: " print
|
"err value: " print
|
||||||
result => [ ^error &println ]
|
result =>! [ ^error &println ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue