fmt: fix formatting backtick char literal
parent
c4f672454f
commit
50491670af
|
@ -40,15 +40,11 @@ pub fn fmt(file ast.File, table &table.Table) string {
|
||||||
}
|
}
|
||||||
f.cur_mod = 'main'
|
f.cur_mod = 'main'
|
||||||
for stmt in file.stmts {
|
for stmt in file.stmts {
|
||||||
// TODO `if stmt is ast.Import`
|
if stmt is ast.Import {
|
||||||
match stmt {
|
|
||||||
ast.Import {
|
|
||||||
// Just remember the position of the imports for now
|
// Just remember the position of the imports for now
|
||||||
f.import_pos = f.out.len
|
f.import_pos = f.out.len
|
||||||
// f.imports(f.file.imports)
|
// f.imports(f.file.imports)
|
||||||
}
|
}
|
||||||
else {}
|
|
||||||
}
|
|
||||||
f.stmt(stmt)
|
f.stmt(stmt)
|
||||||
}
|
}
|
||||||
// for comment in file.comments { println('$comment.line_nr $comment.text') }
|
// for comment in file.comments { println('$comment.line_nr $comment.text') }
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
fn char_backtick() {
|
||||||
|
`\``
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ fn fn_variadic(arg int, args ...string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fn_with_assign_stmts() {
|
fn fn_with_assign_stmts() {
|
||||||
a, b := fn_with_multi_return()
|
_, _ := fn_with_multi_return()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fn_with_multi_return() (int, string) {
|
fn fn_with_multi_return() (int, string) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ fn fn_variadic(arg int, args... string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fn_with_assign_stmts() {
|
fn fn_with_assign_stmts() {
|
||||||
a,b := fn_with_multi_return()
|
_,_ := fn_with_multi_return()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fn_with_multi_return() (int,string) {
|
fn fn_with_multi_return() (int,string) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ fn for_in_loop() {
|
||||||
|
|
||||||
fn for_in_loop_with_counter() {
|
fn for_in_loop_with_counter() {
|
||||||
for i, item in arr {
|
for i, item in arr {
|
||||||
|
println(i)
|
||||||
println(item)
|
println(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ fn for_in_loop() {
|
||||||
|
|
||||||
fn for_in_loop_with_counter() {
|
fn for_in_loop_with_counter() {
|
||||||
for i, item in arr {
|
for i, item in arr {
|
||||||
|
println(i)
|
||||||
println(item)
|
println(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -929,9 +929,6 @@ fn (s mut Scanner) ident_char() string {
|
||||||
s.error('invalid character literal (more than one character)\n' + 'use quotes for strings, backticks for characters')
|
s.error('invalid character literal (more than one character)\n' + 'use quotes for strings, backticks for characters')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c == '\\`' {
|
|
||||||
return '`'
|
|
||||||
}
|
|
||||||
// Escapes a `'` character
|
// Escapes a `'` character
|
||||||
return if c == "\'" { '\\' + c } else { c }
|
return if c == "\'" { '\\' + c } else { c }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue