Dino compiler: language, formatter, language server, docs, editor support
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>
This commit is contained in:
1 parent
3e2779f447
commit
eaf9567a36
117 files changed
+19970
No files matched your search
@@ -0,0 +1,53 @@
|
||||
struct User {
|
||||
name: string
|
||||
age: int
|
||||
}
|
||||
|
||||
func find(id: int): User? {
|
||||
if id == 1 {
|
||||
return User{name: "Ann", age: 30}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func first_even(xs: []int): int? {
|
||||
for x in xs {
|
||||
if x % 2 == 0 { return x }
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func describe(id: int): string {
|
||||
var u = find(id)
|
||||
if u == nil {
|
||||
return "nobody"
|
||||
}
|
||||
return "{u.name} is {u.age}"
|
||||
}
|
||||
|
||||
func main() {
|
||||
print(describe(1))
|
||||
print(describe(2))
|
||||
|
||||
var n = first_even([1, 3, 4, 5])
|
||||
if n != nil {
|
||||
print("first even:", n + 1)
|
||||
}
|
||||
var m: int? = first_even([1, 3])
|
||||
print("m is", m)
|
||||
print("n is", n)
|
||||
|
||||
var count: int? = 5
|
||||
if count != nil && count > 3 {
|
||||
print("big count")
|
||||
}
|
||||
count = nil
|
||||
if count == nil || count > 100 {
|
||||
print("no count")
|
||||
}
|
||||
|
||||
var list: []int? = nil
|
||||
if list == nil {
|
||||
print("no list")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user