diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-06-26 13:59:15 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-06-26 13:59:15 +0100 |
| commit | a0d8dcd9743c1f1a4dabfc5bba7301785ded98a3 (patch) | |
| tree | fd0bc8416b8a2b71456f0b4a6bf63a4e82373b13 /src | |
| parent | c642e326cecd3dc33ca5a9efb6330e757c378dd9 (diff) | |
Remove `let`
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.cpp | 6 | ||||
| -rw-r--r-- | src/check_stmt.cpp | 6 | ||||
| -rw-r--r-- | src/checker.cpp | 5 | ||||
| -rw-r--r-- | src/docs.cpp | 1 | ||||
| -rw-r--r-- | src/ir.cpp | 3 | ||||
| -rw-r--r-- | src/parser.cpp | 23 | ||||
| -rw-r--r-- | src/tokenizer.cpp | 1 |
7 files changed, 20 insertions, 25 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 1fa0117ac..43d870261 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5865,6 +5865,12 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t check_close_scope(c); return kind; } + + if (pl->body == NULL) { + error(node, "A procedure literal must have a body"); + return kind; + } + check_procedure_later(c, c->curr_ast_file, empty_token, decl, type, pl->body, pl->tags); } check_close_scope(c); diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 104733e67..0eac4936b 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1657,7 +1657,6 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { if (decl->kind == AstNode_GenDecl) { switch (decl->GenDecl.token.kind) { case Token_var: - case Token_let: check_stmt(c, decl, flags); break; } @@ -1673,8 +1672,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { for_array(i, gd->specs) { AstNode *spec = gd->specs[i]; switch (gd->token.kind) { - case Token_var: - case Token_let: { + case Token_var: { ast_node(vd, ValueSpec, spec); Entity **entities = gb_alloc_array(c->allocator, Entity *, vd->names.count); @@ -1699,7 +1697,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { found = current_scope_lookup_entity(c->context.scope, str); } if (found == NULL) { - entity = make_entity_variable(c->allocator, c->context.scope, token, NULL, gd->token.kind == Token_let); + entity = make_entity_variable(c->allocator, c->context.scope, token, NULL, false); entity->identifier = name; AstNode *fl = c->context.curr_foreign_library; diff --git a/src/checker.cpp b/src/checker.cpp index 5576180a4..8d0ae001c 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1635,8 +1635,7 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes, bool is_file_sco check_arity_match(c, vs); } break; - case Token_var: - case Token_let: { + case Token_var: { if (!c->context.scope->is_file) { // NOTE(bill): local scope -> handle later and in order break; @@ -1671,7 +1670,7 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes, bool is_file_sco error(name, "A declaration's name must be an identifier, got %.*s", LIT(ast_node_strings[name->kind])); continue; } - Entity *e = make_entity_variable(c->allocator, c->context.scope, name->Ident, NULL, gd->token.kind == Token_let); + Entity *e = make_entity_variable(c->allocator, c->context.scope, name->Ident, NULL, false); e->Variable.is_thread_local = (gd->flags & VarDeclFlag_thread_local) != 0; e->identifier = name; diff --git a/src/docs.cpp b/src/docs.cpp index 6478f490f..e0f27c62c 100644 --- a/src/docs.cpp +++ b/src/docs.cpp @@ -95,7 +95,6 @@ void print_declaration(AstNode *decl) { AstNode *spec = gd->specs[spec_index]; switch(gd->token.kind) { case Token_var: - case Token_let: break; case Token_const: break; diff --git a/src/ir.cpp b/src/ir.cpp index bd3dd8b36..d5fc33174 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -5947,8 +5947,7 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) { for_array(i, gd->specs) { AstNode *spec = gd->specs[i]; switch (gd->token.kind) { - case Token_var: - case Token_let: { + case Token_var: { ast_node(vd, ValueSpec, spec); irModule *m = proc->module; diff --git a/src/parser.cpp b/src/parser.cpp index 4f5c0ef07..f395b382a 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1760,7 +1760,6 @@ void fix_advance_to_next_stmt(AstFile *f) { case Token_var: case Token_const: - case Token_let: case Token_type: case Token_proc: case Token_foreign: @@ -1902,7 +1901,6 @@ void expect_semicolon(AstFile *f, AstNode *s) { if (s->kind == AstNode_GenDecl) { switch (s->GenDecl.token.kind) { case Token_var: - case Token_let: node_string = str_lit("variable declaration"); break; case Token_const: @@ -2292,7 +2290,9 @@ AstNode *parse_operand(AstFile *f, bool lhs) { AstNode *type = parse_proc_type(f, token, &link_name); u64 tags = type->ProcType.tags; - if (f->curr_token.kind == Token_OpenBrace) { + if (allow_token(f, Token_Undef)) { + return ast_proc_lit(f, type, NULL, tags, link_name); + } else if (f->curr_token.kind == Token_OpenBrace) { if ((tags & ProcTag_foreign) != 0) { syntax_error(token, "A procedure tagged as `#foreign` cannot have a body"); } @@ -2749,7 +2749,9 @@ AstNode *parse_proc_decl(AstFile *f) { f->allow_gen_proc_type = prev_allow_gen_proc_type; - if (f->curr_token.kind == Token_OpenBrace) { + if (allow_token(f, Token_Undef)) { + body = NULL; + } else if (f->curr_token.kind == Token_OpenBrace) { if ((tags & ProcTag_foreign) != 0) { syntax_error(token, "A procedure tagged as `#foreign` cannot have a body"); } @@ -3002,7 +3004,6 @@ void parse_foreign_block_decl(AstFile *f, Array<AstNode *> *decls) { case AstNode_GenDecl: switch (decl->GenDecl.token.kind) { case Token_var: - case Token_let: array_add(decls, decl); return; } @@ -3019,7 +3020,6 @@ AstNode *parse_decl(AstFile *f) { switch (f->curr_token.kind) { case Token_var: case Token_const: - case Token_let: func = parse_value_spec; break; @@ -3088,7 +3088,6 @@ AstNode *parse_simple_stmt(AstFile *f, StmtAllowFlag flags) { switch (f->curr_token.kind) { case Token_var: case Token_const: - case Token_let: return parse_decl(f); } @@ -4247,7 +4246,6 @@ AstNode *parse_stmt(AstFile *f) { case Token_var: case Token_const: - case Token_let: case Token_proc: case Token_type: case Token_import: @@ -4287,8 +4285,7 @@ AstNode *parse_stmt(AstFile *f) { // TODO(bill): Make using statements better Token token = expect_token(f, Token_using); AstNode *decl = NULL; - if (f->curr_token.kind == Token_var || - f->curr_token.kind == Token_let) { + if (f->curr_token.kind == Token_var) { decl = parse_decl(f); expect_semicolon(f, decl); } else { @@ -4307,8 +4304,7 @@ AstNode *parse_stmt(AstFile *f) { if (decl != NULL && decl->kind == AstNode_GenDecl) { - if (decl->GenDecl.token.kind != Token_var && - decl->GenDecl.token.kind != Token_let) { + if (decl->GenDecl.token.kind != Token_var) { syntax_error(token, "`using` may only be applied to variable declarations"); return decl; } @@ -4384,8 +4380,7 @@ AstNode *parse_stmt(AstFile *f) { AstNode *s = parse_stmt(f); if (s->kind == AstNode_GenDecl) { - if (s->GenDecl.token.kind != Token_var && - s->GenDecl.token.kind != Token_let) { + if (s->GenDecl.token.kind != Token_var) { syntax_error(token, "`thread_local` may only be applied to variable declarations"); } if (f->curr_proc != NULL) { diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index c7c53a47e..61d1eccc3 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -84,7 +84,6 @@ TOKEN_KIND(Token__OperatorEnd, "_OperatorEnd"), \ \ TOKEN_KIND(Token__KeywordBegin, "_KeywordBegin"), \ TOKEN_KIND(Token_var, "var"), \ - TOKEN_KIND(Token_let, "let"), \ TOKEN_KIND(Token_const, "const"), \ TOKEN_KIND(Token_type, "type"), \ TOKEN_KIND(Token_import, "import"), \ |