From 826698a979317b3d2d643f0112ed043bd27a844b Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 30 May 2018 12:37:58 -0400 Subject: [PATCH] sketch out additional top-level constructs --- source/parser.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/source/parser.c b/source/parser.c index 3d3f04d..746272a 100644 --- a/source/parser.c +++ b/source/parser.c @@ -6,7 +6,7 @@ static AST* definition(Parser* p); static AST* expression(Parser* p); static AST* identifier(Parser* p); static AST* function(Parser* p); -static void type_annotation(Parser* p); +static Type* type_annotation(Parser* p); static AST* literal(Parser* p); static AST* expr_block(Parser* p); static AST* if_stmnt(Parser* p); @@ -65,6 +65,10 @@ AST* toplevel(Parser* p) { TokType type = peek(p)->type; if (accept(p, T_LET) || accept(p, T_VAR)) ret = const_definition(p, (type == T_LET)); +// else if (accept(p, T_TYPE)) +// ret = type_definition(p); +// else if (accept(p, T_FUN)) +// ret = func_definition(p); else error(p, "only definitions are allowed at the toplevel"); } @@ -93,16 +97,9 @@ static AST* const_expression(Parser* p) { return expr; } -static void type_annotation(Parser* p) { +static Type* type_annotation(Parser* p) { expect(p, T_ID); - /* array type */ - if (accept(p,T_LBRACK)) { - accept(p, T_INT); - expect(p, T_RBRACK); - /* reference type */ - } else if (accept(p, T_AMP)) { - // TODO: implement reference types - } + return NULL; } static AST* literal(Parser* p) { -- 2.54.0