aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-05 22:47:47 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-05 22:47:47 -0700
commit4ef062b9c819a2d7bfa9dd3394713ac9e8051660 (patch)
treecae97813bd1925ea7e18f96dc33fde913d161066 /src/parser.cpp
parente21a83dd74822d9d8b272079a2e0e0b01aff60d4 (diff)
downloadzig-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.cpp14
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);
}