Skip to content

Commit c27818e

Browse files
committed
all: remove remaining broken escape sequences
1 parent 966b95c commit c27818e

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

vlib/v/gen/cgen.v

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,10 @@ fn (mut g Gen) stmt(node ast.Stmt) {
804804
g.write_v_source_line_info(node.pos)
805805
if node.label.len > 0 {
806806
if node.kind == .key_break {
807-
g.writeln('goto $node.label\__break;')
807+
g.writeln('goto ${node.label}__break;')
808808
} else {
809809
// assert node.kind == .key_continue
810-
g.writeln('goto $node.label\__continue;')
810+
g.writeln('goto ${node.label}__continue;')
811811
}
812812
} else {
813813
// continue or break
@@ -945,11 +945,11 @@ fn (mut g Gen) stmt(node ast.Stmt) {
945945
g.is_vlines_enabled = true
946946
g.stmts(node.stmts)
947947
if node.label.len > 0 {
948-
g.writeln('$node.label\__continue: {}')
948+
g.writeln('${node.label}__continue: {}')
949949
}
950950
g.writeln('}')
951951
if node.label.len > 0 {
952-
g.writeln('$node.label\__break: {}')
952+
g.writeln('${node.label}__break: {}')
953953
}
954954
}
955955
ast.ForInStmt {
@@ -974,11 +974,11 @@ fn (mut g Gen) stmt(node ast.Stmt) {
974974
g.is_vlines_enabled = true
975975
g.stmts(node.stmts)
976976
if node.label.len > 0 {
977-
g.writeln('\t$node.label\__continue: {}')
977+
g.writeln('\t${node.label}__continue: {}')
978978
}
979979
g.writeln('}')
980980
if node.label.len > 0 {
981-
g.writeln('$node.label\__break: {}')
981+
g.writeln('${node.label}__break: {}')
982982
}
983983
}
984984
ast.GlobalDecl {
@@ -1178,21 +1178,21 @@ fn (mut g Gen) for_in(it ast.ForInStmt) {
11781178
g.write('$atmp_styp $atmp = ')
11791179
g.expr(it.cond)
11801180
g.writeln(';')
1181-
g.writeln('for (int $idx = 0; $idx < $atmp\.key_values.len; ++$idx) {')
1182-
g.writeln('\tif ($atmp\.key_values.keys[$idx].str == 0) {continue;}')
1181+
g.writeln('for (int $idx = 0; $idx < ${atmp}.key_values.len; ++$idx) {')
1182+
g.writeln('\tif (${atmp}.key_values.keys[$idx].str == 0) {continue;}')
11831183
if it.key_var != '_' {
11841184
key_styp := g.typ(it.key_type)
11851185
key := c_name(it.key_var)
11861186
// TODO: analyze whether it.key_type has a .clone() method and call .clone() for all types:
11871187
if it.key_type == table.string_type {
1188-
g.writeln('\t$key_styp $key = /*kkkk*/ string_clone($atmp\.key_values.keys[$idx]);')
1188+
g.writeln('\t$key_styp $key = /*key*/ string_clone(${atmp}.key_values.keys[$idx]);')
11891189
} else {
1190-
g.writeln('\t$key_styp $key = /*kkkk*/ $atmp\.key_values.keys[$idx];')
1190+
g.writeln('\t$key_styp $key = /*key*/ ${atmp}.key_values.keys[$idx];')
11911191
}
11921192
}
11931193
if it.val_var != '_' {
11941194
val_sym := g.table.get_type_symbol(it.val_type)
1195-
valstr := '(void*)($atmp\.key_values.values + $idx * (u32)($atmp\.value_bytes))'
1195+
valstr := '(void*)(${atmp}.key_values.values + $idx * (u32)(${atmp}.value_bytes))'
11961196
if val_sym.kind == .function {
11971197
g.write('\t')
11981198
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) {
12071207
// g.writeln('string_free(&$key);')
12081208
}
12091209
if it.label.len > 0 {
1210-
g.writeln('\t$it.label\__continue: {}')
1210+
g.writeln('\t${it.label}__continue: {}')
12111211
}
12121212
g.writeln('}')
12131213
if it.label.len > 0 {
1214-
g.writeln('\t$it.label\__break: {}')
1214+
g.writeln('\t${it.label}__break: {}')
12151215
}
12161216
return
12171217
} else if it.cond_type.has_flag(.variadic) {
@@ -1240,11 +1240,11 @@ fn (mut g Gen) for_in(it ast.ForInStmt) {
12401240
}
12411241
g.stmts(it.stmts)
12421242
if it.label.len > 0 {
1243-
g.writeln('\t$it.label\__continue: {}')
1243+
g.writeln('\t${it.label}__continue: {}')
12441244
}
12451245
g.writeln('}')
12461246
if it.label.len > 0 {
1247-
g.writeln('\t$it.label\__break: {}')
1247+
g.writeln('\t${it.label}__break: {}')
12481248
}
12491249
}
12501250

@@ -5566,7 +5566,7 @@ fn (mut g Gen) gen_str_default(sym table.TypeSymbol, styp string, str_fn_name st
55665566
convertor = 'bool'
55675567
typename_ = 'bool'
55685568
} else {
5569-
verror("could not generate string method for type \'$styp\'")
5569+
verror("could not generate string method for type '$styp'")
55705570
}
55715571
g.type_definitions.writeln('string ${str_fn_name}($styp it); // auto')
55725572
g.auto_str_funcs.writeln('string ${str_fn_name}($styp it) {')

vlib/v/gen/js/js.v

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ const (
1515
'public', 'return', 'static', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void',
1616
'while', 'with', 'yield']
1717
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',
18-
'\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'
19-
]
18+
'\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']
2019
)
2120

2221
struct JsGen {
@@ -1012,8 +1011,8 @@ fn (mut g JsGen) gen_go_stmt(node ast.GoStmt) {
10121011
name = receiver_sym.name + '.' + name
10131012
}
10141013
// todo: please add a name feild without the mod name for ast.CallExpr
1015-
if name.starts_with('$node.call_expr.mod\.') {
1016-
name = name[node.call_expr.mod.len+1..]
1014+
if name.starts_with('${node.call_expr.mod}.') {
1015+
name = name[node.call_expr.mod.len + 1..]
10171016
}
10181017
g.writeln('await new Promise(function(resolve){')
10191018
g.inc_indent()
@@ -1245,7 +1244,7 @@ fn (mut g JsGen) gen_call_expr(it ast.CallExpr) {
12451244
match it.or_block.kind {
12461245
.block {
12471246
if it.or_block.stmts.len > 1 {
1248-
g.stmts(it.or_block.stmts[..it.or_block.stmts.len-1])
1247+
g.stmts(it.or_block.stmts[..it.or_block.stmts.len - 1])
12491248
}
12501249
g.write('return ')
12511250
g.stmt(it.or_block.stmts.last())

vlib/v/scanner/scanner.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ fn (mut s Scanner) text_scan() token.Token {
580580
// end of `$expr`
581581
// allow `'$a.b'` and `'$a.c()'`
582582
if s.is_inter_start && next_char == `\\` && s.look_ahead(2) !in [`n`, `\\`, `t`] {
583-
// s.warn('unknown escape sequence \\${s.look_ahead(2)}')
583+
s.warn('unknown escape sequence \\${s.look_ahead(2)}')
584584
}
585585
if s.is_inter_start && next_char == `(` {
586586
if s.look_ahead(2) != `)` {

0 commit comments

Comments
 (0)