diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-04-20 11:58:01 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-04-20 11:58:01 -0700 |
| commit | 6acc354957752e2cfa8d67bdd0e4c3b42f9be3c3 (patch) | |
| tree | df6c6511e3ded50d1be9d59940d093a3470b93b4 /src/parser.cpp | |
| parent | a25307c0a1b45d0c7b83158349fbc57626baf656 (diff) | |
| download | zig-6acc354957752e2cfa8d67bdd0e4c3b42f9be3c3.tar.gz zig-6acc354957752e2cfa8d67bdd0e4c3b42f9be3c3.zip | |
for loop: add ability to get pointer to elem var
see #51
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 37b062e522..29a65521d7 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1932,7 +1932,7 @@ static AstNode *ast_parse_symbol(ParseContext *pc, int *token_index) { } /* -ForExpression = "for" "(" Expression ")" option("|" "Symbol" option("," "Symbol") "|") Expression +ForExpression = "for" "(" Expression ")" option("|" option("*") "Symbol" option("," "Symbol") "|") Expression */ static AstNode *ast_parse_for_expr(ParseContext *pc, int *token_index, bool mandatory) { Token *token = &pc->tokens->at(*token_index); @@ -1955,6 +1955,13 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, int *token_index, bool mand Token *maybe_bar = &pc->tokens->at(*token_index); if (maybe_bar->id == TokenIdBinOr) { *token_index += 1; + + Token *maybe_star = &pc->tokens->at(*token_index); + if (maybe_star->id == TokenIdStar) { + *token_index += 1; + node->data.for_expr.elem_is_ptr = true; + } + node->data.for_expr.elem_node = ast_parse_symbol(pc, token_index); Token *maybe_comma = &pc->tokens->at(*token_index); |
