diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index f1819d2e94..deb6758371 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -804,10 +804,10 @@ fn (mut g Gen) stmt(node ast.Stmt) { g.write_v_source_line_info(node.pos) if node.label.len > 0 { if node.kind == .key_break { - g.writeln('goto $node.label\__break;') + g.writeln('goto ${node.label}__break;') } else { // assert node.kind == .key_continue - g.writeln('goto $node.label\__continue;') + g.writeln('goto ${node.label}__continue;') } } else { // continue or break @@ -945,11 +945,11 @@ fn (mut g Gen) stmt(node ast.Stmt) { g.is_vlines_enabled = true g.stmts(node.stmts) if node.label.len > 0 { - g.writeln('$node.label\__continue: {}') + g.writeln('${node.label}__continue: {}') } g.writeln('}') if node.label.len > 0 { - g.writeln('$node.label\__break: {}') + g.writeln('${node.label}__break: {}') } } ast.ForInStmt { @@ -974,11 +974,11 @@ fn (mut g Gen) stmt(node ast.Stmt) { g.is_vlines_enabled = true g.stmts(node.stmts) if node.label.len > 0 { - g.writeln('\t$node.label\__continue: {}') + g.writeln('\t${node.label}__continue: {}') } g.writeln('}') if node.label.len > 0 { - g.writeln('$node.label\__break: {}') + g.writeln('${node.label}__break: {}') } } ast.GlobalDecl { @@ -1178,21 +1178,21 @@ fn (mut g Gen) for_in(it ast.ForInStmt) { g.write('$atmp_styp $atmp = ') g.expr(it.cond) g.writeln(';') - g.writeln('for (int $idx = 0; $idx < $atmp\.key_values.len; ++$idx) {') - g.writeln('\tif ($atmp\.key_values.keys[$idx].str == 0) {continue;}') + g.writeln('for (int $idx = 0; $idx < ${atmp}.key_values.len; ++$idx) {') + g.writeln('\tif (${atmp}.key_values.keys[$idx].str == 0) {continue;}') if it.key_var != '_' { key_styp := g.typ(it.key_type) key := c_name(it.key_var) // TODO: analyze whether it.key_type has a .clone() method and call .clone() for all types: if it.key_type == table.string_type { - g.writeln('\t$key_styp $key = /*kkkk*/ string_clone($atmp\.key_values.keys[$idx]);') + g.writeln('\t$key_styp $key = /*key*/ string_clone(${atmp}.key_values.keys[$idx]);') } else { - g.writeln('\t$key_styp $key = /*kkkk*/ $atmp\.key_values.keys[$idx];') + g.writeln('\t$key_styp $key = /*key*/ ${atmp}.key_values.keys[$idx];') } } if it.val_var != '_' { val_sym := g.table.get_type_symbol(it.val_type) - valstr := '(void*)($atmp\.key_values.values + $idx * (u32)($atmp\.value_bytes))' + valstr := '(void*)(${atmp}.key_values.values + $idx * (u32)(${atmp}.value_bytes))' if val_sym.kind == .function { g.write('\t') g.write_fn_ptr_decl(val_sym.info as table.FnType, c_name(it.val_var)) @@ -1207,11 +1207,11 @@ fn (mut g Gen) for_in(it ast.ForInStmt) { // g.writeln('string_free(&$key);') } if it.label.len > 0 { - g.writeln('\t$it.label\__continue: {}') + g.writeln('\t${it.label}__continue: {}') } g.writeln('}') if it.label.len > 0 { - g.writeln('\t$it.label\__break: {}') + g.writeln('\t${it.label}__break: {}') } return } else if it.cond_type.has_flag(.variadic) { @@ -1240,11 +1240,11 @@ fn (mut g Gen) for_in(it ast.ForInStmt) { } g.stmts(it.stmts) if it.label.len > 0 { - g.writeln('\t$it.label\__continue: {}') + g.writeln('\t${it.label}__continue: {}') } g.writeln('}') if it.label.len > 0 { - g.writeln('\t$it.label\__break: {}') + g.writeln('\t${it.label}__break: {}') } } @@ -5566,7 +5566,7 @@ fn (mut g Gen) gen_str_default(sym table.TypeSymbol, styp string, str_fn_name st convertor = 'bool' typename_ = 'bool' } else { - verror("could not generate string method for type \'$styp\'") + verror("could not generate string method for type '$styp'") } g.type_definitions.writeln('string ${str_fn_name}($styp it); // auto') g.auto_str_funcs.writeln('string ${str_fn_name}($styp it) {') diff --git a/vlib/v/gen/js/js.v b/vlib/v/gen/js/js.v index 9e7600c8c7..3668bd4973 100644 --- a/vlib/v/gen/js/js.v +++ b/vlib/v/gen/js/js.v @@ -15,8 +15,7 @@ const ( 'public', 'return', 'static', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield'] tabs = ['', '\t', '\t\t', '\t\t\t', '\t\t\t\t', '\t\t\t\t\t', '\t\t\t\t\t\t', '\t\t\t\t\t\t\t', - '\t\t\t\t\t\t\t\t', '\t\t\t\t\t\t\t\t\t', '\t\t\t\t\t\t\t\t\t', '\t\t\t\t\t\t\t\t\t' - ] + '\t\t\t\t\t\t\t\t', '\t\t\t\t\t\t\t\t\t', '\t\t\t\t\t\t\t\t\t', '\t\t\t\t\t\t\t\t\t'] ) struct JsGen { @@ -1012,8 +1011,8 @@ fn (mut g JsGen) gen_go_stmt(node ast.GoStmt) { name = receiver_sym.name + '.' + name } // todo: please add a name feild without the mod name for ast.CallExpr - if name.starts_with('$node.call_expr.mod\.') { - name = name[node.call_expr.mod.len+1..] + if name.starts_with('${node.call_expr.mod}.') { + name = name[node.call_expr.mod.len + 1..] } g.writeln('await new Promise(function(resolve){') g.inc_indent() @@ -1245,7 +1244,7 @@ fn (mut g JsGen) gen_call_expr(it ast.CallExpr) { match it.or_block.kind { .block { if it.or_block.stmts.len > 1 { - g.stmts(it.or_block.stmts[..it.or_block.stmts.len-1]) + g.stmts(it.or_block.stmts[..it.or_block.stmts.len - 1]) } g.write('return ') g.stmt(it.or_block.stmts.last()) diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index ebea4a94aa..7210d2b77e 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -580,7 +580,7 @@ fn (mut s Scanner) text_scan() token.Token { // end of `$expr` // allow `'$a.b'` and `'$a.c()'` if s.is_inter_start && next_char == `\\` && s.look_ahead(2) !in [`n`, `\\`, `t`] { - // s.warn('unknown escape sequence \\${s.look_ahead(2)}') + s.warn('unknown escape sequence \\${s.look_ahead(2)}') } if s.is_inter_start && next_char == `(` { if s.look_ahead(2) != `)` {