]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
added parsing logic for function arguments on function definitions
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 20 Jun 2018 12:27:18 +0000 (08:27 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 20 Jun 2018 12:27:18 +0000 (08:27 -0400)
example.src
source/parser.c

index 2a2416d933511ac0229e4ad5468ff3d0595291dc..c6f51e66133817c62ffc61252db836b75ad5cdda 100644 (file)
@@ -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;
     {}
index 524df58bf98e89c188ea417c224100720eaa1191..374116bffb75373e92aab2bf5cf85bf855bd7c93 100644 (file)
@@ -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;