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,50 @@
|
||||
import os
|
||||
import math
|
||||
import time
|
||||
|
||||
func count(path: string): (int, int, error) {
|
||||
var text = os.read_file(path)?
|
||||
var words = 0
|
||||
var lines = 0
|
||||
for line in text.lines() {
|
||||
lines += 1
|
||||
words += line.fields().len()
|
||||
}
|
||||
return lines, words, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var csv = " alpha, beta ,gamma,, delta "
|
||||
var parts = csv.split(",")
|
||||
for p in parts { print("[" + p.trim() + "]") }
|
||||
print(parts.len(), parts.join("|"))
|
||||
print("Hello".upper(), "Hello".lower(), "a-b-c".replace("-", "+"), "ab".repeat(3))
|
||||
print("hello".contains("ell"), "hello".starts_with("he"), "hello".ends_with("x"), "hello".index_of("l"), "hello".index_of("z"))
|
||||
var n, err = "42".to_int()
|
||||
print(n, err)
|
||||
var bad, err2 = "4x2".to_int()
|
||||
print(bad, err2)
|
||||
var f, err3 = "2.5".to_float()
|
||||
print(f * 2, err3)
|
||||
|
||||
print(math.sqrt(16), math.pow(2, 10), math.floor(2.7), math.round(2.5), math.PI)
|
||||
print(math.min(3, 9), math.max(2.5, 1), math.abs(-7), math.abs(-2.5))
|
||||
var small: u8 = 7
|
||||
print(math.min(small, 200), math.max(small, 3))
|
||||
|
||||
var t0 = time.now()
|
||||
time.sleep(0.01)
|
||||
print(time.now() - t0 >= 0.01)
|
||||
|
||||
var err4 = os.write_file("/tmp/dino_std_test.txt", "one two\nthree\n\nfour five six\n")
|
||||
print(err4)
|
||||
var lines, words, e5 = count("/tmp/dino_std_test.txt")
|
||||
print(lines, words, e5)
|
||||
var l2, w2, e6 = count("/tmp/definitely/not/here.txt")
|
||||
print(l2, w2, e6)
|
||||
print(os.exists("/tmp/dino_std_test.txt"), os.exists("/nope"))
|
||||
print(os.args.len(), os.env("HOME_NOPE_X") == nil)
|
||||
var home = os.env("PATH")
|
||||
if home != nil { print(home.len() > 0) }
|
||||
os.exit(3)
|
||||
}
|
||||
Reference in new issue
Block a user