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,29 @@
|
||||
// A small CLI tool: count lines and words in files.
|
||||
import os
|
||||
|
||||
struct Stats {
|
||||
lines: int
|
||||
words: int
|
||||
}
|
||||
|
||||
func count(path: string): (Stats, error) {
|
||||
var text = os.read_file(path)? // ? returns the error to the caller
|
||||
var stats = Stats{}
|
||||
for line in text.lines() {
|
||||
stats.lines += 1
|
||||
stats.words += line.fields().len()
|
||||
}
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var args = os.args
|
||||
for path in args[1..] {
|
||||
var s, err = count(path)
|
||||
if err != nil {
|
||||
print("{path}: error: {err}")
|
||||
continue
|
||||
}
|
||||
print("{path}: {s.lines} lines, {s.words} words")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user