aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parse.c
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-08-25 00:31:25 +0900
committernsfisis <nsfisis@gmail.com>2025-08-25 00:41:12 +0900
commit7f29d50e4558a700b7611dc72e87e7922ac6a345 (patch)
treeb4a8b7c41457d209eb91e29f23044610d6b4b700 /src/parse.c
parent36da139565202a9a39d1e4261ab8bf950041518b (diff)
downloadducc-7f29d50e4558a700b7611dc72e87e7922ac6a345.tar.gz
ducc-7f29d50e4558a700b7611dc72e87e7922ac6a345.tar.zst
ducc-7f29d50e4558a700b7611dc72e87e7922ac6a345.zip
feat: support static function
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/parse.c b/src/parse.c
index 882d769..7750f40 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -519,8 +519,16 @@ BOOL is_type_token(Parser* p, Token* token) {
Type* parse_type(Parser* p) {
Token* t = next_token(p);
- if (t->kind == TokenKind_keyword_const || t->kind == TokenKind_keyword_static) {
- t = next_token(p);
+ BOOL has_static = FALSE;
+ while (1) {
+ if (t->kind == TokenKind_keyword_const) {
+ t = next_token(p);
+ } else if (t->kind == TokenKind_keyword_static) {
+ t = next_token(p);
+ has_static = TRUE;
+ } else {
+ break;
+ }
}
if (!is_type_token(p, t)) {
fatal_error("%s:%d: parse_type: expected type, but got '%s'", t->loc.filename, t->loc.line, token_stringify(t));
@@ -578,6 +586,7 @@ Type* parse_type(Parser* p) {
}
ty = type_new_ptr(ty);
}
+ ty->is_static = has_static;
return ty;
}
@@ -1254,6 +1263,7 @@ AstNode* parse_func_decl_or_def(Parser* p) {
func->node_stack_size =
p->lvars.data[p->lvars.len - 1].stack_offset + type_sizeof(p->lvars.data[p->lvars.len - 1].ty);
}
+ func->node_function_is_static = ty->is_static;
return func;
}