From 6acc354957752e2cfa8d67bdd0e4c3b42f9be3c3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 20 Apr 2016 11:58:01 -0700 Subject: for loop: add ability to get pointer to elem var see #51 --- src/parser.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/parser.cpp') 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); -- cgit v1.2.3