Track the LScript changes since the grammar was first written: - some, ok and err are reserved prefix operators and wrapper patterns; the old |.some/|.ok/|.err forms and postfix/prefix ! are rejected - function literal inputs may omit their type annotation, and tuple components may omit theirs; an empty typed tuple pattern is now just the unit pattern - migrate fixtures, corpus, queries, CST contract and Rust tests Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
29 lines
679 B
Plaintext
29 lines
679 B
Plaintext
choose: (bit, i32, i32) -> i32: @ (condition: bit, when_true: i32, when_false: i32) { if condition { when_true } else { when_false } }
|
|
|
|
choose_block: (bit, i32, i32) -> i32: @ (condition: bit, when_true: i32, when_false: i32) { if condition {
|
|
when_true
|
|
} else if not condition {
|
|
when_false
|
|
} else {
|
|
0
|
|
} }
|
|
|
|
first_positive: []i32 -> i32?: @ values: []i32 {
|
|
for value in values {
|
|
if value > 0 {
|
|
return some value
|
|
}
|
|
}
|
|
nil
|
|
}
|
|
|
|
labelled_search: []i32 -> i32: @ values: []i32 { loop `outer {
|
|
for value in values `items {
|
|
if value > 0 {
|
|
break `outer value
|
|
}
|
|
continue `items
|
|
}
|
|
break 0
|
|
} }
|