From e56bf42270f814d23b89a38555f035c562357bb3 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 20 Feb 2020 20:30:34 +0100 Subject: [PATCH] v2: xor, for x = ... --- vlib/builtin/map.v | 7 +++++-- vlib/v/parser/parser.v | 3 +++ vlib/v/token/token.v | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/vlib/builtin/map.v b/vlib/builtin/map.v index e36364d193..f493caf679 100644 --- a/vlib/builtin/map.v +++ b/vlib/builtin/map.v @@ -108,7 +108,10 @@ fn (m mut map) set(key string, value voidptr) { // Match is not possible anymore. // Probe until an empty index is found. // Swap when probe count is higher/richer (Robin Hood). - mut current_kv := KeyValue{key, malloc(m.value_bytes)} + mut current_kv := KeyValue{ + key:key + value:malloc(m.value_bytes) + } C.memcpy(current_kv.value, value, m.value_bytes) for m.probe_hash[index] != 0 { if probe_hash > m.probe_hash[index] { @@ -371,4 +374,4 @@ pub fn (m map_string) str() string { } sb.writeln('}') return sb.str() -} \ No newline at end of file +} diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 118d32a42c..f08b9b0426 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -917,6 +917,9 @@ fn (p mut Parser) for_statement() ast.Stmt { if p.peek_tok.kind == .decl_assign { init = p.var_decl() } + else if p.peek_tok.kind == .assign { + init = p.assign_stmt() + } else if p.tok.kind != .semicolon {} // allow `for ;; i++ {` // Allow `for i = 0; i < ...` diff --git a/vlib/v/token/token.v b/vlib/v/token/token.v index ff2dc3f0f0..3297ae8f99 100644 --- a/vlib/v/token/token.v +++ b/vlib/v/token/token.v @@ -480,7 +480,7 @@ pub fn (k Kind) is_start_of_type() bool { pub fn (kind Kind) is_infix() bool { return kind in [.plus, .minus, .mod, .mul, .div, .eq, .ne, .gt, .lt, .key_in, // - .key_as, .ge, .le, .logical_or, + .key_as, .ge, .le, .logical_or, .xor, // .and, .dot, .pipe, .amp, .left_shift, .right_shift] }