aboutsummaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-18 15:39:22 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-18 15:39:22 -0400
commit7f5af625e5045055173fb776fc5aaa5453704f61 (patch)
treed69a512eef5f5a04f039bc0f9d9a210db5d200bd /parse.c
parent2d78f11400d61f89845678b40e7b0682f14bba7f (diff)
Support `use`ing .c files and .S files (assembly)
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c13
1 files changed, 9 insertions, 4 deletions
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);
}