Files
Your NameandClaude Opus 5.5 7cf9727bcd Rename the language from Dino to Rex
Files use .rex, the command is rex, and the crate, runtime prefixes,
docs, editor files and examples all use the new name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:51:23 +01:00

44 lines
1.0 KiB
Rexx

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)
}
}