Deprecate linker directives

This commit is contained in:
Bruce Hill 2024-09-18 00:43:13 -04:00
parent 8e3c871f27
commit 7e0b1a3214
5 changed files with 1 additions and 20 deletions

1
ast.c
View File

@ -157,7 +157,6 @@ CORD ast_to_xml(ast_t *ast)
T(NonOptional, "<NonOptional>%r</NonOptional>", ast_to_xml(data.value))
T(DocTest, "<DocTest>%r<output>%r</output></DocTest>", optional_tagged("expression", data.expr), xml_escape(data.output))
T(Use, "<Use>%r</Use>", xml_escape(data.path))
T(LinkerDirective, "<LinkerDirective>%r</LinkerDirective>", xml_escape(data.directive))
T(InlineCCode, "<InlineCode>%r</InlineCode>", xml_escape(data.code))
default: return "???";
#undef T

4
ast.h
View File

@ -129,7 +129,6 @@ typedef enum {
Index, FieldAccess, Optional, NonOptional,
DocTest,
Use,
LinkerDirective,
InlineCCode,
} ast_e;
@ -300,9 +299,6 @@ struct ast_s {
const char *path;
enum { USE_LOCAL, USE_MODULE, USE_SHARED_OBJECT, USE_HEADER } what;
} Use;
struct {
const char *directive;
} LinkerDirective;
struct {
CORD code;
struct type_s *type;

View File

@ -3243,7 +3243,6 @@ CORD compile(env_t *env, ast_t *ast)
}
case Use: code_err(ast, "Compiling 'use' as expression!");
case Defer: code_err(ast, "Compiling 'defer' as expression!");
case LinkerDirective: code_err(ast, "Linker directives are not supported yet");
case Extern: code_err(ast, "Externs are not supported as expressions");
case TableEntry: code_err(ast, "Table entries should not be compiled directly");
case Declare: case Assign: case UpdateAssign: case For: case While: case StructDef: case LangDef:

13
parse.c
View File

@ -98,7 +98,6 @@ static PARSER(parse_func_def);
static PARSER(parse_if);
static PARSER(parse_inline_c);
static PARSER(parse_lang_def);
static PARSER(parse_linker);
static PARSER(parse_namespace);
static PARSER(parse_path);
static PARSER(parse_say);
@ -1916,7 +1915,6 @@ PARSER(parse_namespace) {
||(stmt=optional(ctx, &pos, parse_lang_def))
||(stmt=optional(ctx, &pos, parse_func_def))
||(stmt=optional(ctx, &pos, parse_use))
||(stmt=optional(ctx, &pos, parse_linker))
||(stmt=optional(ctx, &pos, parse_extern))
||(stmt=optional(ctx, &pos, parse_inline_c))
||(stmt=optional(ctx, &pos, parse_declaration)))
@ -1952,7 +1950,6 @@ PARSER(parse_file_body) {
||(stmt=optional(ctx, &pos, parse_lang_def))
||(stmt=optional(ctx, &pos, parse_func_def))
||(stmt=optional(ctx, &pos, parse_use))
||(stmt=optional(ctx, &pos, parse_linker))
||(stmt=optional(ctx, &pos, parse_extern))
||(stmt=optional(ctx, &pos, parse_inline_c))
||(stmt=optional(ctx, &pos, parse_top_declaration)))
@ -2343,16 +2340,6 @@ PARSER(parse_use) {
return NewAST(ctx->file, start, pos, Use, .path=name, .what=what);
}
PARSER(parse_linker) {
const char *start = pos;
if (!match_word(&pos, "!link")) return NULL;
spaces(&pos);
size_t len = strcspn(pos, "\r\n");
const char *directive = GC_strndup(pos, len);
pos += len;
return NewAST(ctx->file, start, pos, LinkerDirective, .directive=directive);
}
ast_t *parse_file(const char *path, jmp_buf *on_err) {
const char *resolved = resolve_path(path, ".", ".");
if (!resolved)

View File

@ -875,7 +875,7 @@ type_t *get_type(env_t *env, ast_t *ast)
case Extern: {
return parse_type_ast(env, Match(ast, Extern)->type);
}
case Declare: case Assign: case DocTest: case LinkerDirective: {
case Declare: case Assign: case DocTest: {
return Type(VoidType);
}
case Use: {