array syntax is [10]i32 instead of [i32; 10]

This commit is contained in:
Andrew Kelley
2016-01-05 22:47:47 -07:00
parent e21a83dd74
commit 4ef062b9c8
7 changed files with 24 additions and 32 deletions

View File

@@ -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.array_size = ast_parse_expression(pc, token_index, false);
ast_eat_token(pc, token_index, TokenIdRBracket);
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, true);
Token *rbracket_token = &pc->tokens->at(*token_index);
*token_index += 1;
ast_expect_token(pc, rbracket_token, TokenIdRBracket);
} else {
ast_invalid_token_error(pc, token);
}