This commit is contained in:
Yaossg 2024-11-17 10:39:58 +08:00
parent fc9ac15c4b
commit dfbeb90387
2 changed files with 38 additions and 3 deletions

12
boot.c
View file

@ -249,7 +249,7 @@ void next_token() {
} else if (ch == '/') {
int ch2 = getchar();
if (ch2 == '/') {
do ch = getchar(); while (ch != '\n' && ch != -1);
while ((ch = getchar()) != -1 && ch != '\n');
next_token();
return;
} else if (ch2 == '*') {
@ -1238,14 +1238,20 @@ void parse_function(const char* name) {
expect_token(TOKEN_PAREN_RIGHT);
break;
}
int decl_type = parse_type();
int arg_type = parse_type();
expect_token(TOKEN_ID);
args[arg++] = declare_local(token_data, decl_type);
int arg_name = token_data;
next_token();
if (token_type == TOKEN_BRACKET_LEFT) {
expect_token(TOKEN_BRACKET_RIGHT);
next_token();
if (arg_type & TYPE_PTR_MASK) {
eprintf("local variable of array of pointers is not supported\n");
exit(1);
}
arg_type = arg_type | TYPE_PTR_MASK;
}
args[arg++] = declare_local(token_data, arg_type);
if (token_type == TOKEN_COMMA) {
// continue;
} else if (token_type == TOKEN_PAREN_RIGHT) {