diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-07-08 23:13:57 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-07-08 23:13:57 +0100 |
| commit | b201670f7af595c58f398a5ba608b925b1f939ac (patch) | |
| tree | a0dbdb4faa0d27605108ff8c0156bacdb3a56658 /src/parser.cpp | |
| parent | 4b051a0d3b9da924924ed2a28ef7c102902a880c (diff) | |
Fix _preload.odin; Add for in without parameters; Change sync.Mutex for windows
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index b52fb21b7..c2286e25b 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -3992,7 +3992,25 @@ AstNode *parse_for_stmt(AstFile *f) { if (f->curr_token.kind != Token_OpenBrace && f->curr_token.kind != Token_do) { isize prev_level = f->expr_level; + defer (f->expr_level = prev_level); f->expr_level = -1; + + if (f->curr_token.kind == Token_in) { + Token in_token = expect_token(f, Token_in); + AstNode *rhs = nullptr; + bool prev_allow_range = f->allow_range; + f->allow_range = true; + rhs = parse_expr(f, false); + f->allow_range = prev_allow_range; + + if (allow_token(f, Token_do)) { + body = convert_stmt_to_body(f, parse_stmt(f)); + } else { + body = parse_block_stmt(f, false); + } + return ast_range_stmt(f, token, nullptr, nullptr, in_token, rhs, body); + } + if (f->curr_token.kind != Token_Semicolon) { cond = parse_simple_stmt(f, StmtAllowFlag_In); if (cond->kind == AstNode_AssignStmt && cond->AssignStmt.op.kind == Token_in) { @@ -4014,7 +4032,6 @@ AstNode *parse_for_stmt(AstFile *f) { } } - f->expr_level = prev_level; } if (allow_token(f, Token_do)) { |