diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.cpp | 14 | ||||
| -rw-r--r-- | src/parser.hpp | 2 |
2 files changed, 5 insertions, 11 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); } diff --git a/src/parser.hpp b/src/parser.hpp index 52cbf3e37d..8a3246fb33 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -106,7 +106,7 @@ struct AstNodeType { AstNodeTypeType type; Buf primitive_name; AstNode *child_type; - AstNode *array_size; + AstNode *array_size; // can be null bool is_const; AstNode *compiler_expr; }; |
