mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
small vfmt fixes
This commit is contained in:
parent
749d3ec14d
commit
b76227b781
2
Makefile
2
Makefile
@ -36,7 +36,7 @@ TCCREPO := https://github.com/vlang/tccbin_win
|
|||||||
VCFILE := v_win.c
|
VCFILE := v_win.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: latest_vc
|
all: latest_vc latest_tcc
|
||||||
ifdef WIN32
|
ifdef WIN32
|
||||||
$(CC) -std=c99 -w -o v0.exe $(TMPVC)/$(VCFILE) $(LDFLAGS)
|
$(CC) -std=c99 -w -o v0.exe $(TMPVC)/$(VCFILE) $(LDFLAGS)
|
||||||
./v0.exe -o v.exe v.v
|
./v0.exe -o v.exe v.v
|
||||||
|
@ -1056,7 +1056,7 @@ pub fn new_v(args []string) &V {
|
|||||||
is_live: '-live' in args
|
is_live: '-live' in args
|
||||||
sanitize: '-sanitize' in args
|
sanitize: '-sanitize' in args
|
||||||
// nofmt: '-nofmt' in args
|
// nofmt: '-nofmt' in args
|
||||||
|
|
||||||
show_c_cmd: '-show_c_cmd' in args
|
show_c_cmd: '-show_c_cmd' in args
|
||||||
translated: 'translated' in args
|
translated: 'translated' in args
|
||||||
is_run: 'run' in args
|
is_run: 'run' in args
|
||||||
@ -1075,7 +1075,7 @@ pub fn new_v(args []string) &V {
|
|||||||
building_v: !is_repl && (rdir_name == 'compiler' || rdir_name == 'v.v' || dir.contains('vlib'))
|
building_v: !is_repl && (rdir_name == 'compiler' || rdir_name == 'v.v' || dir.contains('vlib'))
|
||||||
comptime_define: comptime_define
|
comptime_define: comptime_define
|
||||||
// is_fmt: comptime_define == 'vfmt'
|
// is_fmt: comptime_define == 'vfmt'
|
||||||
|
|
||||||
user_mod_path: user_mod_path
|
user_mod_path: user_mod_path
|
||||||
vlib_path: vlib_path
|
vlib_path: vlib_path
|
||||||
vpath: vpath
|
vpath: vpath
|
||||||
|
@ -586,6 +586,7 @@ fn (p mut Parser) parse(pass Pass) {
|
|||||||
for i := start; i < end; i++ {
|
for i := start; i < end; i++ {
|
||||||
p.cgen.lines[i] = ''
|
p.cgen.lines[i] = ''
|
||||||
}
|
}
|
||||||
|
p.fgen_nl()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p.error('unexpected token `${p.strtok()}`')
|
p.error('unexpected token `${p.strtok()}`')
|
||||||
@ -793,6 +794,9 @@ fn (p mut Parser) type_decl() {
|
|||||||
cat: .alias
|
cat: .alias
|
||||||
is_public: is_pub
|
is_public: is_pub
|
||||||
})
|
})
|
||||||
|
if p.tok != .key_type {
|
||||||
|
p.fspace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// current token is `(`
|
// current token is `(`
|
||||||
@ -980,7 +984,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
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,7 @@ fn (p mut Parser) fgen_nl() {
|
|||||||
// Previous token is a comment, and NL has already been generated?
|
// Previous token is a comment, and NL has already been generated?
|
||||||
// Don't generate a second NL.
|
// Don't generate a second NL.
|
||||||
if p.scanner.fmt_lines.len > 0 && p.scanner.fmt_lines.last() == '\n' &&
|
if p.scanner.fmt_lines.len > 0 && p.scanner.fmt_lines.last() == '\n' &&
|
||||||
|
p.token_idx > 2 &&
|
||||||
p.tokens[p.token_idx-2].tok == .line_comment
|
p.tokens[p.token_idx-2].tok == .line_comment
|
||||||
{
|
{
|
||||||
//if p.fileis('parser.v') {
|
//if p.fileis('parser.v') {
|
||||||
@ -231,21 +232,26 @@ fn (p &Parser) gen_fmt() {
|
|||||||
if p.pass != .main {
|
if p.pass != .main {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//println('gen fmt name=$p.file_name path=$p.file_path')
|
||||||
if p.file_name == '' {
|
if p.file_name == '' {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//s := p.scanner.fmt_out.str().replace('\n\n\n', '\n').trim_space()
|
//s := p.scanner.fmt_out.str().replace('\n\n\n', '\n').trim_space()
|
||||||
//s := p.scanner.fmt_out.str().trim_space()
|
//s := p.scanner.fmt_out.str().trim_space()
|
||||||
//p.scanner.fgenln('// nice')
|
//p.scanner.fgenln('// nice')
|
||||||
s := p.scanner.fmt_lines.join('')/*.replace_each([
|
s := p.scanner.fmt_lines.join('')
|
||||||
|
/*.replace_each([
|
||||||
'\n\n\n\n', '\n\n',
|
'\n\n\n\n', '\n\n',
|
||||||
' \n', '\n',
|
' \n', '\n',
|
||||||
') or{', ') or {',
|
') or{', ') or {',
|
||||||
])
|
])
|
||||||
*/
|
*/
|
||||||
//.replace('\n\n\n\n', '\n\n')
|
//.replace('\n\n\n\n', '\n\n')
|
||||||
.replace(' \n', '\n')
|
.replace_each([
|
||||||
.replace(') or{', ') or {')
|
' \n', '\n',
|
||||||
|
') or{', ') or {',
|
||||||
|
')or{', ') or {',
|
||||||
|
] )
|
||||||
|
|
||||||
if s == '' {
|
if s == '' {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user