diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-01-01 18:18:43 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-01-01 18:18:43 +0000 |
| commit | 3f1195cd03ac009eee508b7d0e086807507a0ef4 (patch) | |
| tree | 28d6b4c7af854adfe336b06cea7167b8a7e8abab /src/parser.c | |
| parent | 311b5cb6e211aa49d8dc0e081173204d7271964f (diff) | |
More declaration differentiation in semantic stage e.g. make only variables and constants
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/parser.c b/src/parser.c index 2d61c9e92..12144462c 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1740,31 +1740,25 @@ AstNode *parse_operand(AstFile *f, bool lhs) { // Parse Procedure Type or Literal case Token_proc: { + Token token = f->curr_token; String foreign_name = {0}; String link_name = {0}; - AstNode *curr_proc = f->curr_proc; AstNode *type = parse_proc_type(f, &foreign_name, &link_name); - f->curr_proc = type; - - if (type->ProcType.tags & ProcTag_foreign) { - syntax_error(f->curr_token, "#foreign cannot be applied to procedure literals"); - } - if (type->ProcType.tags & ProcTag_export) { - syntax_error(f->curr_token, "#export cannot be applied to procedure literals"); - } if (f->curr_token.kind == Token_OpenBrace) { - AstNode *body; + u64 tags = type->ProcType.tags; - if ((type->ProcType.tags & ProcTag_foreign) != 0) { - syntax_error(f->curr_token, "A procedure tagged as `#foreign` cannot have a body"); + if ((tags & ProcTag_foreign) != 0) { + syntax_error(token, "A procedure tagged as `#foreign` cannot have a body"); } + AstNode *curr_proc = f->curr_proc; + f->curr_proc = type; + AstNode *body = parse_body(f); + f->curr_proc = curr_proc; - body = parse_body(f); - type = make_proc_lit(f, type, body, type->ProcType.tags, foreign_name, link_name); + return make_proc_lit(f, type, body, tags, foreign_name, link_name); } - f->curr_proc = curr_proc; return type; } @@ -1941,7 +1935,15 @@ AstNode *parse_type(AstFile *f); AstNode *parse_unary_expr(AstFile *f, bool lhs) { switch (f->curr_token.kind) { - case Token_Pointer: + case Token_Pointer: { + Token op = f->curr_token; + next_token(f); + AstNode *expr = parse_unary_expr(f, lhs); + if (is_ast_node_type(expr)) { + return make_pointer_type(f, op, expr); + } + return make_unary_expr(f, op, expr); + } break; case Token_Maybe: case Token_Add: case Token_Sub: |