From 97490c6445cb3ba85f470e64e6ed6d24394c421a Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 29 May 2023 23:17:06 +0100 Subject: Basic support for `#reverse for in` on normal arrays --- src/parser.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 1b48dce87..afdb1078d 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -4759,6 +4759,17 @@ gb_internal Ast *parse_stmt(AstFile *f) { return stmt; } else if (tag == "unroll") { return parse_unrolled_for_loop(f, name); + } else if (tag == "reverse") { + Ast *for_stmt = parse_for_stmt(f); + if (for_stmt->kind == Ast_RangeStmt) { + if (for_stmt->RangeStmt.reverse) { + syntax_error(token, "#reverse already applied to a 'for in' statement"); + } + for_stmt->RangeStmt.reverse = true; + } else { + syntax_error(token, "#reverse can only be applied to a 'for in' statement"); + } + return for_stmt; } else if (tag == "include") { syntax_error(token, "#include is not a valid import declaration kind. Did you mean 'import'?"); s = ast_bad_stmt(f, token, f->curr_token); -- cgit v1.2.3