From fbcee9484d51d7cdf2921fdbb2ff12639337335d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 23 Jul 2020 02:42:13 +0200 Subject: Make parenthesis optional in function if there are no parameters --- src/parser.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/parser.c b/src/parser.c index 0c46f42..8d23888 100644 --- a/src/parser.c +++ b/src/parser.c @@ -167,9 +167,13 @@ static TslParseResult tsl_parser_parse_fn_body(TslParser *self) { return tsl_parser_parse_expressions(self, TSL_TOKEN_RBRACE); } -/* FN = '(' (IDENTIFIER ',')* ')' FN_BODY */ +/* FN = ( '(' (IDENTIFIER ',')* ')' )? FN_BODY */ static TslParseResult tsl_parser_parse_fn(TslParser *self) { - return_if_error(tsl_tokenizer_accept(&self->tokenizer, TSL_TOKEN_LPAREN)); + TslToken token = tsl_tokenizer_next(&self->tokenizer); + /* FN_BODY */ + if(token == TSL_TOKEN_LBRACE) + return tsl_parser_parse_expressions(self, TSL_TOKEN_RBRACE); + for(;;) { TslToken token = tsl_tokenizer_next(&self->tokenizer); if(token == TSL_TOKEN_RPAREN) { -- cgit v1.2.3