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,43 @@
|
||||
import parser
|
||||
import eval
|
||||
import os
|
||||
|
||||
// Evaluates one line and prints the answer or the problem.
|
||||
func run_line(scope: shared eval.Scope, line: string) {
|
||||
var text = line.trim()
|
||||
if text == "" { return }
|
||||
var tree, err = parser.parse(text)
|
||||
if err != nil {
|
||||
print(" error:", err)
|
||||
return
|
||||
}
|
||||
var value, err2 = scope.eval(tree)
|
||||
if err2 != nil {
|
||||
print(" error:", err2)
|
||||
return
|
||||
}
|
||||
print(" =", value)
|
||||
}
|
||||
|
||||
// Reads lines from the file named on the command line, or from the keyboard.
|
||||
func main() {
|
||||
var scope = shared eval.new_scope()
|
||||
var args = os.args
|
||||
if args.len() > 1 {
|
||||
var text, err = os.read_file(args[1])
|
||||
if err != nil {
|
||||
print("cannot read", args[1], err)
|
||||
os.exit(1)
|
||||
}
|
||||
for line in text.lines() {
|
||||
print(line)
|
||||
run_line(scope, line)
|
||||
}
|
||||
return
|
||||
}
|
||||
for {
|
||||
var line = os.read_line()
|
||||
if line == nil { break }
|
||||
run_line(scope, line)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user