Compiler in Rust (lexer, parser, checker, C codegen), maps, chars, dino fmt, dino lsp (diagnostics, formatting, outline, definition, hover, completion, signature help), docs, examples, VS Code/Vim files. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
34 lines
595 B
Plaintext
34 lines
595 B
Plaintext
func say(msg: string, v: int): int {
|
|
print(msg)
|
|
return v
|
|
}
|
|
|
|
func add(a, b, c: int): int {
|
|
return a + b + c
|
|
}
|
|
|
|
func yes(msg: string): bool {
|
|
print(msg)
|
|
return true
|
|
}
|
|
|
|
func no(msg: string): bool {
|
|
print(msg)
|
|
return false
|
|
}
|
|
|
|
func main() {
|
|
print("arguments run left to right:")
|
|
print(add(say("first", 1), say("second", 2), say("third", 3)))
|
|
|
|
print("&& and || short-circuit:")
|
|
if no("A") && yes("B") {
|
|
print("unreachable")
|
|
}
|
|
if yes("C") || yes("D") {
|
|
print("done")
|
|
}
|
|
var ok = no("E") || yes("F") && yes("G")
|
|
print(ok)
|
|
}
|