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 | |
| parent | 4b051a0d3b9da924924ed2a28ef7c102902a880c (diff) | |
Fix _preload.odin; Add for in without parameters; Change sync.Mutex for windows
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.cpp | 19 | ||||
| -rw-r--r-- | src/tokenizer.cpp | 6 |
2 files changed, 21 insertions, 4 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)) { diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 31d1e8933..b1fff3305 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -94,14 +94,14 @@ TOKEN_KIND(Token__KeywordBegin, "_KeywordBegin"), \ TOKEN_KIND(Token_if, "if"), \ TOKEN_KIND(Token_else, "else"), \ TOKEN_KIND(Token_for, "for"), \ - TOKEN_KIND(Token_in, "in"), \ TOKEN_KIND(Token_match, "match"), \ + TOKEN_KIND(Token_in, "in"), \ + TOKEN_KIND(Token_do, "do"), \ TOKEN_KIND(Token_case, "case"), \ TOKEN_KIND(Token_break, "break"), \ TOKEN_KIND(Token_continue, "continue"), \ TOKEN_KIND(Token_fallthrough, "fallthrough"), \ TOKEN_KIND(Token_defer, "defer"), \ - TOKEN_KIND(Token_do, "do"), \ TOKEN_KIND(Token_return, "return"), \ TOKEN_KIND(Token_proc, "proc"), \ TOKEN_KIND(Token_macro, "macro"), \ @@ -111,9 +111,9 @@ TOKEN_KIND(Token__KeywordBegin, "_KeywordBegin"), \ TOKEN_KIND(Token_enum, "enum"), \ TOKEN_KIND(Token_bit_field, "bit_field"), \ TOKEN_KIND(Token_vector, "vector"), \ + TOKEN_KIND(Token_map, "map"), \ TOKEN_KIND(Token_static, "static"), \ TOKEN_KIND(Token_dynamic, "dynamic"), \ - TOKEN_KIND(Token_map, "map"), \ TOKEN_KIND(Token_using, "using"), \ TOKEN_KIND(Token_context, "context"), \ TOKEN_KIND(Token_push_context, "push_context"), \ |