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
This commit is contained in:
Minus committed 2026-11-16 01:48:47 +00:00
1 parent 52d118211f
commit 3c20496c78
19 files changed
+978 -99

No files matched your search

+5
View File
@@ -21,6 +21,7 @@ static const struct kw g_keywords[] = {
{ "do", CAT_LEXER_TOK_DO },
{ "else", CAT_LEXER_TOK_ELSE },
{ "elseif", CAT_LEXER_TOK_ELSEIF },
{ "except", CAT_LEXER_TOK_EXCEPT },
{ "end", CAT_LEXER_TOK_END },
{ "false", CAT_LEXER_TOK_FALSE },
{ "for", CAT_LEXER_TOK_FOR },
@@ -32,11 +33,14 @@ static const struct kw g_keywords[] = {
{ "not", CAT_LEXER_TOK_NOT },
{ "or", CAT_LEXER_TOK_OR },
{ "repeat", CAT_LEXER_TOK_REPEAT },
{ "raise", CAT_LEXER_TOK_RAISE },
{ "return", CAT_LEXER_TOK_RETURN },
{ "then", CAT_LEXER_TOK_THEN },
{ "true", CAT_LEXER_TOK_TRUE },
{ "try", CAT_LEXER_TOK_TRY },
{ "until", CAT_LEXER_TOK_UNTIL },
{ "while", CAT_LEXER_TOK_WHILE },
{ "yield", CAT_LEXER_TOK_YIELD },
};
void cat_lexer_init(CAT_LEXER_Lexer *lx, const char *src)
@@ -254,6 +258,7 @@ const char *cat_lexer_kind_name(int kind)
"and", "break", "do", "else", "elseif", "end", "false", "for",
"function", "if", "in", "local", "nil", "not", "or", "repeat",
"return", "then", "true", "until", "while",
"yield", "try", "except", "raise",
"+", "-", "*", "/", "%", "^", "#", "==", "~=", "<=", ">=", "<",
">", "=", "(", ")", "{", "}", "[", "]", ";", ",", ".", ":",
"::", "..", "->"