]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
checkpoint commit wirth
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 2 Oct 2019 00:57:36 +0000 (20:57 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 2 Oct 2019 00:57:36 +0000 (20:57 -0400)
example.src
src/parser.c
test/parser.c

index 22a606efab11ee59ffada15ad342d7a56773c0d1..85083cf5b138af8f06db50957e8dabfee44af3f4 100644 (file)
@@ -1,5 +1,7 @@
 require ("fmt")
-provide (main)
+provide {
+    fun main(args string[]) int
+}
 
 type type_int = int
 type type_intary = int[]
index ded14db4a12638ba1bf62d11e5dcef960a6ce097..e59cc30efd091b2202068b94e0f4a1b4e90850be 100644 (file)
@@ -137,7 +137,7 @@ void toplevel(Parser* p) {
         require_list(p);
     if (matches(p, T_PROVIDES))
         provide_list(p);
-    definition_list(p);
+//    definition_list(p);
     parse_exit();
 }
 
@@ -156,12 +156,19 @@ static void require_list(Parser* p) {
 static void provide_list(Parser* p) {
     parse_enter();
     accept(p, T_PROVIDES);
-    expect(p, '(');
+    expect(p, '{');
     while (!matches(p, ')')) {
-        Tok* tok = expect_val(p, T_ID);
-        pkg_add_provide(&(p->pkg), tok->text);
+        if (matches(p, T_LET) || matches(p, T_VAR)) {
+            //declaration(p);
+        } else if (matches(p, T_TYPE)) {
+            //type_definition(p);
+        } else if (matches(p, T_FUN)) {
+            //func_declaration(p);
+        } else {
+            error(p, "only definitions are allowed at the top level");
+        }
     }
-    expect(p, ')');
+    expect(p, '}');
     parse_exit();
 }
 
index b0c861b9195b26cb0d0629abebffe730c8214fc5..bce8ab3627478043faf88309e727d9e81ed3a93b 100644 (file)
@@ -13,6 +13,8 @@ static int astcmp(AST* a, AST* b) {
             return (a->value.integer - b->value.integer);
         case AST_STRING:
             return strcmp(a->value.text, b->value.text);
+        default:
+            return -1;
     }
 }