]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
added support for nested functions to the grammar
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 7 Aug 2018 17:50:22 +0000 (13:50 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 7 Aug 2018 17:50:22 +0000 (13:50 -0400)
example.src
source/parser.c

index b05e693a62672aa95913589eeb5a87e4fab26179..02b3cf164f728c45ddd6afcc8a4ae9ffb80570dc 100644 (file)
@@ -35,15 +35,14 @@ fun main(args string[]) int {
     foo()
     bar(1)
     baz(1,2)
-#    if (123) {}
-#    if 123 {}
-#    if (123) {} else {}
-#    if (123) {} else if (123) {}
-#    if (123) {} else if (123) {} else {}
-#    if 123 {} else if 123 {} else {}
-#
-#    fun main(args string[]) int {
-#        123
-#    }
+    if (123) {}
+    if 123 {}
+    if (123) {} else {}
+    if (123) {} else if (123) {}
+    if (123) {} else if (123) {} else {}
+    if 123 {} else if 123 {} else {}
+    fun main(args string[]) int {
+        123
+    }
 }
 
index 2225da000d88d42bc17a551ead31767a4ac92789..98ef30f31ba03b7a42a66129d1a7f07125e93831 100644 (file)
@@ -230,6 +230,8 @@ static AST* expression_block(Parser* p) {
     while (!matches(p, '}')) {
         if (matches(p, T_LET) || matches(p, T_VAR)) {
             definition(p);
+        } else if (matches(p, T_FUN)) {
+            func_definition(p);
         } else {
             expression(p);
         }