Commit Graph
5 Commits
Author SHA1 Message Date
Minus 95f3823acf comptime: compile-time evaluation (Zig-style)
`comptime "<source>"` runs catscript inside the compiler, in an embedded
VM created lazily and shared for the whole compilation:

- expression position: the result value is baked into the program as a
  constant (`local x = comptime "return 6 * 7"` -> x is 42).
- statement position: runs for side effects (compile-time globals) and
  the value is discarded.
- errors raised at compile time surface as normal compile errors
  ("line N: comptime: boom").
- the embedded VM is freed at the end of compilation.

This reuses the existing interpreter, which is why it is cheap: the
language already has a VM to embed.  tests/comptime.cat + suite block.
Suite 141 -> 144.
2026-11-18 17:17:20 +00:00
Minus b945182739 interface + structural is: runtime-checked interfaces
Add nominal interface declarations with structural, runtime checking
(the owner asked for the operator AND the runtime check).

- lexer: `interface` and `is` are keywords; `implements` is a soft
  keyword (matched by text in the class clause) so the `implements()`
  stdlib function is not shadowed.
- `interface NAME [extends BASE] <function m() end> end` builds a table
  tagged `__interface`; members name the required methods (with an
  optional default body, shared via `__index`). Interface inheritance
  follows `__index`.
- class: `class C [extends B] [implements I, ...]` -- after the class
  global is set, `__implements_check` runs and raises if the class does
  not satisfy each declared interface.
- new opcode `IS` (`obj is iface`): structural membership test, and it
  degrades to an exact type (vtable) match when the right side is not an
  interface, so `x is SomeClass` reads naturally. Backed by
  `cat_value_is()`.
- stdlib: `implements(obj, iface)` (the same test as a function).
- tests/interface.cat + suite block: interface satisfaction, interface
  inheritance, duck typing (no `implements` needed), and a missing
  method failing. Suite 130 -> 136, all green.
2026-11-18 15:56:10 +00:00
Minus ef305e7824 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
2026-11-16 01:53:53 +00:00
Minus 3c20496c78 generators/iterators, raise/try/except, and slot-based object layout
- VM refactor: resumable CAT_VM_Frame (ip/sp/locals/handlers)
- yield/next/generators: calling a yield-function returns a generator
- for..in over any iterator, ends on explicit exhaustion status
- raise/try/except: structured error values, nearest-handler unwinding
- slots: C-declared member layout (offsetof), PyTypeObject/tp_members style
- File now exposes path/mode/closed via slots
- examples: generators.cat, errors.cat, slots.cat; 40/40 tests
2026-11-16 01:48:47 +00:00
Minus 52d118211f catscript: núcleo C, stdlib (TOML), família de arquivos e front-end self-hosted
- Modelo de objetos Cat_Value + vtable (interfaces abstratas)
- VM de bytecode, sem GIL (VM por-thread, nativas como valores)
- Stdlib com TOML embutido (toml_parse/toml_encode)
- Família de arquivos: AbstractFile (abstrata), File::open, StringIO, BytesIO
- Front-end (lexer/parser/checker/compiler) implementado em catscript
- cpk (cat package manager) como primeiro programa; manifest package.toml
- Type hints advisory, inclusive DynSized() e sentinel_sized<...>
- 25/25 testes passando (make test)
2026-11-16 01:27:44 +00:00