fix: macros with multiple arguments didn't work

This commit is contained in:
overflowerror 2024-05-18 11:23:54 +02:00
parent 76fb52c60c
commit 3f0b407cb3
3 changed files with 15 additions and 6 deletions

View file

@ -95,13 +95,16 @@ static void handle_macro_definition(void) {
fprintf(stderr, "preprocessor: macro: , expected, got: %s\n", yytext);
panic("preprocessor syntax error");
}
} else {
if (token != ID) {
fprintf(stderr, "preprocessor: macro: identifier expected, got: %s\n", yytext);
panic("preprocessor syntax error");
}
list_add(macro->argument_list, yylval.id);
token = yylex();
}
if (token != ID) {
fprintf(stderr, "preprocessor: macro: identifier expected, got: %s\n", yytext);
panic("preprocessor syntax error");
}
list_add(macro->argument_list, yylval.id);
is_first = false;
}
token = yylex();

View file

@ -0,0 +1,5 @@
#macro test(a, b, c) {
print($a, $b, $c, '\n')
}
test$('f', 'o', 'o');

View file

@ -0,0 +1 @@
[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++<<<.>.>.>.