fmt: use `import module` syntax
parent
2251634743
commit
233ae3f772
|
@ -3,11 +3,9 @@
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module fmt
|
module fmt
|
||||||
|
|
||||||
import (
|
import v.ast
|
||||||
v.ast
|
import v.table
|
||||||
v.table
|
import strings
|
||||||
strings
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
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']
|
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']
|
||||||
|
@ -109,16 +107,19 @@ fn (f mut Fmt) imports(imports []ast.Import) {
|
||||||
f.out_imports.writeln('import ${imp_stmt_str}\n')
|
f.out_imports.writeln('import ${imp_stmt_str}\n')
|
||||||
} else if imports.len > 1 {
|
} else if imports.len > 1 {
|
||||||
*/
|
*/
|
||||||
f.out_imports.writeln('import (')
|
// f.out_imports.writeln('import (')
|
||||||
for imp in imports {
|
for imp in imports {
|
||||||
if !(imp.mod in f.used_imports) {
|
if !(imp.mod in f.used_imports) {
|
||||||
// TODO bring back once only unused imports are removed
|
// TODO bring back once only unused imports are removed
|
||||||
// continue
|
// continue
|
||||||
}
|
}
|
||||||
f.out_imports.write('\t')
|
// f.out_imports.write('\t')
|
||||||
|
// f.out_imports.writeln(f.imp_stmt_str(imp))
|
||||||
|
f.out_imports.write('import ')
|
||||||
f.out_imports.writeln(f.imp_stmt_str(imp))
|
f.out_imports.writeln(f.imp_stmt_str(imp))
|
||||||
}
|
}
|
||||||
f.out_imports.writeln(')\n')
|
f.out_imports.writeln('')
|
||||||
|
// f.out_imports.writeln(')\n')
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import (
|
import math
|
||||||
math
|
import os
|
||||||
os
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mypi = math.pi
|
mypi = math.pi
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import (
|
import os
|
||||||
os
|
import math
|
||||||
math
|
|
||||||
)
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// println(m.pi)
|
// println(m.pi)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import (
|
import os
|
||||||
os
|
|
||||||
)
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import (
|
import time
|
||||||
time
|
|
||||||
)
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println(time.now())
|
println(time.now())
|
||||||
|
|
|
@ -3,16 +3,14 @@
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module gen
|
module gen
|
||||||
|
|
||||||
import (
|
import strings
|
||||||
strings
|
import v.ast
|
||||||
v.ast
|
import v.table
|
||||||
v.table
|
import v.pref
|
||||||
v.pref
|
import v.token
|
||||||
v.token
|
import v.util
|
||||||
v.util
|
import v.depgraph
|
||||||
v.depgraph
|
import term
|
||||||
term
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
c_reserved = ['delete', 'exit', 'unix', 'error', 'calloc', 'malloc', 'free', 'panic', 'auto',
|
c_reserved = ['delete', 'exit', 'unix', 'error', 'calloc', 'malloc', 'free', 'panic', 'auto',
|
||||||
|
@ -2200,8 +2198,8 @@ fn (g mut Gen) string_inter_literal(node ast.StringInterLiteral) {
|
||||||
verror('only V strings can be formatted with a ${sfmt} format')
|
verror('only V strings can be formatted with a ${sfmt} format')
|
||||||
}
|
}
|
||||||
g.write('%' + sfmt[1..])
|
g.write('%' + sfmt[1..])
|
||||||
} else if node.expr_types[i] in [table.string_type, table.bool_type] ||
|
} else if node.expr_types[i] in [table.string_type, table.bool_type] || sym.kind in
|
||||||
sym.kind in [.enum_, .array, .array_fixed] {
|
[.enum_, .array, .array_fixed] {
|
||||||
g.write('%.*s')
|
g.write('%.*s')
|
||||||
} else if node.expr_types[i] in [table.f32_type, table.f64_type] {
|
} else if node.expr_types[i] in [table.f32_type, table.f64_type] {
|
||||||
g.write('%f')
|
g.write('%f')
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module parser
|
module parser
|
||||||
|
|
||||||
import (
|
import v.ast
|
||||||
v.ast
|
import v.table
|
||||||
v.table
|
import v.scanner
|
||||||
v.scanner
|
import v.token
|
||||||
v.token
|
|
||||||
)
|
|
||||||
|
|
||||||
pub fn (p mut Parser) call_expr(is_c bool, mod string) ast.CallExpr {
|
pub fn (p mut Parser) call_expr(is_c bool, mod string) ast.CallExpr {
|
||||||
first_pos := p.tok.position()
|
first_pos := p.tok.position()
|
||||||
|
|
|
@ -3,16 +3,14 @@
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module parser
|
module parser
|
||||||
|
|
||||||
import (
|
import v.scanner
|
||||||
v.scanner
|
import v.ast
|
||||||
v.ast
|
import v.token
|
||||||
v.token
|
import v.table
|
||||||
v.table
|
import v.pref
|
||||||
v.pref
|
import v.util
|
||||||
v.util
|
import term
|
||||||
term
|
import os
|
||||||
os
|
|
||||||
)
|
|
||||||
|
|
||||||
struct Parser {
|
struct Parser {
|
||||||
scanner &scanner.Scanner
|
scanner &scanner.Scanner
|
||||||
|
|
Loading…
Reference in New Issue