]> git.corax.cc Git - ccc/commitdiff
parser: Implement parsing of argument expression lists
authorMatthias Kruk <m@m10k.eu>
Sat, 11 Jul 2020 08:38:51 +0000 (17:38 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 11 Jul 2020 08:38:51 +0000 (17:38 +0900)
src/grammar.h
src/parser.c

index 661efc207b653bbf5006d30639ada139a37b6290..a14bf2c0ec603d6caa2918d992b8a7fa8b66b5f8 100644 (file)
@@ -250,6 +250,7 @@ struct assignment_expression {
 
 struct argument_expression_list {
        struct assignment_expression *aexpr;
+       struct token *comma;
        struct argument_expression_list *next;
 };
 
index f89ee12b07dcbbc97dda1d371c891fb1a344c5c0..9727d86b7a16f95615051f4afd1ca127af5a6b89 100644 (file)
@@ -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);
 }