From: Michael D. Lowis Date: Wed, 2 Oct 2019 00:57:36 +0000 (-0400) Subject: checkpoint commit X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=54f69c15b8d58d701df9b2da0e4d046c86f12e54;p=proto%2Fsclpl.git checkpoint commit --- diff --git a/example.src b/example.src index 22a606e..85083cf 100644 --- a/example.src +++ b/example.src @@ -1,5 +1,7 @@ require ("fmt") -provide (main) +provide { + fun main(args string[]) int +} type type_int = int type type_intary = int[] diff --git a/src/parser.c b/src/parser.c index ded14db..e59cc30 100644 --- a/src/parser.c +++ b/src/parser.c @@ -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(); } diff --git a/test/parser.c b/test/parser.c index b0c861b..bce8ab3 100644 --- a/test/parser.c +++ b/test/parser.c @@ -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; } }