std/ tree, use (import) and class syntax

- std/ layout: std/lang/{lexer,parser,checker,compiler}.cat moved from src/catscript
- std/io/io.cat, std/fs/fs.cat, std/math/math.cat modules
- use "path.cat": import another unit (compile+run in the same VM)
- class NAME [extends BASE] ... end: methods, inheritance via __index,
  default new constructor (runs optional init), tables are callable
- examples/classes.cat, tests/std.cat; 48/48 tests
This commit is contained in:
Minus committed 2026-11-16 01:53:53 +00:00
1 parent 3c20496c78
commit ef305e7824
19 files changed
+370 -9

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
-- tests/std.cat -- exercises the std/ tree (use/import + modules).
use "std/math/math.cat"
use "std/io/io.cat"
use "std/fs/fs.cat"
print("math double:", double(21))
print("math square:", square(9))
print("math abs:", abs(-7))
print("io join:", join({ "a", "b", "c" }, "-"))
local path = "/tmp/catscript_std_test.txt"
fs_write(path, "one")
fs_append(path, "two")
print("fs read:", fs_read(path))
print("fs copy:", fs_copy(path, "/tmp/catscript_std_copy.txt"))
print("fs read2:", fs_read("/tmp/catscript_std_copy.txt"))