From: Matthias Kruk Date: Sat, 11 Jul 2020 08:38:51 +0000 (+0900) Subject: parser: Implement parsing of argument expression lists X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=8f940da39bcd44c0330fc47dc29771a75d017e94;p=ccc parser: Implement parsing of argument expression lists --- diff --git a/src/grammar.h b/src/grammar.h index 661efc2..a14bf2c 100644 --- a/src/grammar.h +++ b/src/grammar.h @@ -250,6 +250,7 @@ struct assignment_expression { struct argument_expression_list { struct assignment_expression *aexpr; + struct token *comma; struct argument_expression_list *next; }; diff --git a/src/parser.c b/src/parser.c index f89ee12..9727d86 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1278,6 +1278,31 @@ struct postfix_expression *parse_postfix_expression(void) struct argument_expression_list *parse_argument_expression_list(void) { - fprintf(stderr, "FIXME: %s() is not implemented\n", __func__); + struct argument_expression_list *list; + int pos; + + list = argument_expression_list_new(); + + if(!list) { + return(NULL); + } + + if((list->aexpr = parse_assignment_expression())) { + return(list); + } + + pos = lex_getpos(); + + list->next = parse_argument_expression_list(); + list->comma = lex_gettoken(); + list->aexpr = parse_assignment_expression(); + + if(list->next && list->comma && list->aexpr && list->comma->type == TOKEN_COMMA) { + return(list); + } + + argument_expression_list_free(list); + lex_setpos(pos); + return(NULL); }