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
|
||||
endif
|
||||
|
||||
all: latest_vc
|
||||
all: latest_vc latest_tcc
|
||||
ifdef WIN32
|
||||
$(CC) -std=c99 -w -o v0.exe $(TMPVC)/$(VCFILE) $(LDFLAGS)
|
||||
./v0.exe -o v.exe v.v
|
||||
|
@ -586,6 +586,7 @@ fn (p mut Parser) parse(pass Pass) {
|
||||
for i := start; i < end; i++ {
|
||||
p.cgen.lines[i] = ''
|
||||
}
|
||||
p.fgen_nl()
|
||||
}
|
||||
else {
|
||||
p.error('unexpected token `${p.strtok()}`')
|
||||
@ -793,6 +794,9 @@ fn (p mut Parser) type_decl() {
|
||||
cat: .alias
|
||||
is_public: is_pub
|
||||
})
|
||||
if p.tok != .key_type {
|
||||
p.fspace()
|
||||
}
|
||||
}
|
||||
|
||||
// current token is `(`
|
||||
|
@ -81,6 +81,7 @@ fn (p mut Parser) fgen_nl() {
|
||||
// Previous token is a comment, and NL has already been generated?
|
||||
// Don't generate a second NL.
|
||||
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
|
||||
{
|
||||
//if p.fileis('parser.v') {
|
||||
@ -231,21 +232,26 @@ fn (p &Parser) gen_fmt() {
|
||||
if p.pass != .main {
|
||||
return
|
||||
}
|
||||
//println('gen fmt name=$p.file_name path=$p.file_path')
|
||||
if p.file_name == '' {
|
||||
return
|
||||
}
|
||||
//s := p.scanner.fmt_out.str().replace('\n\n\n', '\n').trim_space()
|
||||
//s := p.scanner.fmt_out.str().trim_space()
|
||||
//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',
|
||||
') or{', ') or {',
|
||||
])
|
||||
*/
|
||||
//.replace('\n\n\n\n', '\n\n')
|
||||
.replace(' \n', '\n')
|
||||
.replace(') or{', ') or {')
|
||||
.replace_each([
|
||||
' \n', '\n',
|
||||
') or{', ') or {',
|
||||
')or{', ') or {',
|
||||
] )
|
||||
|
||||
if s == '' {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user