run vfmt on fn.v
parent
81045023c4
commit
569b32bd1e
3
v.v
3
v.v
|
@ -21,9 +21,8 @@ const (
|
||||||
fn main() {
|
fn main() {
|
||||||
//t := time.ticks()
|
//t := time.ticks()
|
||||||
//defer { println(time.ticks() - t) }
|
//defer { println(time.ticks() - t) }
|
||||||
// There's no `flags` module yet, so args have to be parsed manually
|
|
||||||
args := compiler.env_vflags_and_os_args()
|
args := compiler.env_vflags_and_os_args()
|
||||||
options, command := compiler.get_v_options_and_main_command( args )
|
options, command := compiler.get_v_options_and_main_command( args )
|
||||||
// external tool
|
// external tool
|
||||||
if command in simple_tools {
|
if command in simple_tools {
|
||||||
compiler.launch_tool('v' + command)
|
compiler.launch_tool('v' + command)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1159,6 +1159,20 @@ pub fn vfmt(args[]string) {
|
||||||
println('v fmt can only be used on .v files')
|
println('v fmt can only be used on .v files')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
println('WIP')
|
||||||
|
/*
|
||||||
|
vexe := vexe_path()
|
||||||
|
//launch_tool('vfmt', '-d vfmt')
|
||||||
|
vroot := os.dir(vexe)
|
||||||
|
os.chdir(vroot)
|
||||||
|
ret := os.system('$vexe -o $vroot/tools/vfmt -d vfmt v.v')
|
||||||
|
if ret != 0 {
|
||||||
|
println('err')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
os.exec('$vroot/tools/vfmt $file') or { panic(err) }
|
||||||
|
//if !os.exists('
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_symlink() {
|
pub fn create_symlink() {
|
||||||
|
|
|
@ -853,6 +853,9 @@ fn (p &Parser) strtok() string {
|
||||||
return p.lit
|
return p.lit
|
||||||
}
|
}
|
||||||
if p.tok == .chartoken {
|
if p.tok == .chartoken {
|
||||||
|
if p.lit == '`' {
|
||||||
|
return '`\\$p.lit`'
|
||||||
|
}
|
||||||
return '`$p.lit`'
|
return '`$p.lit`'
|
||||||
}
|
}
|
||||||
if p.tok == .str {
|
if p.tok == .str {
|
||||||
|
@ -964,7 +967,7 @@ fn (p mut Parser) get_type() string {
|
||||||
// Register anon fn type
|
// Register anon fn type
|
||||||
fn_typ := Type{
|
fn_typ := Type{
|
||||||
name: f.typ_str() // 'fn (int, int) string'
|
name: f.typ_str() // 'fn (int, int) string'
|
||||||
|
|
||||||
mod: p.mod
|
mod: p.mod
|
||||||
func: f
|
func: f
|
||||||
}
|
}
|
||||||
|
@ -2902,6 +2905,7 @@ fn (p mut Parser) attribute() {
|
||||||
|
|
||||||
fn (p mut Parser) defer_st() {
|
fn (p mut Parser) defer_st() {
|
||||||
p.check(.key_defer)
|
p.check(.key_defer)
|
||||||
|
p.fspace()
|
||||||
p.check(.lcbr)
|
p.check(.lcbr)
|
||||||
pos := p.cgen.lines.len
|
pos := p.cgen.lines.len
|
||||||
// Save everything inside the defer block to `defer_text`.
|
// Save everything inside the defer block to `defer_text`.
|
||||||
|
|
|
@ -75,8 +75,6 @@ fn new_scanner_file(file_path string) &Scanner {
|
||||||
fn new_scanner(text string) &Scanner {
|
fn new_scanner(text string) &Scanner {
|
||||||
return &Scanner{
|
return &Scanner{
|
||||||
text: text
|
text: text
|
||||||
// fmt_out: strings.new_builder(1000)
|
|
||||||
|
|
||||||
print_line_on_error: true
|
print_line_on_error: true
|
||||||
print_colored_error: true
|
print_colored_error: true
|
||||||
print_rel_paths_on_error: true
|
print_rel_paths_on_error: true
|
||||||
|
|
|
@ -243,16 +243,16 @@ fn (p &Parser) gen_fmt() {
|
||||||
if s == '' {
|
if s == '' {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !p.file_name.contains('scanner.v') {return}
|
if !p.file_name.contains('fn.v') {return}
|
||||||
path := os.tmpdir() + '/' + p.file_name
|
path := os.tmpdir() + '/' + p.file_name
|
||||||
println('generating ${path}')
|
println('generating ${path}')
|
||||||
mut out := os.create(path) or {
|
mut out := os.create(path) or {
|
||||||
verror('failed to create fmt.v')
|
verror('failed to create fmt.v')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
println('replacing ${p.file_path}...')
|
println('replacing ${p.file_path}...\n')
|
||||||
os.mv(path, p.file_path)
|
|
||||||
out.writeln(s)//p.scanner.fmt_out.str().trim_space())
|
out.writeln(s)//p.scanner.fmt_out.str().trim_space())
|
||||||
out.close()
|
out.close()
|
||||||
|
os.mv(path, p.file_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue