aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-07-20 15:17:04 +0100
committerGinger Bill <bill@gingerbill.org>2017-07-20 15:17:04 +0100
commit6d37ed12d2e9914bd308dbf2fd3dec166cc78af1 (patch)
tree50597ee875a84c1ec2f8c64d031cb9857c0c233f /src/parser.cpp
parenteab23cd5b74b9df2f5158138510b45c83bbf1bc8 (diff)
Update internals of a Union and Tuple
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 48169f4d6..090d3a46e 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -2291,34 +2291,37 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
Token token = expect_token(f, Token_proc);
String link_name = {};
AstNode *type = parse_proc_type(f, token, &link_name);
+
+ if (f->allow_type && f->expr_level < 0) {
+ return type;
+ }
+
u64 tags = type->ProcType.tags;
if (allow_token(f, Token_Undef)) {
return ast_proc_lit(f, type, nullptr, tags, link_name);
- } else if (!f->allow_type || f->expr_level >= 0) {
- if (f->curr_token.kind == Token_OpenBrace) {
- if ((tags & ProcTag_foreign) != 0) {
- syntax_error(token, "A procedure tagged as `#foreign` cannot have a body");
- }
- AstNode *curr_proc = f->curr_proc;
- AstNode *body = nullptr;
- f->curr_proc = type;
- body = parse_body(f);
- f->curr_proc = curr_proc;
-
- return ast_proc_lit(f, type, body, tags, link_name);
- } else if (allow_token(f, Token_do)) {
- if ((tags & ProcTag_foreign) != 0) {
- syntax_error(token, "A procedure tagged as `#foreign` cannot have a body");
- }
- AstNode *curr_proc = f->curr_proc;
- AstNode *body = nullptr;
- f->curr_proc = type;
- body = convert_stmt_to_body(f, parse_stmt(f));
- f->curr_proc = curr_proc;
-
- return ast_proc_lit(f, type, body, 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");
+ }
+ AstNode *curr_proc = f->curr_proc;
+ AstNode *body = nullptr;
+ f->curr_proc = type;
+ body = parse_body(f);
+ f->curr_proc = curr_proc;
+
+ return ast_proc_lit(f, type, body, tags, link_name);
+ } else if (allow_token(f, Token_do)) {
+ if ((tags & ProcTag_foreign) != 0) {
+ syntax_error(token, "A procedure tagged as `#foreign` cannot have a body");
}
+ AstNode *curr_proc = f->curr_proc;
+ AstNode *body = nullptr;
+ f->curr_proc = type;
+ body = convert_stmt_to_body(f, parse_stmt(f));
+ f->curr_proc = curr_proc;
+
+ return ast_proc_lit(f, type, body, tags, link_name);
}
if ((tags & ProcTag_foreign) != 0) {