diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-07-29 13:01:28 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-07-29 13:01:28 +0100 |
| commit | 3546391311d84376a758ee0fcc806e192d6a18ce (patch) | |
| tree | f8b68340491e86192b8acbe6e7287a8236fed127 /src/parser.cpp | |
| parent | 24c812115e8cbc905b1a5c1d73182da5db94dfde (diff) | |
| parent | 28be0ad69b98868c5a77f0fe9d2898391b1ac400 (diff) | |
Merge branch 'master' of https://github.com/gingerBill/Odin
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index b24aea6cf..3612efe64 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -3250,12 +3250,22 @@ AstNode *parse_value_decl(AstFile *f, Array<AstNode *> names, CommentGroup docs) Array<AstNode *> values = {}; Token colon = expect_token_after(f, Token_Colon, "identifier list"); - type = parse_type_attempt(f); + if (f->curr_token.kind == Token_type) { + type = ast_type_type(f, advance_token(f), nullptr); + is_mutable = false; + } else { + type = parse_type_attempt(f); + } if (f->curr_token.kind == Token_Eq || f->curr_token.kind == Token_Colon) { - Token sep = advance_token(f); - is_mutable = sep.kind != Token_Colon; + Token sep = {}; + if (!is_mutable) { + sep = expect_token_after(f, Token_Colon, "type"); + } else { + sep = advance_token(f); + is_mutable = sep.kind != Token_Colon; + } values = parse_rhs_expr_list(f); if (values.count > names.count) { syntax_error(f->curr_token, "Too many values on the right hand side of the declaration"); |