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:
1 parent
3c20496c78
commit
ef305e7824
19 files changed
+370
-9
No files matched your search
+5
-1
@@ -18,11 +18,13 @@ struct kw {
|
||||
static const struct kw g_keywords[] = {
|
||||
{ "and", CAT_LEXER_TOK_AND },
|
||||
{ "break", CAT_LEXER_TOK_BREAK },
|
||||
{ "class", CAT_LEXER_TOK_CLASS },
|
||||
{ "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 },
|
||||
{ "extends", CAT_LEXER_TOK_EXTENDS },
|
||||
{ "false", CAT_LEXER_TOK_FALSE },
|
||||
{ "for", CAT_LEXER_TOK_FOR },
|
||||
{ "function", CAT_LEXER_TOK_FUNCTION },
|
||||
@@ -39,6 +41,7 @@ static const struct kw g_keywords[] = {
|
||||
{ "true", CAT_LEXER_TOK_TRUE },
|
||||
{ "try", CAT_LEXER_TOK_TRY },
|
||||
{ "until", CAT_LEXER_TOK_UNTIL },
|
||||
{ "use", CAT_LEXER_TOK_USE },
|
||||
{ "while", CAT_LEXER_TOK_WHILE },
|
||||
{ "yield", CAT_LEXER_TOK_YIELD },
|
||||
};
|
||||
@@ -261,7 +264,8 @@ const char *cat_lexer_kind_name(int kind)
|
||||
"yield", "try", "except", "raise",
|
||||
"+", "-", "*", "/", "%", "^", "#", "==", "~=", "<=", ">=", "<",
|
||||
">", "=", "(", ")", "{", "}", "[", "]", ";", ",", ".", ":",
|
||||
"::", "..", "->"
|
||||
"::", "..", "->",
|
||||
"class", "extends", "use"
|
||||
};
|
||||
if (kind >= 0 && kind < (int)(sizeof(names) / sizeof(names[0])))
|
||||
return names[kind];
|
||||
|
||||
Reference in new issue
Block a user