From: Michael D. Lowis Date: Wed, 20 Jun 2018 12:27:18 +0000 (-0400) Subject: added parsing logic for function arguments on function definitions X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=fba0aec1513c0b736ca7de2a4ee46268f01462ca;p=proto%2Fsclpl.git added parsing logic for function arguments on function definitions --- diff --git a/example.src b/example.src index 2a2416d..c6f51e6 100644 --- a/example.src +++ b/example.src @@ -26,7 +26,7 @@ type type_union = union { bar = float; }; -fun main() int { +fun main(args string[]) int { let foo int = 123; var bar int = 123; {} diff --git a/source/parser.c b/source/parser.c index 524df58..374116b 100644 --- a/source/parser.c +++ b/source/parser.c @@ -140,8 +140,20 @@ static AST* type_definition(Parser* p) { static AST* func_definition(Parser* p) { expect(p, T_FUN); expect(p, T_ID); + expect(p, '('); + if (!matches(p, ')')) { + while (true) { + expect(p, T_ID); + type_expression(p); + if (!matches(p, ')')) + expect(p, ','); + else + break; + } + } expect(p, ')'); + type_expression(p); expression_block(p); return NULL;