diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-05 22:47:47 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-05 22:47:47 -0700 |
| commit | 4ef062b9c819a2d7bfa9dd3394713ac9e8051660 (patch) | |
| tree | cae97813bd1925ea7e18f96dc33fde913d161066 /src/parser.cpp | |
| parent | e21a83dd74822d9d8b272079a2e0e0b01aff60d4 (diff) | |
| download | zig-4ef062b9c819a2d7bfa9dd3394713ac9e8051660.tar.gz zig-4ef062b9c819a2d7bfa9dd3394713ac9e8051660.zip | |
array syntax is [10]i32 instead of [i32; 10]
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 60de2fbab7..36038a3bc2 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1062,7 +1062,7 @@ static AstNode *ast_parse_compiler_fn_call(ParseContext *pc, int *token_index, b /* Type : token(Symbol) | token(Unreachable) | token(Void) | PointerType | ArrayType | MaybeType | CompilerFnExpr PointerType : token(Ampersand) option(token(Const)) Type -ArrayType : token(LBracket) Type token(Semicolon) token(Number) token(RBracket) +ArrayType : token(LBracket) option(Expression) token(RBracket) Type */ static AstNode *ast_parse_type(ParseContext *pc, int *token_index) { Token *token = &pc->tokens->at(*token_index); @@ -1103,17 +1103,11 @@ static AstNode *ast_parse_type(ParseContext *pc, int *token_index) { } else if (token->id == TokenIdLBracket) { node->data.type.type = AstNodeTypeTypeArray; - node->data.type.child_type = ast_parse_type(pc, token_index); - - Token *semicolon_token = &pc->tokens->at(*token_index); - *token_index += 1; - ast_expect_token(pc, semicolon_token, TokenIdSemicolon); + node->data.type.array_size = ast_parse_expression(pc, token_index, false); - node->data.type.array_size = ast_parse_expression(pc, token_index, true); + ast_eat_token(pc, token_index, TokenIdRBracket); - Token *rbracket_token = &pc->tokens->at(*token_index); - *token_index += 1; - ast_expect_token(pc, rbracket_token, TokenIdRBracket); + node->data.type.child_type = ast_parse_type(pc, token_index); } else { ast_invalid_token_error(pc, token); } |
