aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-23 02:42:13 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-23 02:42:13 +0200
commitfbcee9484d51d7cdf2921fdbb2ff12639337335d (patch)
treebb1aa8eb8df94d7ca4898843d5432010337830ea /src
parente7c8a04078261b331b00490ffbffd9ff05d1e0d0 (diff)
Make parenthesis optional in function if there are no parameters
Diffstat (limited to 'src')
-rw-r--r--src/parser.c8
1 files changed, 6 insertions, 2 deletions
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) {