From 7f5af625e5045055173fb776fc5aaa5453704f61 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 18 Sep 2024 15:39:22 -0400 Subject: Support `use`ing .c files and .S files (assembly) --- parse.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index b387eb5d..b3f9a0c3 100644 --- a/parse.c +++ b/parse.c @@ -2356,14 +2356,19 @@ PARSER(parse_use) { pos += name_len; while (match(&pos, ";")) continue; int what; - if (name[0] == '<' || name[0] == '"') + if (name[0] == '<' || ends_with(name, ".h")) { what = USE_HEADER; - else if (starts_with(name, "./") || starts_with(name, "/") || starts_with(name, "../") || starts_with(name, "~/")) + } else if (ends_with(name, ".c")) { + what = USE_C_CODE; + } else if (ends_with(name, ".S") || ends_with(name, ".s")) { + what = USE_ASM; + } else if (starts_with(name, "./") || starts_with(name, "/") || starts_with(name, "../") || starts_with(name, "~/")) { what = USE_LOCAL; - else if (ends_with(name, ".so")) + } else if (ends_with(name, ".so")) { what = USE_SHARED_OBJECT; - else + } else { what = USE_MODULE; + } return NewAST(ctx->file, start, pos, Use, .path=name, .what=what); } -- cgit v1.2.3