diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-10-04 23:10:43 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-10-04 23:10:43 -0400 |
| commit | a4cb5ffafc050b519f806f74f0160ad48f76bee6 (patch) | |
| tree | 7a55f9b2e7c680eaccfa81c3734efdda71e848a3 /src/parse | |
| parent | 4cb2ea78760fabcbf526dee5962a6bf4896639f3 (diff) | |
Deprecate `extend`
Diffstat (limited to 'src/parse')
| -rw-r--r-- | src/parse/files.c | 5 | ||||
| -rw-r--r-- | src/parse/typedefs.c | 27 | ||||
| -rw-r--r-- | src/parse/typedefs.h | 1 | ||||
| -rw-r--r-- | src/parse/utils.c | 7 |
4 files changed, 7 insertions, 33 deletions
diff --git a/src/parse/files.c b/src/parse/files.c index 5e0dc29c..2dbe0e8f 100644 --- a/src/parse/files.c +++ b/src/parse/files.c @@ -41,9 +41,8 @@ ast_t *parse_file_body(parse_ctx_t *ctx, const char *pos) { ast_t *stmt; if ((stmt = optional(ctx, &pos, parse_struct_def)) || (stmt = optional(ctx, &pos, parse_func_def)) || (stmt = optional(ctx, &pos, parse_enum_def)) || (stmt = optional(ctx, &pos, parse_lang_def)) - || (stmt = optional(ctx, &pos, parse_extend)) || (stmt = optional(ctx, &pos, parse_convert_def)) - || (stmt = optional(ctx, &pos, parse_use)) || (stmt = optional(ctx, &pos, parse_inline_c)) - || (stmt = optional(ctx, &pos, parse_top_declaration))) { + || (stmt = optional(ctx, &pos, parse_convert_def)) || (stmt = optional(ctx, &pos, parse_use)) + || (stmt = optional(ctx, &pos, parse_inline_c)) || (stmt = optional(ctx, &pos, parse_top_declaration))) { statements = new (ast_list_t, .ast = stmt, .next = statements); pos = stmt->end; whitespace(ctx, &pos); // TODO: check for newline diff --git a/src/parse/typedefs.c b/src/parse/typedefs.c index fe48cb2c..56bb687f 100644 --- a/src/parse/typedefs.c +++ b/src/parse/typedefs.c @@ -26,9 +26,8 @@ ast_t *parse_namespace(parse_ctx_t *ctx, const char *pos) { ast_t *stmt; if ((stmt = optional(ctx, &pos, parse_struct_def)) || (stmt = optional(ctx, &pos, parse_func_def)) || (stmt = optional(ctx, &pos, parse_enum_def)) || (stmt = optional(ctx, &pos, parse_lang_def)) - || (stmt = optional(ctx, &pos, parse_extend)) || (stmt = optional(ctx, &pos, parse_convert_def)) - || (stmt = optional(ctx, &pos, parse_use)) || (stmt = optional(ctx, &pos, parse_inline_c)) - || (stmt = optional(ctx, &pos, parse_declaration))) { + || (stmt = optional(ctx, &pos, parse_convert_def)) || (stmt = optional(ctx, &pos, parse_use)) + || (stmt = optional(ctx, &pos, parse_inline_c)) || (stmt = optional(ctx, &pos, parse_declaration))) { statements = new (ast_list_t, .ast = stmt, .next = statements); pos = stmt->end; whitespace(ctx, &pos); // TODO: check for newline @@ -182,25 +181,3 @@ ast_t *parse_lang_def(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, LangDef, .name = name, .namespace = namespace); } - -ast_t *parse_extend(parse_ctx_t *ctx, const char *pos) { - const char *start = pos; - // extend Name: body... - if (!match_word(&pos, "extend")) return NULL; - int64_t starting_indent = get_indent(ctx, pos); - spaces(&pos); - const char *name = get_id(&pos); - if (!name) parser_err(ctx, start, pos, "I expected a name for this lang"); - - ast_t *body = NULL; - const char *ns_pos = pos; - whitespace(ctx, &ns_pos); - int64_t ns_indent = get_indent(ctx, ns_pos); - if (ns_indent > starting_indent) { - pos = ns_pos; - body = optional(ctx, &pos, parse_namespace); - } - if (!body) body = NewAST(ctx->file, pos, pos, Block, .statements = NULL); - - return NewAST(ctx->file, start, pos, Extend, .name = name, .body = body); -} diff --git a/src/parse/typedefs.h b/src/parse/typedefs.h index 1a746cff..1bdb92e6 100644 --- a/src/parse/typedefs.h +++ b/src/parse/typedefs.h @@ -7,5 +7,4 @@ ast_t *parse_lang_def(parse_ctx_t *ctx, const char *pos); ast_t *parse_enum_def(parse_ctx_t *ctx, const char *pos); ast_t *parse_struct_def(parse_ctx_t *ctx, const char *pos); -ast_t *parse_extend(parse_ctx_t *ctx, const char *pos); ast_t *parse_namespace(parse_ctx_t *ctx, const char *pos); diff --git a/src/parse/utils.c b/src/parse/utils.c index 2048a3ff..28cf0964 100644 --- a/src/parse/utils.c +++ b/src/parse/utils.c @@ -12,10 +12,9 @@ #include "utils.h" static const char *keywords[] = { - "C_code", "_max_", "_min_", "and", "assert", "break", "continue", "defer", "deserialize", "do", - "else", "enum", "extend", "for", "func", "if", "in", "lang", "mod", "mod1", - "no", "none", "not", "or", "pass", "return", "skip", "skip", "stop", "struct", - "then", "unless", "use", "when", "while", "xor", "yes", + "C_code", "_max_", "_min_", "and", "assert", "break", "continue", "defer", "deserialize", "do", "else", "enum", + "for", "func", "if", "in", "lang", "mod", "mod1", "no", "none", "not", "or", "pass", + "return", "skip", "skip", "stop", "struct", "then", "unless", "use", "when", "while", "xor", "yes", }; CONSTFUNC bool is_keyword(const char *word) { |
