From 78bdd279d90ace6e53a853a898f4819327e82743 Mon Sep 17 00:00:00 2001 From: c Date: Thu, 8 Feb 2024 19:41:27 -0500 Subject: Fixed broken test. Calls and their arguments are now parsed correctly. --- src/parser.c | 11 +++++++++-- test/parser.c | 5 +---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/parser.c b/src/parser.c index ac08a16..731df78 100644 --- a/src/parser.c +++ b/src/parser.c @@ -100,10 +100,17 @@ tree_t* parser_parse_kwd(parser_t* parser) { call->data.call.target = parser->token->val; parser->token->val = NULL; - - if (parser_nxt_token_match(parser, TOKEN_TYPE_APPLY)) { + + /* Skip over keyword, check for arguments. */ + if ( + parser_nxt_token(parser) && + parser->token->type == TOKEN_TYPE_APPLY + ) { + /* Expect some arguments. */ + parser_nxt_token(parser); call->data.call.arg = parser_parse_carg(parser); } else { + /* There're no arguments. */ call->data.call.arg = NULL; } diff --git a/test/parser.c b/test/parser.c index 3bceab1..503244f 100644 --- a/test/parser.c +++ b/test/parser.c @@ -716,7 +716,7 @@ void cargumented_call_of_call() { char* target1 = tree1call->data.call.target = ecalloc(2, sizeof(char)); strcpy(target1, "x"); tree1call->data.call.arg = NULL; - tree0call->data.carg.nxt = NULL; + tree0carg->data.carg.nxt = NULL; tree->data.block.nxt = NULL; pp = pp_init(src); @@ -730,9 +730,6 @@ void cargumented_call_of_call() { ASSERT(tree_cmp(parser->tree, tree) == 1); - tree_print(tree, 0); - tree_print(parser->tree, 0); - token_destroy(lexer->tokenl); lexer_destroy(lexer); free(pp->psrc); -- cgit v1.2.3