summaryrefslogtreecommitdiff
path: root/src/parser/parser_type.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/parser_type.c')
-rw-r--r--src/parser/parser_type.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/parser/parser_type.c b/src/parser/parser_type.c
index 24e9f69..39a4dc7 100644
--- a/src/parser/parser_type.c
+++ b/src/parser/parser_type.c
@@ -439,6 +439,14 @@ Type *parse_type_base(ParserContext *ctx, Lexer *l)
return type_new(TYPE_ISIZE);
}
+ // Relaxed Type Check: If explicit 'struct Name', trust the user.
+ if (explicit_struct)
+ {
+ Type *ty = type_new(TYPE_STRUCT);
+ ty->name = name;
+ ty->is_explicit_struct = 1;
+ }
+
// Selective imports ONLY apply when we're NOT in a module context
if (!ctx->current_module_prefix)
{
@@ -707,6 +715,19 @@ Type *parse_type_base(ParserContext *ctx, Lexer *l)
return ty;
}
+ // If we have an identifier that wasn't found,
+ // assume it is a valid external C type
+ // (for example, a struct defined in implementation).
+ if (t.type == TOK_IDENT)
+ {
+ char *fallback = token_strdup(t);
+ lexer_next(l);
+ Type *ty = type_new(TYPE_STRUCT);
+ ty->name = fallback;
+ ty->is_explicit_struct = 0;
+ return ty;
+ }
+
return type_new(TYPE_UNKNOWN);
}