diff options
| author | Mel <mel@rnrd.eu> | 2026-05-28 01:06:31 +0200 |
|---|---|---|
| committer | Mel <mel@rnrd.eu> | 2026-05-28 01:06:31 +0200 |
| commit | 351433f3f7dc3f1051a9875402502663fe8a0be8 (patch) | |
| tree | 95ddeb3cdc87746da195c558c20260bd92d7a865 /boot/parse.c | |
| parent | 7dda10e54ebf303509cb7dcf7a3c60ec2de399d2 (diff) | |
| download | catskill-351433f3f7dc3f1051a9875402502663fe8a0be8.tar.zst catskill-351433f3f7dc3f1051a9875402502663fe8a0be8.zip | |
Allow no arguments for calls and constructs
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/parse.c')
| -rw-r--r-- | boot/parse.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/boot/parse.c b/boot/parse.c index 3ea4939..56d767a 100644 --- a/boot/parse.c +++ b/boot/parse.c @@ -153,6 +153,7 @@ parser_new(struct Parser* p, struct Lexer* lexer, struct Source_File source_file memset(p->lookahead, 0, sizeof(p->lookahead)); p->source_file = source_file; p->had_errors = false; + p->context = (struct Parser_Context){ 0 }; } bool @@ -467,10 +468,18 @@ parser_function_header_node(struct Parser* p, struct Parser_Error* error) } struct Tree_Argument_Group -parser_argument_group_node(struct Parser* p, struct Parser_Error* error) +parser_argument_group_node(struct Parser* p, enum Token_Kind close, struct Parser_Error* error) { Array(struct String) argument_names = array_new(struct String, 32); struct Tree_Expression *arguments_head = nil, *arguments_current = nil; + + if (parser_probe(p, close)) { + // empty argument list + return (struct Tree_Argument_Group){ + .arguments = nil, .argument_names = argument_names + }; + } + for (;;) { // check if we have a named argument. struct String name = string_empty(); @@ -1036,7 +1045,8 @@ parser_expression_postfix_call( CHECK(parser_need(p, TOKEN_ROUND_OPEN, error)); parser_unglue(p); - struct Tree_Argument_Group argument_group = parser_argument_group_node(p, error); + struct Tree_Argument_Group argument_group = + parser_argument_group_node(p, TOKEN_ROUND_CLOSE, error); if (!parser_error_is_none(error)) { parser_error_wrap(error, PARSER_ERROR_EXPECTED_ARGUMENTS); return nil; @@ -1057,7 +1067,8 @@ parser_expression_postfix_construct( CHECK(parser_need(p, TOKEN_CURLY_OPEN, error)); parser_unglue(p); - struct Tree_Argument_Group argument_group = parser_argument_group_node(p, error); + struct Tree_Argument_Group argument_group = + parser_argument_group_node(p, TOKEN_CURLY_CLOSE, error); if (!parser_error_is_none(error)) { parser_error_wrap(error, PARSER_ERROR_EXPECTED_ARGUMENTS); return nil; |
